在 Netbeans 中部署我的应用程序期间,日志显示:
06-Mar-2024 20:23:39.783 INFO [Catalina-utility-2] com.sun.faces.spi.InjectionProviderFactory.createInstance JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
jakarta.faces.FacesException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because the return value of "java.security.CodeSource.getLocation()" is null
应用程序在 Tomcat 10 下正确部署。阅读 Tomcat 11 版本信息后,我认为过渡到 Tomcat 11 会很容易。
我的 web.xml 看起来像这样:
<web-app xmlns="jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="jakarta.ee/xml/ns/jakartaee jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0" metadata-complete="true">
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>native</param-value>
</context-param>
<context-param>
<param-name>org.omnifaces.EXCEPTION_TYPES_TO_SUPPRESS</param-name>
<param-value>java.nio.channels.ClosedByInterruptException,java.nio.channels.IllegalSelectorException</param-value>
</context-param>
<welcome-file-list>
<welcome-file>dashboard/index.xhtml</welcome-file>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
<url-pattern>/dashboard/*</url-pattern>
<url-pattern>/changes/*</url-pattern>
<url-pattern>/finance/*</url-pattern>
<url-pattern>/forecast/*</url-pattern>
<url-pattern>/inventory/*</url-pattern>
<url-pattern>/license/*</url-pattern>
<url-pattern>/order/*</url-pattern>
<url-pattern>/project/*</url-pattern>
<url-pattern>/requests/*</url-pattern>
<url-pattern>/resource/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>These roles are allowed access</description>
<role-name>oobimanager</role-name>
<role-name>tomcat</role-name>
<role-name>manager-gui</role-name>
</auth-constraint>
<web-resource-collection>
<web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
<url-pattern>/dashboard/*</url-pattern>
<url-pattern>/admin/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>These roles are allowed access</description>
<role-name>oobiadmin</role-name>
</auth-constraint>
<web-resource-collection>
<web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
<url-pattern>/dashboard/*</url-pattern>
<url-pattern>/inventory/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>These roles are allowed access</description>
<role-name>oobiappliances</role-name>
</auth-constraint>
<web-resource-collection>
<web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
<url-pattern>/dashboard/*</url-pattern>
<url-pattern>/license/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>These roles are allowed access</description>
<role-name>oobilicenses</role-name>
</auth-constraint>
<web-resource-collection>
<web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
<url-pattern>/dashboard/*</url-pattern>
<url-pattern>/order/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>These roles are allowed access</description>
<role-name>oobiorder</role-name>
</auth-constraint>
<web-resource-collection>
<web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
<url-pattern>/shoppingcart/calculator.xhtml</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>These roles are allowed access</description>
<role-name>oobicalculator</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/error.xhtml</form-error-page>
</form-login-config>
</login-config>
<mime-mapping>
<extension>ico</extension>
<mime-type>image/x-icon</mime-type>
</mime-mapping>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mgdsrvoobm</res-ref-name>
<res-type>jakarta.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
也许有人有同样的问题并且已经找到了解决方案。我已经在互联网上搜索过,但找不到解决方案。
这是日志:
07-Mar-2024 11:59:13.308 INFO [http-nio-8080-exec-44] org.apache.catalina.util.LifecycleBase.stop The stop() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/neptun]] after stop() had already been called. The second call will be ignored.
07-Mar-2024 11:59:13.814 INFO [http-nio-8080-exec-44] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/neptun]
07-Mar-2024 11:59:13.832 INFO [http-nio-8080-exec-45] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [/Users/Michael/apache-tomcat-11.0.0-M17/conf/Catalina/localhost/neptun.xml]
07-Mar-2024 11:59:13.833 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/neptun] in deployment descriptor [/Users/Michael/apache-tomcat-11.0.0-M17/conf/Catalina/localhost/neptun.xml] has been ignored
07-Mar-2024 11:59:13.837 WARNING [http-nio-8080-exec-45] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Context/Realm] failed to set property [digest] to [MD5]
07-Mar-2024 11:59:15.413 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [oobimanager] used in an <auth-constraint> without being defined in a <security-role>
07-Mar-2024 11:59:15.413 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [tomcat] used in an <auth-constraint> without being defined in a <security-role>
07-Mar-2024 11:59:15.413 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [manager-gui] used in an <auth-constraint> without being defined in a <security-role>
07-Mar-2024 11:59:15.413 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [oobiadmin] used in an <auth-constraint> without being defined in a <security-role>
07-Mar-2024 11:59:15.413 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [oobiappliances] used in an <auth-constraint> without being defined in a <security-role>
07-Mar-2024 11:59:15.413 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [oobilicenses] used in an <auth-constraint> without being defined in a <security-role>
07-Mar-2024 11:59:15.413 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [oobiorder] used in an <auth-constraint> without being defined in a <security-role>
07-Mar-2024 11:59:15.413 WARNING [http-nio-8080-exec-45] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [oobicalculator] used in an <auth-constraint> without being defined in a <security-role>
07-Mar-2024 11:59:15.433 INFO [http-nio-8080-exec-45] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
07-Mar-2024 11:59:15.439 INFO [http-nio-8080-exec-45] org.jboss.weld.environment.servlet.EnhancedListener.onStartup WELD-ENV-001008: Initialize Weld using ServletContainerInitializer
07-Mar-2024 11:59:15.448 INFO [http-nio-8080-exec-45] org.jboss.weld.bootstrap.WeldStartup.<clinit> WELD-000900: 4.0.0 (Final)
07-Mar-2024 11:59:15.542 INFO [http-nio-8080-exec-45] org.jboss.weld.bootstrap.WeldStartup.startContainer WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
07-Mar-2024 11:59:15.676 INFO [http-nio-8080-exec-45] org.jboss.weld.environment.tomcat.TomcatContainer.initialize WELD-ENV-001100: Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.
07-Mar-2024 11:59:15.799 INFO [http-nio-8080-exec-45] com.sun.faces.config.ConfigureListener.contextInitialized Initializing Mojarra 4.0.0-M1 for context '/neptun'
07-Mar-2024 11:59:15.847 INFO [http-nio-8080-exec-45] com.sun.faces.spi.InjectionProviderFactory.createInstance JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
07-Mar-2024 11:59:15.996 SEVERE [http-nio-8080-exec-45] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because the return value of "java.security.CodeSource.getLocation()" is null
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:316)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:180)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4409)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4844)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:650)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:711)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:599)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:448)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1667)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:294)
at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:803)
at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1477)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:971)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:334)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:619)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:716)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:119)
at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:119)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:597)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:355)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:54)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:673)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:389)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1749)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: jakarta.faces.FacesException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because the return value of "java.security.CodeSource.getLocation()" is null
at com.sun.faces.config.ConfigManager.getAnnotatedClasses(ConfigManager.java:202)
at com.sun.faces.application.ApplicationAssociate.createFaceletFactory(ApplicationAssociate.java:660)
at com.sun.faces.application.ApplicationAssociate.initializeFacelets(ApplicationAssociate.java:349)
at com.sun.faces.application.ApplicationAssociate.getCompiler(ApplicationAssociate.java:384)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:217)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:307)
... 43 more
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because the return value of "java.security.CodeSource.getLocation()" is null
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at com.sun.faces.config.ConfigManager.getAnnotatedClasses(ConfigManager.java:200)
... 48 more
Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because the return value of "java.security.CodeSource.getLocation()" is null
at com.sun.faces.config.manager.tasks.ProvideMetadataToAnnotationScanTask.initializeIvars(ProvideMetadataToAnnotationScanTask.java:78)
at com.sun.faces.config.manager.tasks.ProvideMetadataToAnnotationScanTask.getAnnotationScanURIs(ProvideMetadataToAnnotationScanTask.java:91)
at com.sun.faces.config.manager.tasks.FindAnnotatedConfigClasses.call(FindAnnotatedConfigClasses.java:83)
at com.sun.faces.config.manager.tasks.FindAnnotatedConfigClasses.call(FindAnnotatedConfigClasses.java:40)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at com.sun.faces.config.ConfigManager.findAnnotations(ConfigManager.java:354)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:247)
... 43 more
07-Mar-2024 11:59:15.999 SEVERE [http-nio-8080-exec-45] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
07-Mar-2024 11:59:15.999 SEVERE [http-nio-8080-exec-45] org.apache.catalina.core.StandardContext.startInternal Context [/neptun] startup failed due to previous errors
07-Mar-2024 11:59:16.010 INFO [http-nio-8080-exec-45] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [/Users/Michael/apache-tomcat-11.0.0-M17/conf/Catalina/localhost/neptun.xml] has finished in [2,178] ms
自从从 9.x 升级到 tomcat 11 以来,我们已经有了 JSF 1.1 的产品。 jakarta Face 3版本可以用于tomcat 11。并且支持JSP?