Wednesday, February 27, 2008

HOWTO: create data aware applications in NetBeans 6.0

Roumen Strobl created a very clear and easy to follow flash demo describing how to create data aware applications using NetBeans 6.0. In the demo, Roumen covers 3 topics:
  • Process for connecting to a MySQL database
  • Steps to create a "data aware" Swing Application that talks to MySQL
  • Steps to create a REST based web service for accessing the same database
You can view Romen's Weblog here and a direct link to the demo here. The entire demo is under 8 minutes so grab a coffee and enjoy.

Somewhere on this page you will find a link to Roumen's weblog. It is on my "bookmark me" list.

Sunday, February 24, 2008

SOLUTION: Web Service Testing in Netbeans 6.0.1 gets ClassNotFound Exception

Overview
Recently, I have been working on creating some web services using NetBeans 6.0/6.0.1. I have done this before and I wasn't creating anything to crazy. I decided to try them out using the new handy Web Services feature that is in the Services tab of the NetBeans 6.0.1 IDE. Within this feature, you can add a WSDL file and look at the features available for consumption from the web service. My favorite aspect of this is that you can right click on any method and test it. A form opens so you can provide parameters. Once submitted, results are returned in an object. This object can be drilled into for more details.

Using this testing feature, I ran into an odd issue however. I created a new WS that I wanted to experiment with. Again, nothing fancy. When I setup the WS in the NetBeans Web Services area, they were added without errors. However, when I tested them, I got a ClassNotFound exception. I looked at everything but got the same results. I even deployed them on a different server that is running a newer build of Tomcat but got the same results. I wrote a simple client that consumed the WS and it _did_ work...? That was not expected. I looked that the issue from many different angles but could not see an obvious cause. Then something occurred to me...

Workaround

My web service name was all lowercase. Since a web service can be considered a class so it should start with an upper case character. This is normally my convention however, this was just a simple experiment.

Basically, I had something like:
https://www.inhouse.headache.net/timezonews/convertWS?wsdl

That should have been like:
https://www.inhouse.headache.net/timezonews/ConvertWS?wsdl

Once I created my Web Service to start with an upper case character, everything worked. I have not read to see if a web service MUST start with an upper case character. If anyone knows the answer, please post

Final Thoughts
This was an odd issue that I ran into using NetBeans. I hope anyone out there who runs into the same thing reads this solution before they lose to much time.

Happy developing using NetBeans.