How to run my JSF 1.1 application on WAS 6.0 - java

I face troubles accessing my website deployed on Websphere Application Server 6.0 when I deploy my application which uses JSF1.1 Runtime Environment.
At first It loaded with some errors telling me that my commandLink is missing bodyContent, which is Optional, but I think edited my pages and the page is displayed.
When I try to press any button or do any event handling, it just doesn't react.
Then I made my web module class Loader mode to : Parent Last, and then I caught an Exception : Error 500: SRVE0207E: Uncaught initialization exception thrown by servlet
The detailed error is
[5/23/06 11:57:23:761 CEST] 0000007d ServletWrappe A SRVE0242I: [component-showcase_war]
[/component-showcase] [/index.jsp]: Initialization successful.
[5/23/06 11:57:23:766 CEST] 0000007d ServletWrappe E SRVE0100E: Did not realize init() exception thrown by servlet Persistent Faces Servlet: java.lang.NullPointerException
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesCommonlet.init(Unknown Source)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet.init(Unknown Source)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:274)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:510)
at com.ibm._jsp._index._jspService(_index.java:66)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java(Inlined Compiled Code))
at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java(Compiled Code))
at com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor.handleRequest(JSPExtensionProcessor.java:241)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2933)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:288)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:201)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:103)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
What do you think is the problem, and what do am i missing here, I've been searching and some people said to delete the default WAS jsf-api.jar file, but it didnt help!

I think WAS has another JSF jar called ws-jsf.jar. Remove it too and try

at com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet.init(Unknown Source)
This servlet is failing to initialize. It might be an idea to go to icesoft.com and find out what it does and why it is failing rather than just deleting files from your app server.
It might be easier to diagnose the problem if you give more details about the technology stack you are using (including the JSF implementation you are deploying with the app).
I made my web module class Loader mode to : Parent Last
This is the correct thing to do. By doing this, your application will use its own JSF implementation instead of the older version in the container. I did not delete any files.
Here the structure of a simple JSF 1.1 application I deployed to WAS 6.0. I used the MyFaces library version 1.1.6.
test.jsp
WEB-INF/faces-config.xml
WEB-INF/web.xml
WEB-INF/lib/commons-beanutils-1.7.0.jar
WEB-INF/lib/commons-el-1.0.jar
WEB-INF/lib/jstl-1.1.0.jar
WEB-INF/lib/commons-collections-3.1.jar
WEB-INF/lib/commons-lang-2.1.jar
WEB-INF/lib/myfaces-api-1.1.6.jar
WEB-INF/lib/commons-digester-1.8.jar
WEB-INF/lib/commons-logging-1.1.1.jar
WEB-INF/lib/myfaces-impl-1.1.6.jar
faces-config.xml doctype:
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>jsf11</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>-1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>

Related

Jersey : How to prevent Conflicting URI templates with other web services in the same web app

I am trying to introduce Jersey web service into a web application that has other web services (such as Apache CXF in it) in it. So I added Jersey servlet to my web.xml..
<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.spring.container.servlet.SpringServlet
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.freedomoss.crowdcontrol.api</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
During intiliazation this servlet gives the following error about conflicting URL templates...
INFO: Registering Spring bean, restApiService, of type com.mycompany.ws.RestApiService as a root resource class
Mar 12, 2015 11:07:42 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Conflicting URI templates. The URI template / for root resource class com.mycompany.ws.RestApiService and the URI template / transform to the same regular expression (/.*)?
When I look in the code of this RestApiService, I see..
#Path("/")
#Service
public class RestApiService extends AbstractRestService {
Since this other web service is being used elsewhere in the application I cannot change the value of 'Path' although doing so does solve my problem
What else can I do? Can I somehow tell Jersey Servlet not to register this other web service "as a root resource class"?
My goal is to make Jersey work along with this other web service and not change the latter in any way.

Tomcat unable to parse web.xml, no error at mentioned code point

I am using Jersey for my web service, and this is how my web.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-name>com.rohanprabhu.external.interfaces.service.web</param-name>
</init-param>**
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-name>true</param-name>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>*</url-pattern>
</servlet-mapping>
</web-app>
I am getting an error Occurred at line 10 column 22, which is where I have marked in my file as '**' (it isn't actually there in the file, I just put it on here). Here is (a part) of the stack trace I get:
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.IllegalArgumentException: Can't convert argument: null
at org.apache.tomcat.util.IntrospectionUtils.convert(IntrospectionUtils.java:889)
at org.apache.tomcat.util.digester.CallMethodRule.end(CallMethodRule.java:476)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1057)
... 188 more
Occurred at line 10 column 22
Marking this application unavailable due to previous error(s)
Here is the entire stacktrace, in case that helps: http://pastebin.com/EX4bMGex
I agree the error message is suboptimal, but I'm also sure you want one <param-name> and one <param-value> per <init-param>. :-)
You are using <param-name> twice. but other init attribute should be <param-value>.

Websphere 7 with JSF 2

I need to use JSF 2 for an application running under Websphere 7.0.0.13, I have followed this:
http://www.manorrock.com/online/wiki/app/page/edit.html
***It says:
Even though Websphere 7 does not formally support JSF 2.0 you can get it to work in a degraded mode. Follow the steps below to get it to work on your version of Websphere 7.
Upgrade to at least version 7.0.0.13
Ship the Mojarra JAR files in your WEB-INF/lib directory
Set the WAR classloader to PARENT_LAST
Set the EAR classloader to PARENT_LAST and APPLICATION
Note the degraded mode means you are NOT going to be able to use #Resource or any JPA annotations. If you think you need support for it contact your IBM representative.
Note it will process #PostConstruct and #PreDestroy.***
I did this, but I getting this error, in the log:
[8/30/13 22:51:32:702 CDT] 0000000c webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
java.lang.LinkageError: loading constraint violation: loader "com/ibm/ws/classloader/CompoundClassLoader#31c031c" previously initiated loading for a different type with name "javax/servlet/ServletContext" defined by loader "org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader#66656665"
at com.sun.faces.config.WebConfiguration.getInstance(WebConfiguration.java:184)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:163)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1681)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:374)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:299)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100
And the error en my page:
Error 404: javax.servlet.UnavailableException: SRVE0201E: Servlet [javax.faces.webapp.FacesServlet]: not a servlet class
This is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" 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">
<display-name>testJSF2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
I accesed by:
..../testJSF2/index.faces
If I enter by:
..../testJSF2/index.jsp
get this in the page:
HTTP Error Code: 500
Error Message:
JSPG0049E: /index.jsp failed to compile :
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 48 : The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 100 : The method handlePageException(Exception) in the type PageContext is not applicable for the arguments (Throwable)
JSPG0091E: An error occurred at line: 20 in the file: /index.jsp
JSPG0093E: Generated servlet error from file: /index.jsp
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 119 : The method getELContext() is undefined for the type PageContext
JSPG0091E: An error occurred at line: 21 in the file: /index.jsp
JSPG0093E: Generated servlet error from file: /index.jsp
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 144 : The method getELContext() is undefined for the type PageContext
Root Cause:
com.ibm.ws.jsp.JspCoreException: JSPG0049E: /index.jsp failed to compile :
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 48 : The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 100 : The method handlePageException(Exception) in the type PageContext is not applicable for the arguments (Throwable)
JSPG0091E: An error occurred at line: 20 in the file: /index.jsp
JSPG0093E: Generated servlet error from file: /index.jsp
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 119 : The method getELContext() is undefined for the type PageContext
JSPG0091E: An error occurred at line: 21 in the file: /index.jsp
JSPG0093E: Generated servlet error from file: /index.jsp
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 144 : The method getELContext() is undefined for the type PageContext
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.translateJsp(AbstractJSPExtensionServletWrapper.java:574)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper._checkForTranslation(AbstractJSPExtensionServletWrapper.java:441)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.checkForTranslation(AbstractJSPExtensionServletWrapper.java:299)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:149)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
Thanks for you help.
For WebSphere 7, I've followed another article:
http://wasbehindtheglass.blogspot.co.uk/2011/11/myfaces-20-and-websphere-application.html
I've created shared library on WebSphere (name is not important, only content) with following jars:
manifest.jar
myfaces-api-2.0.7.jar
myfaces-impl-2.0.7.jar
commons-logging-1.1.1.jar
commons-digester-1.8.jar
commons-collections-3.2.jar
commons-codec-1.3.jar
commons-beanutils-1.8.3.jar
\IBM\SDP\runtimes\base_v7\optionalLibraries\IBM\JSFProviders\WebSphere-MyFaces20-annotation-provider.jar
You need to give absolute paths. WebSphere-MyFaces20-annotation-provider.jar should be in your WebSphere installation. manifest.jar is the jar containing only following META-INF/MANIFEST.MF:
Manifest-Version: 1.0
Extension-Name: org/apache/myfaces
Specification-Title: MyFaces 2.0.7 shared lib
Specification-Version: 1.0
Specification-Vendor: apache.org
Implementation-Version: 1.0
Final thing to be done is to modify your pom.xml to create the manifest entries referring the shared library:
<manifestEntries>
<Extension-List>myfaces</Extension-List>
<myfaces-Extension-Name>org/apache/myfaces</myfaces-Extension-Name>
<myfaces-Specification-Version>1.0</myfaces-Specification-Version>
</manifestEntries>
After the deploy, if both shared library and manifest are configured correctly, the binding is automatically created.
I'd guess you are not only providing the JSF classes, but a second instance / api as well.
Check if you have a servlet-api or something similar in your WEB-INF/lib folder.
As it cannot load the ServletContext you get the other follow-up errors. Probably even loading a simple jsp with no JSF in it fails.
I tried this, and it is working, just put here an alternative solution for future questions
this issue happen because we have add the servlet-api-2.5.jar in the project lib so when we remove it work .
so here the final Step to get this work
1- set the Parent last in the class loading policy for the application and module as well .
2- don't add the servlet-api-2.5 .jar to the porject lib
taked from here
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014541986
C:\apache-tomcat-8.0.3\webapps\kumar-app\WEB-INF\lib\servlet-api-2.3.jar
C:\apache-tomcat-8.0.3\lib\servlet-api.jar
I had above jar file version mismatch , i deleted the jar from C:\apache-tomcat-8.0.3\webapps\kumar-app\WEB-INF\lib\servlet-api-2.3.jar and my application worked properly.

Tomcat 7: Invalid mapping (java.lang.IllegalArgumentException) [duplicate]

This question already has answers here:
java.lang.IllegalArgumentException: The servlets named [X] and [Y] are both mapped to the url-pattern [/url] which is not permitted
(7 answers)
Closed 7 years ago.
I am migrating an existing project from Tomcat 6 to 7. Upon startup I am encountering this logged error message:
Jul 02, 2013 2:38:39 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at jndi:/localhost/padd/WEB-INF/web.xml
org.xml.sax.SAXParseException; systemId: jndi:/localhost/padd/WEB-INF/web.xml; lineNumber: 309; columnNumber: 21; Error at (309, 21) : The servlets named [ArtefactServlet] and [saveArtefactServlet] are both mapped to the url-pattern [/saveRestoration] which is not permitted
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2687)
...
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: The servlets named [ArtefactServlet] and [saveArtefactServlet] are both mapped to the url-pattern [/saveRestoration] which is not permitted
Here the WEB-INF/web.xml line 309fff:
<servlet-mapping>
<servlet-name>saveArtefactServlet</servlet-name>
<url-pattern>/saveRestoration</url-pattern>
</servlet-mapping>
EDIT:
<servlet-mapping>
<servlet-name>ArtefactServlet</servlet-name>
<url-pattern>/saveRestoration</url-pattern>
</servlet-mapping>
Here tomcat's web.xml:
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- The mappings for the JSP servlet -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
I tried to play around with the mapping, but couldn't make any progress. Hope you can help!
The error says :
The servlets named [ArtefactServlet] and [saveArtefactServlet] are
both mapped to the url-pattern [/saveRestoration] which is not
permitted
So tomcat doesn't know which servlet to be called when your url pattern is matched. Give different url patterns for these two servlets ArtefactServlet, saveArtefactServlet
java.lang.IllegalArgumentException: The servlets named...
I fetched this cause where I create new servlet in different package (name='syncro'). My servlet located in syncro.SynchronizeServlet
And when I add information about this servlet in deployment descriptor (web.xml) I catch error: IllegalArgumentException
Example of incorrect descriptor part:
<servlet>
<description></description>
<display-name>SynchronizeServlet</display-name>
<servlet-name>SynchronizeServlet</servlet-name>
<servlet-class>SynchronizeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SynchronizeServlet</servlet-name>
<url-pattern>/SynchronizeServlet</url-pattern>
<url-pattern>/SynServlet</url-pattern>
</servlet-mapping>
When I add correct path for servlet - error disappeared. Correct desc below:
<servlet>
<description></description>
<display-name>syncro.SynchronizeServlet</display-name>
<servlet-name>syncro.SynchronizeServlet</servlet-name>
<servlet-class>syncro.SynchronizeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>syncro.SynchronizeServlet</servlet-name>
<url-pattern>/SynchronizeServlet</url-pattern>
<url-pattern>/SynServlet</url-pattern>
</servlet-mapping>
==> 73!

Deploying Jersey-enabled servlet to Tomcat: Exceptions

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.
You have probably a conflict somewhere, check your jar files and see if there are no duplicate classes. Use Tattletale to locate the problem
**Caused by: java.lang.NoSuchMethodError: javax.ws.rs.ext.Providers.getContextResolver(Ljava/lang/Class;Ljavax/ws/rs/core/MediaType;)Ljavax/ws/rs/ext/ContextResolver;**
at com.sun.jersey.impl.provider.entity.AbstractJAXBProvider.<init>(AbstractJAXBProvider.java:81)
at com.sun.jersey.impl.provider.entity.AbstractRootElementProvider.<init>(AbstractRootElementProvider.java:67)
at com.sun.jersey.impl.provider.entity.XMLRootElementProvider.<init>(XMLRootElementProvider.java:66)
at com.sun.jersey.impl.provider.entity.XMLRootElementProvider$App.<init>(XMLRootElementProvider.java:72)
... 41 more

Categories