Configuring for RichFaces: java.lang.ClassNotFound

2019-06-26 20:50发布

I have a project that contains some RichFaces components. All other components get displayed but the RichFaces.

From the server logs I get:

java.lang.ClassNotFoundException: org.ajax4jsf.Filter

I am aware that with RichFaces 4.0 no filters are needed in the Web.xml.

Here is my library:

  1. commons-beanutils-1.7.0.jar
  2. commons-collections-3.2.jar
  3. commons-digester-1.8.jar
  4. commons-digester.jar
  5. commons-discovery.jar
  6. commons-logging-1.0.4.jar
  7. cssparser-0.9.5.jar
  8. guava-r08.jar
  9. jhighlight-1.0.jar
  10. jsf-api.jar
  11. jsf-facelets.jar
  12. jsf-impl.jar
  13. richfaces-components-api-4.0.0.Final.jar
  14. richfaces-components-ui-4.0.0.Final.jar
  15. richfaces-core-api-4.0.0.Final.jar
  16. richfaces-core-impl-4.0.0.Final.jar
  17. sac-1.3.jar

and this my web.xml

<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>

I am using GlassFish server 3.1.1

I have tried different configurations, also tried to include ajax4jsf.jar. But always ended up with the same error. Any help is greatly appreciated.

the complete server log is shown here:

0500|SEVERE|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WebModule[/HelloWorld_war_exploded]PWC1270: Exception starting filter richfaces
java.lang.InstantiationException
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:124)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4685)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5377)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
    at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
    at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:219)
    at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
    at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
    at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
    at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
    at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
    at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
    at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:253)
    at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)
    at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)
    at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
    at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
    at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:69)
    at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
    at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
Caused by: java.lang.ClassNotFoundException: org.ajax4jsf.Filter
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1519)

1条回答
贪生不怕死
2楼-- · 2019-06-26 21:12

Remove jsf*.jar from your libraries. The JSF 2.x libs are already provided by Glassfish3. Also, jsf-facelets.jar is of Facelets 1.x for JSF 1.x. The JSF 2.x libs already include Facelets 2.x.

As to the exception, just remove <filter> of org.ajax4jsf.Filter from web.xml. This is from RichFaces 3.x and not necessary anymore in RichFaces 4.x. Make sure that you're reading developer documentation for RichFaces 4.x and not RichFaces 3.x.

查看更多
登录 后发表回答