1

ほとんどのビジネス ロジックを含む JAR ファイルがあります。Spring MVC で開発された私の Web アプリケーションは、その JAR ファイルを使用します。JAR ファイルを保護するために、JarCryp を使用しました。JarCryp は、JAR ファイルから .sjar ファイルを作成しました。ここで、Tomcat から JAR ファイルをロードするために、Tomcat の context.ieAdded 次の行を context.xml に追加しました。

 <Loader className="ComponioSampleClassLoader" ></Loader>

ComponioSampleClassLoaderクラスがorg.apache.catalina.loader.WebappClassLoaderを拡張した場所

今、Tomcatを起動すると、次のエラーが発生します

INFO: Deploying configuration descriptor host-manager.xml
Mar 1, 2013 11:50:41 PM org.apache.tomcat.util.digester.Digester endElement
SEVERE: End event threw exception

    java.lang.IllegalArgumentException: argument type mismatch
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:928)
        at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:193)
        at org.apache.tomcat.util.digester.Rule.end(Rule.java:229)
        at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1138)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1642)
        at org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:793)
        at org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:732)
        at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1018)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
        at org.apache.catalina.core.StandardContext.init(StandardContext.java:5700)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4448)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
        at org.apache.catalina.core.StandardService.start(StandardService.java:525)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Mar 1, 2013 11:50:41 PM org.apache.catalina.startup.ContextConfig processContextConfig
    SEVERE: Parse error in context.xml for /host-manager
    java.lang.IllegalArgumentException: argument type mismatch
        at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2806)
        at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2832)
        at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1141)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1642)
        at org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:793)
        at org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:732)
        at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1018)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
        at org.apache.catalina.core.StandardContext.init(StandardContext.java:5700)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4448)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
        at org.apache.catalina.core.StandardService.start(StandardService.java:525)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Caused by: java.lang.IllegalArgumentException: argument type mismatch
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:928)
        at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:193)
        at org.apache.tomcat.util.digester.Rule.end(Rule.java:229)
        at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1138)
        ... 40 more

助けてもらえますか?

4

1 に答える 1

1

数時間同じ問題に苦労しました...

WebappClassLoader ではなく、WebappLoader (org.apache.catalina.loader.WebappLoader) から拡張する必要があります。

両方のコンストラクターが同じであることに気付くでしょう。そのため、この変更を行うときにコンストラクターを変更する必要はほとんどありません。

package tomcat7;

import org.apache.catalina.loader.WebappLoader;

public class Tomcat7CustomWebappLoader extends WebappLoader {

    public Tomcat7CustomWebappLoader() {
        super();
    }

    public Tomcat7CustomWebappLoader(ClassLoader parent) {
        super(parent);
    }
}

WebappLoader からの拡張は、Tomcat にパッケージ化された "VirtualWebappLoader" (org.apache.catalina.loader.VirtualWebappLoader) Loader 実装を見ても明らかです。

残念ながら、特定のユースケースの経験はありませんが、ローダーは WebappLoader を拡張する必要があります。

ここのページの下部近くにあるより高度な実装

于 2013-03-20T02:53:13.127 に答える