[英]JSF 2 doesn't work on WebSphere 7 - Redirecting to JSP
我有一个使用JSF 2在JBoss上运行良好的应用程序。我看到了与JSF 2,WebSphere和Class Loader有关的问题。 这时,我看到消息“为上下文'/ medicao-web'初始化Mojarra 2.1.7”。 然后,我认为类加载器正在加载正确的JSF类。
我有一个index.jsp,用于重定向到index.jsf。 当我尝试请求index.jsf时,它会导致无限循环和许多异常。 在堆栈跟踪中,有一个“位于javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)”,然后我认为它有时正在使用FacesServlet。 但是我还在日志中看到与JSF相关的问题是它正在尝试读取JSP。
我还尝试请求另一个页面,即没有同名的JSP。 请求arquivo.jsf之后,我得到:
java.io.FileNotFoundException: JSPG0036E: Failed to find resource /arquivo.jsp
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.findWrapper(AbstractJSPExtensionProcessor.java:360)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:331)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:325)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:415)
at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:491)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:159)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1443)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1384)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:852)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:785)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3610)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:274)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:926)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
这是我的web.xml:
<?xml version="1.0"?>
<web-app 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>MedicaoCNI</display-name>
<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>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>medicao</param-value>
</context-param>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</web-app>
这是我的faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude" 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">
<!-- <lifecycle>
<phase-listener>org.cni.medicao.util.AuthenticationListener</phase-listener>
</lifecycle> -->
<navigation-rule>
<from-view-id>/*</from-view-id>
<navigation-case>
<from-outcome>loginSucesso</from-outcome>
<to-view-id>/usuario.jsf</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>loginFail</from-outcome>
<to-view-id>/index.jsf</to-view-id>
<redirect />
</navigation-case>
<navigation-case>
<from-outcome>logoutSucesso</from-outcome>
<to-view-id>/index.jsf</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config>
我所有的页面都是XHTML格式。 我还向我的项目添加了facelets依赖性。 我正在使用Maven。
我进行了一些配置,以尝试使类加载器加载PARENT_LAST。 我不知道它是否正确,但是虽然日志显示它已加载Mojarra 2.1.7,但我认为还可以。
我找到了与我的文章有关,但并没有解决: WebSphere 7+中的JSF 2 Mojarra和Primefaces
提前致谢。
更新:
我试图将javax.faces.DEFAULT_SUFFIX上下文参数添加到.xhtml。 结果是,当我尝试打开arquivo.jsf时,我看到了XHTML的源代码。 尽管日志中说正在初始化Mojarra 2.1.7,但我感觉这里有些冲突。
这是我的耳朵的Maven模块的耳朵插件配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<version>5</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<earSourceDirectory>${basedir}\src\main\application\META-INF\ibmconfig</earSourceDirectory>
</configuration>
</plugin>
在\\ src \\ main \\ application \\ META-INF \\ ibmconfig中,有deployment.xml:
<appdeployment:Deployment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:appdeployment="http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi" xmi:id="Deployment_1241112964096">
<deployedObject xmi:type="appdeployment:ApplicationDeployment" xmi:id="ApplicationDeployment_1241112964096" startingWeight="1" warClassLoaderPolicy="SINGLE">
<classloader xmi:id="Classloader_1241112964096" mode="PARENT_LAST"/>
<modules xmi:type="appdeployment:WebModuleDeployment" xmi:id="WebModuleDeployment_1241112964096" startingWeight="10000" uri="medicao-web.war">
<classloader xmi:id="Classloader_1241112964097" mode="PARENT_LAST"/>
</modules>
</deployedObject>
</appdeployment:Deployment>
在我的网站的maven模块中,我具有以下依赖关系:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.14</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
有什么不对? 我是WebSphere的新手,需要与JSF 2一起使用。
更新:
我删除了jsf-facelets依赖关系,但是还不能正常工作。 我导出了一个EAR,看是否有deployment.xml,但是没有将其打包在EAR中。 有什么不对?
更新:
现在,我正在关注本教程: http : //www.webspheretools.com/sites/webspheretools.nsf/docs/How%20to%20set%20the%20class%20loading%20policy%20to%20parent%20last%20using%20configuration %20files%20shipped%20in%20the%20EAR
我的deployment.xml在\\ META-INF \\ ibmconfig \\ cells \\ defaultCell \\ applications \\ defaultApp \\ deployments \\ defaultApp下,并且我的耳塞的配置为:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<version>5</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
这样,当我导出EAR时,将对deployment.xml进行打包。 我的deployment.xml与本教程中显示的相同。
无论如何,当我在WebSphere上部署应用程序时,它会生成一个新的deploy.xml,而忽略了我的。 然后,它仍然会先加载父级。
好吧,我所有的配置都还可以。 我尝试使用WebSphere的控制台安装EAR,它读取了我的deployment.xml。 我认为IBM开发的WebSphere 7插件有问题。 它没有正确安装应用程序,然后忽略了deployment.xml。
现在我的问题与IDE有关,因为每次更改应用程序时手动安装应用程序都是很糟糕的,但是这个问题并不关乎它。
我认为websphere 7没有桥梁就不支持JSF 2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.