WSIT with Tomcat and NetBean
While studying the world of interoperability in webservices stacks, after Axis2, I set up a environment with NetBeans 5.5.1 and Tomcat to test the stack from SUN : Metro and its interop component WSIT. After installing NetBeans and the WSIT module, you can easily create a new web application project and a webservice inside the IDE. But if you want WS-* capabilities you must add the WSIT runtime library to TOMCAT. The installation is simple (for JSE 6 there’s a trick) :
- download WSIT,
- copy webservices-api.jar to TOMCAT_HOME\common\endorsed\lib
- copy the others jars in TOMCAT_HOME\shared\lib
Then you can right click on the webservice in NetBeans and edit attributes, you have a WSIT tab (here I activate WS-Security with a username token, by default WSIT looks for the user in the tomcat-users.xml file but a validator class can be specified) :
When you deploy the application, you see a JAX-WS deployment message but the wsdl doesn’t include the policy elements from WSIT (which are described in a xml file under the WEB-INF folder). Why ? Because the bundled Tomcat in NetBeans refers to two folders to configure the server : one in CATALINA_HOME and one in CATALINA_BASE (whih is under the .netbeans folder inside Document and Settings\YOUR_USERNAME). And in one of theses folders, the declaration to add the WSIT runtime jars is not included in catalina.properties.
it’s obviously more simple to use a fresh TOMCAT installation and copy the jars from WSIT and use this server in NetBeans. From here, you can encounter two problems :
- a ClassCastException from WSDLGeneratorExtension. There are some class loading problems between JAX-WS 2.1 libraries in your project and the runtime in Tomcat where you deploy. In the “nbproject\build-impl.xml” file just remove or comment the the copy tasks declarations of the JAX-WS libraries (located inside the “library-inclusion-in-archive” target). After cleanning, build and deploy your application.
- tomcat-users.xml is not well formed and the lookup of the user failed. Replace the declaration of the user <user name=“admin” password="" roles=“admin,manager” /> by <user username=“admin” password="" roles=“admin,manager”/>
Billet publié dans les rubriques Programmation le