在glassfish上部署JSF应用程序时出错

时间:2011-06-24 18:11:48

标签: java jsf glassfish

尝试通过netbeans6.9在glassfish服务器上运行我的jsf应用程序时出现以下错误。

来自Mozilla firefox:

HTTP Status 500 -

type: Exception report

message:

description: The server encountered an internal error () that prevented it from fulfilling this request.

exception:    javax.servlet.ServletException: PWC1243: Filter execution threw an exception

root cause:    java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory

root cause:    java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory

Glassfish输出如下:

    Welcome to Felix
    ================
    INFO: Perform lazy SSL initialization for the listener 'http-listener-2'
    INFO: Starting Grizzly Framework 1.9.18-o - Fri Jun 24 23:30:29 IST 2011
    INFO: Starting Grizzly Framework 1.9.18-o - Fri Jun 24 23:30:29 IST 2011
    INFO: Grizzly Framework 1.9.18-o started in: 842ms listening on port 4848
    INFO: Grizzly Framework 1.9.18-o started in: 795ms listening on port 3700
    INFO: Grizzly Framework 1.9.18-o started in: 920ms listening on port 8080
    INFO: Grizzly Framework 1.9.18-o started in: 858ms listening on port 8181
    INFO: Grizzly Framework 1.9.18-o started in: 748ms listening on port 7676
    INFO: GlassFish Server Open Source Edition 3.0.1 (22) startup time : Felix(22511ms) startup services(3244ms) total(25755ms)
    INFO: Binding RMI port to *:8686
    INFO: Hibernate Validator bean-validator-3.0-JBoss-4.0.2
    INFO: JMXStartupService: Started JMXConnector, JMXService URL = service:jmx:rmi://192.168.1.3:8686/jndi/rmi://192.168.1.3:8686/jmxrmi
    INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    INFO: Grizzly Framework 1.9.18-o started in: 16ms listening on port 8080
    INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
    INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
    INFO: Perform lazy SSL initialization for the listener 'http-listener-2'
    INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\Users\Rajat\.netbeans\6.9\config\GF3\domain1\autodeploy\bundles, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\Rajat\AppData\Local\Temp\fileinstall--7360438857828003896, felix.fileinstall.filter = null}
    INFO: Grizzly Framework 1.9.18-o started in: 47ms listening on port 8181
    INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\Program Files\glassfish-3.0.1\glassfish\modules\autostart, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\Rajat\AppData\Local\Temp\fileinstall--8677560274950500254, felix.fileinstall.filter = null}
    INFO: SEC1002: Security Manager is OFF.
    INFO: Security startup service called
    INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
    INFO: Realm admin-realm of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
    INFO: Realm file of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
    INFO: Realm certificate of classtype com.sun.enterprise.security.auth.realm.certificate.CertificateRealm successfully created.
    INFO: Security service(s) started successfully....
    INFO: Created HTTP listener http-listener-1 on port 8080
    INFO: Created HTTP listener http-listener-2 on port 8181
    INFO: Created HTTP listener admin-listener on port 4848
    INFO: Created virtual server server
    INFO: Created virtual server __asadmin
    INFO: Updating configuration from org.apache.felix.fileinstall-autodeploy-bundles.cfg
    INFO: Installed C:\Program Files\glassfish-3.0.1\glassfish\modules\autostart\org.apache.felix.fileinstall-autodeploy-bundles.cfg
    INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\Users\Rajat\.netbeans\6.9\config\GF3\domain1\autodeploy\bundles, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\Rajat\AppData\Local\Temp\fileinstall--3915594108307422560, felix.fileinstall.filter = null}
    INFO: Virtual server server loaded system default web module
    INFO: Initializing Mojarra 2.0.2 (FCS b10) for context '/Px10App'
    INFO: Running on PrimeFaces 3.0.M1
    INFO: Loading application Px10App at /Px10App
    INFO: Px10App was successfully deployed in 19,578 milliseconds.
    WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
    java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
            at java.lang.Class.getConstructor0(Class.java:2699)
            at java.lang.Class.getConstructor(Class.java:1657)
            at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:301)
            at com.sun.enterprise.web.WebContainer.createFilterInstance(WebContainer.java:725)
            at com.sun.enterprise.web.WebModule.createFilterInstance(WebModule.java:1948)
            at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:248)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
            at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
            at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:959)
            at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1430)
            ... 33 more

    WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
    java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
            at java.lang.Class.getConstructor0(Class.java:2699)
            at java.lang.Class.getConstructor(Class.java:1657)
            at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:301)
            at com.sun.enterprise.web.WebContainer.createFilterInstance(WebContainer.java:725)
            at com.sun.enterprise.web.WebModule.createFilterInstance(WebModule.java:1948)
            at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:248)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
            at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
            at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:959)
            at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1430)
            ... 33 more

    WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
    java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
            at java.lang.Class.getConstructor0(Class.java:2699)
            at java.lang.Class.getConstructor(Class.java:1657)
            at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:301)
            at com.sun.enterprise.web.WebContainer.createFilterInstance(WebContainer.java:725)
            at com.sun.enterprise.web.WebModule.createFilterInstance(WebModule.java:1948)
            at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:248)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
            at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
            at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:959)
            at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1430)
            ... 33 more

如何成功运行应用程序?

1 个答案:

答案 0 :(得分:2)

从异常中可以看出,应用程序所需的某些类未被类加载器加载,因为它们的定义(.class文件)不存在。

这通常是因为类在应用程序服务器中完全不可用(如Tomcat 6上的EJB API),或者您错过了打包特定依赖项(在本例中为Apache Commons FileUpload库)。您需要确保您的EAR / WAR文件在某个位置(通常是WAR文件的WEB-INF / lib或EAR文件的/ lib目录)中包含此依赖项,以使类加载器能够在运行时找到所需的类

在Netbeans中,您通常不需要做任何事情来确保这一点。我的意见是,对于Apache Commons FileUpload库(或jar文件),未选中“package”复选框(请参阅下面的屏幕截图),因此Netbeans将不再将其打包到WAR / EAR文件中。不要忘记清理并重建项目。

Netbeans package library JAR option

如果您不希望将库添加到项目中(出于某种未知原因),您也可以在项目的打包属性中执行此操作。您需要将WAR文件中的路径显式指定为“WEB-INF / lib”。

Package library into WAR