Tomcat 异常:java.lang.reflect.InvocationTargetException、java.lang.SecurityException、org.xml.sax.SAXNotRecognizedException
Tomcat Exception: java.lang.reflect.InvocationTargetException, java.lang.SecurityException, org.xml.sax.SAXNotRecognizedException
在 tomcat 8.5.16 版本中部署 .war 文件时,出现以下错误:
Exception
java.lang.SecurityException: AuthConfigFactory error:
java.lang.reflect.InvocationTargetException
javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:85)
org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1205)
org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1195)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:469)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source) Root Cause
java.lang.reflect.InvocationTargetException
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) java.lang.reflect.Constructor.newInstance(Unknown Source)
javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:76)
javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:66)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:65)
org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1205)
org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1195)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:469)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source) Root Cause
java.lang.SecurityException: org.xml.sax.SAXNotRecognizedException:
SAX feature 'http://apache.org/xml/features/allow-java-encodings' not
recognized.
org.apache.catalina.authenticator.jaspic.PersistentProviderRegistrations.loadProviders(PersistentProviderRegistrations.java:66)
org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.loadPersistentRegistrations(AuthConfigFactoryImpl.java:329)
org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.(AuthConfigFactoryImpl.java:69)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) java.lang.reflect.Constructor.newInstance(Unknown Source)
javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:76)
javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:66)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:65)
org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1205)
org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1195)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:469)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source) Root Cause
org.xml.sax.SAXNotRecognizedException: SAX feature
'http://apache.org/xml/features/allow-java-encodings' not recognized.
oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:230)
org.apache.tomcat.util.digester.Digester.setFeature(Digester.java:478)
org.apache.catalina.authenticator.jaspic.PersistentProviderRegistrations.loadProviders(PersistentProviderRegistrations.java:62)
org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.loadPersistentRegistrations(AuthConfigFactoryImpl.java:329)
org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.(AuthConfigFactoryImpl.java:69)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) java.lang.reflect.Constructor.newInstance(Unknown Source)
javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:76)
javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:66)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:65)
org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1205)
org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1195)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:469)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source) Note The full stack trace of the
root cause is available in the server logs.
有什么解决办法吗?
在$TOMCAT_HOME/conf/catalina.properties
在死角设置以下 4 个罐子:
javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
javax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
javax.xml.datatype.DatatypeFactory=com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl
这将设置您的 catalina 环境以包含所需的 .jars。
以下内容可能对某些人有用。
在 Azure PaaS WebApps 环境中 运行 Tomcat 时,我遇到了与@Om Sao 完全相同的问题。对我来说,问题是 site/wwwroot/webapps
下没有 ROOT 目录。添加 ROOT 目录后(我不确定在 ROOT 目录中实际需要什么 - 如果有的话 - 才能使其正常工作)然后问题就消失了。
我遇到这个问题的另一次是我在 Azure 中单击“部署到根目录”时不小心将我的应用程序上传到 ROOT 目录(在 Eclipse 中作为 Azure Web 应用程序执行 Azure/Publish)
在 tomcat 8.5.16 版本中部署 .war 文件时,出现以下错误:
Exception
java.lang.SecurityException: AuthConfigFactory error: java.lang.reflect.InvocationTargetException javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:85) org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1205) org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1195) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:469) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) Root Cause
java.lang.reflect.InvocationTargetException sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) java.lang.reflect.Constructor.newInstance(Unknown Source) javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:76) javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:66) java.security.AccessController.doPrivileged(Native Method) javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:65) org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1205) org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1195) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:469) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) Root Cause
java.lang.SecurityException: org.xml.sax.SAXNotRecognizedException: SAX feature 'http://apache.org/xml/features/allow-java-encodings' not recognized. org.apache.catalina.authenticator.jaspic.PersistentProviderRegistrations.loadProviders(PersistentProviderRegistrations.java:66) org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.loadPersistentRegistrations(AuthConfigFactoryImpl.java:329) org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.(AuthConfigFactoryImpl.java:69) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) java.lang.reflect.Constructor.newInstance(Unknown Source) javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:76) javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:66) java.security.AccessController.doPrivileged(Native Method) javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:65) org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1205) org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1195) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:469) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) Root Cause
org.xml.sax.SAXNotRecognizedException: SAX feature 'http://apache.org/xml/features/allow-java-encodings' not recognized. oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:230) org.apache.tomcat.util.digester.Digester.setFeature(Digester.java:478) org.apache.catalina.authenticator.jaspic.PersistentProviderRegistrations.loadProviders(PersistentProviderRegistrations.java:62) org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.loadPersistentRegistrations(AuthConfigFactoryImpl.java:329) org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.(AuthConfigFactoryImpl.java:69) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) java.lang.reflect.Constructor.newInstance(Unknown Source) javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:76) javax.security.auth.message.config.AuthConfigFactory.run(AuthConfigFactory.java:66) java.security.AccessController.doPrivileged(Native Method) javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:65) org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1205) org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1195) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:469) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) Note The full stack trace of the root cause is available in the server logs.
有什么解决办法吗?
在$TOMCAT_HOME/conf/catalina.properties
在死角设置以下 4 个罐子:
javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
javax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
javax.xml.datatype.DatatypeFactory=com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl
这将设置您的 catalina 环境以包含所需的 .jars。
以下内容可能对某些人有用。
在 Azure PaaS WebApps 环境中 运行 Tomcat 时,我遇到了与@Om Sao 完全相同的问题。对我来说,问题是 site/wwwroot/webapps
下没有 ROOT 目录。添加 ROOT 目录后(我不确定在 ROOT 目录中实际需要什么 - 如果有的话 - 才能使其正常工作)然后问题就消失了。
我遇到这个问题的另一次是我在 Azure 中单击“部署到根目录”时不小心将我的应用程序上传到 ROOT 目录(在 Eclipse 中作为 Azure Web 应用程序执行 Azure/Publish)