Tomcat异常:java.lang.reflect.InvocationTargetException,java.lang.SecurityException,org.xml.sax.SAXNotRecognizedException

时间:2019-10-21 10:49:51

标签: tomcat tomcat8 saxparser

在tomcat 8.5.16版本中部署.war文件时,出现以下错误:

  

例外

     

java.lang.SecurityException:AuthConfigFactory错误:    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(未知来源)     java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知源)     org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     java.lang.Thread.run(未知源)根本原因

     

java.lang.reflect.InvocationTargetException     sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)     sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源)     sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知   来源)java.lang.reflect.Constructor.newInstance(未知来源)     javax.security.auth.message.config.AuthConfigFactory $ 1.run(AuthConfigFactory.java:76)     javax.security.auth.message.config.AuthConfigFactory $ 1.run(AuthConfigFactory.java:66)     java.security.AccessController.doPrivileged(本机方法)     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(未知来源)     java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知源)     org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     java.lang.Thread.run(未知源)根本原因

     

java.lang.SecurityException :org.xml.sax.SAXNotRecognizedException:   SAX功能'http://apache.org/xml/features/allow-java-encodings'不是   公认的。     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(本机方法)     sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源)     sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知   来源)java.lang.reflect.Constructor.newInstance(未知来源)     javax.security.auth.message.config.AuthConfigFactory $ 1.run(AuthConfigFactory.java:76)     javax.security.auth.message.config.AuthConfigFactory $ 1.run(AuthConfigFactory.java:66)     java.security.AccessController.doPrivileged(本机方法)     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(未知来源)     java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知源)     org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     java.lang.Thread.run(未知源)根本原因

     

org.xml.sax.SAXNotRecognizedException :SAX功能   无法识别“ http://apache.org/xml/features/allow-java-encodings”。     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(本机方法)     sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源)     sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知   来源)java.lang.reflect.Constructor.newInstance(未知来源)     javax.security.auth.message.config.AuthConfigFactory $ 1.run(AuthConfigFactory.java:76)     javax.security.auth.message.config.AuthConfigFactory $ 1.run(AuthConfigFactory.java:66)     java.security.AccessController.doPrivileged(本机方法)     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(未知来源)     java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知源)     org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     java.lang.Thread.run(未知源)注意   根本原因可在服务器日志中找到。

任何帮助如何解决?

2 个答案:

答案 0 :(得分:1)

$TOMCAT_HOME/conf/catalina.properties

在死角处设置以下4个jar:

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。

答案 1 :(得分:0)

以下内容可能对某人有用。

在Azure PaaS WebApps环境中运行Tomcat时,我遇到了与@Om Sao完全相同的问题。对我来说,问题在于arguments下没有ROOT目录。当添加了ROOT目录时(我不确定什么(如果有的话)实际上需要放在ROOT目录中才能使其正常工作),问题就消失了。

另一个问题是我偶然通过在Azure中单击“部署到根”将应用程序上载到ROOT目录中(在Eclipse中执行Azure /作为Azure Web App发布时)

enter image description here