0

我正在尝试使用 Tomcat7 和几个相关的 webapp 和 Java 项目构建开发环境。

按照建议(http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Virtual_webapp),我配置了以下上下文:

<Context path="/vcaui" docBase="/Users/alexey/EclipseWorkspaces/dooks/application/VCAUI/war" reloadable="true">                    
<Loader loaderClass="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="/Users/alexey/EclipseWorkspaces/dooks/application/VCA/bin" />
<JarScanner scanAllDirectories="true" />
</Context>

我收到以下错误,尝试启动 Tomcat:

Aug 04, 2013 1:41:56 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Context/Loader} Setting property 'virtualClasspath' to '/Users/alexey/EclipseWorkspaces/dooks/application/VCA/bin' did not find a matching property.
Aug 04, 2013 1:41:56 PM org.apache.catalina.loader.WebappLoader startInternal
SEVERE: LifecycleException 
java.lang.ClassCastException: org.apache.catalina.loader.VirtualWebappLoader cannot be cast to  org.apache.catalina.loader.WebappClassLoader
at org.apache.catalina.loader.WebappLoader.createClassLoader(WebappLoader.java:731)
at org.apache.catalina.loader.WebappLoader.startInternal(WebappLoader.java:583)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5299)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

有人有线索吗?

4

2 回答 2

2

Loader标签可以替换为Resources 和 PreResources。这些标签的详细信息在这里

例如:

<Resources className="org.apache.catalina.webresources.StandardRoot">
    <PreResources className="org.apache.catalina.webresources.DirResourceSet"
        base="${catalina.base}/{YOUR_DIRECTORY}"
        internalPath="/"
        webAppMount="/WEB-INF/classes"/>
</Resources>
于 2018-10-24T10:03:41.093 回答
1

尝试将属性替换loaderClassclassName. 我过去曾使用过它,并从tomcat文档中的this bit中获取了示例

(复制示例,以防将来页面消失)

<Context path="/mywebapp" docBase="/Users/theuser/mywebapp/src/main/webapp" >
  <Resources className="org.apache.naming.resources.VirtualDirContext" 
             extraResourcePaths="/WEB-INF/classes=/Users/theuser/mywebapp/target/classes" />
  <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
          virtualClasspath="/Users/theuser/mywebapp/target/classes; /Users/theuser/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar" />
  <JarScanner scanAllDirectories="true" />
</Context>
于 2013-08-04T11:18:33.830 回答