Hey guys,
Here is what I'm trying to do: we are switching over to using JAXB and Jersey for all our REST services and XML/JSON serialization needs.
So far, I have been able to get a simple test working where some beans are annotated, some test objects created and these are perfectly serialized to either XML or JSON and return to the client upon request. I mostly wrote this based on some of the examples around the Internet, where the an HTTPServer is created and started in the main method.
I am now trying to put this same example into a WAR file and deploy it to my local Tomcat server so I can test it in a more production-like environment. Seeing as I was not able to get it to work on Tomcat 5.5.27 following the instructions here I went ahead and upgraded to Tomcat 6.0. Same instructions, same outcome, a huge InvocationTargetException.
What exactly am I missing guys?
INFO: Scanning for root resource and provider classes in the paths:
/Library/Tomcat/Home/webapps/user/WEB-INF/lib
/Library/Tomcat/Home/webapps/user/WEB-INF/classes
Sep 9, 2009 7:22:32 PM com.sun.jersey.api.core.ClasspathResourceConfig init
INFO: Root resource classes found:
class example.HelloWorld
Sep 9, 2009 7:22:32 PM com.sun.jersey.api.core.ClasspathResourceConfig init
INFO: Provider classes found:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.jersey.impl.application.WebApplicationImpl$DefaultComponentProvider.getInstance(WebApplicationImpl.java:437)
at com.sun.jersey.impl.application.ComponentProviderCache.getComponent(ComponentProviderCache.java:187)
at com.sun.jersey.impl.application.ComponentProviderCache.getProvidersAndServices(ComponentProviderCache.java:122)
at com.sun.jersey.impl.application.InjectableProviderFactory.configure(InjectableProviderFactory.java:113)
at com.sun.jersey.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:582)
at com.sun.jersey.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:487)
at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:622)
at com.sun.jersey.spi.container.servlet.ServletContainer.load(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:197)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
That's part of the ginormous spew in catalina.out.
Also, here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.jersey.impl.container.servlet.ServletAdaptor</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Any help with this would be greatly appreciated! Thanks in advance.