Wednesday, January 7, 2009

Netbeans modified web.xml when it shouldn't

A couple of days ago, I was working on a J2EE project using EJB 3.0 and plain JSP/Servlets. I used Netbeans 6.0.1 with GlassFish 9.1 on my XP Professional PC. For some reason, the project build kept on failing, without any changes in the configuration files which I barely touched. After digging through the stack traces and log files I got, I found this message "The ResourceConfig instance does not contain any root resource classes". I googled for that and found that others got the same problem. I followed this thread on java.net forums, and was really angry to find that Netbeans added stuff to my web.xml, which of course couldn't be resolved by the deployment script. This is the extra parts the guys mentioned on the forum and I found in my web.xml:

<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.ws.rest.impl.container.servlet.ServletAdaptor</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
and:
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>

It seemed like it had to do with the RESTful webservices plug-ins which I didn't even reference in that project. I removed the extra parts from my web.xml and also removed the RESTful plug-ins to make sure it doesn't happen again and everything went fine.

No comments: