Websphere 7 with JSF 2 - java

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.

Related

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!

JAX-RS exception with Tomcat

When starting the a servlet (from eclipse), I'm getting the following error:
It's tomcat 7 and the servlet is REST.
INFO: validateJarFile(C:\beezer\WebServerWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BeezerServer\WEB-INF\lib\geronimo-j2ee_1.4_spec-1.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
448 [localhost-startStop-1] ERROR org.apache.wink.server.internal.servlet.RestServlet - com.test.AddressBookApplication<br />
java.lang.ClassNotFoundException: com.test.AddressBookApplication<br />
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)<br/>
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)<br/>
at java.lang.Class.forName0(Native Method)<br/>
at java.lang.Class.forName(Class.java:169)<br/>
at org.apache.wink.server.internal.servlet.RestServlet.getApplication(RestServlet.java:144)<br/>
at org.apache.wink.server.internal.servlet.RestServlet.createRequestProcessor(RestServlet.java:105)<br/>
at org.apache.wink.server.internal.servlet.RestServlet.init(RestServlet.java:81)<br/>
at javax.servlet.GenericServlet.init(GenericServlet.java:160)<br/>
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)<br/>
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)<br/>
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)<br/>
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)<br/>
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)<br/>
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)<br/>
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)<br/>
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)<br/>
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)<br/>
at java.util.concurrent.FutureTask.run(FutureTask.java:138)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)<br/>
at java.lang.Thread.run(Thread.java:662)<br/>
Aug 30, 2012 7:49:41 PM org.apache.catalina.core.ApplicationContext log<br/>
INFO: Marking servlet JAX-RS Servlet as unavailable<br/>
Aug 30, 2012 7:49:41 PM org.apache.catalina.core.StandardContext loadOnStartup<br/>
SEVERE: Servlet /BeezerServer threw load() exception<br/>
javax.servlet.UnavailableException: com.test.AddressBookApplication<br/>
at org.apache.wink.server.internal.servlet.RestServlet.init(RestServlet.java:91)<br/>
at javax.servlet.GenericServlet.init(GenericServlet.java:160)<br/>
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)<br/>
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)<br/>
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)<br/>
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)<br/>
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)<br/>
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)<br/>
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)<br/>
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)<br/>
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)<br/>
at java.util.concurrent.FutureTask.run(FutureTask.java:138)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)<br/>
at java.lang.Thread.run(Thread.java:662)<br/>
Aug 30, 2012 7:49:41 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
My web.XML:
<?xml version="1.0" encoding="UTF-8"?><br/> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>BeezerServer</display-name>
<servlet>
<description>JAX-RS Tools Generated - Do not modify</description>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.test.AddressBookApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/jaxrs/*</url-pattern>
</servlet-mapping>
Does anyone has a clew?
thanks!
First check that this class really exists. Check class name and package. Does it belong to the web project or dependent project?
If everything is OK, refresh project, then run Project/Clean, then clean and re-publish tomcat. If it does not work create server again (I mean in eclipse). If it still does not work go to C:\beezer\WebServerWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BeezerServer\WEB-INF\classes (the path is taken from your log) and check that the class file is there.
Good luck and welcome to the club of people that spend night fighting against the bugs in plugin of tomcat for eclipse...
Get rid of C:\beezer\WebServerWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BeezerServer\WEB-INF\lib\geronimo-j2ee_1.4_spec-1.1.jar It contains the class Servlet.java, which should be provided by the AS itself. If you are using Maven, mark the dependency as provided (<scope>provided</scope>)
Btw. the jar is still needed for compilation, but not in runtime.
EDIT: Oh, now I've noticed, it is only INFO in the log. So it is not the source of the problem, the root cause is the ClassNotFound ex. Make sure the class is on the classpath.

java.lang.NullPointerException at com.sun.faces.context.flash.ELFlash.getFlash

I had created a simple JSF2.0 app and it runs fine in my computer, but when I try to run it in Heroku, I get this error:
HTTP ERROR 500
Problem accessing /login.xhtml. Reason:
Server Error
Caused by:
java.lang.NullPointerException
at com.sun.faces.context.flash.ELFlash.getFlash(ELFlash.java:93)
at com.sun.faces.context.flash.ELFlash.getELFlash(ELFlash.java:124)
at com.sun.faces.context.flash.ELFlash.doPostPhaseActions(ELFlash.java:722)
at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:108)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:481)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:940)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:904)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:565)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:46)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:545)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Thread.java:636)
So, any solution to this problem?
Thanks in advance.
java.lang.NullPointerException
at com.sun.faces.context.flash.ELFlash.getFlash(ELFlash.java:93)
at com.sun.faces.context.flash.ELFlash.getELFlash(ELFlash.java:124)
I don't recognize the ELFlash#getELFlash() method as part of recent Mojarra implementations. Perhaps you're using a very early 2.0.0 implementation which has a bug related to this. Upgrading to the latest should fix this problem.
but the problem with annotations persists in Heroku
javax.el.PropertyNotFoundException: /login.xhtml #15,55 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100‌​)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(Html‌​BasicInputRenderer.java:95)
JSF2 annotations will fail if your faces-config.xml is not properly declared conform JSF2 specification. Make sure that the <faces-config> root declaration look like this:
<faces-config
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-facesconfig_2_0.xsd"
version="2.0">
<!-- config here -->
</faces-config>

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

How to run my JSF 1.1 application on WAS 6.0

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>

Categories