使用自己的server.xml通过maven插件运行tomcat

时间:2017-02-09 15:36:17

标签: java maven tomcat maven-tomcat-plugin

我已经在我的server.xml中定义了一个自定义资源,当我运行我的Spring应用程序时,它没有被选中。

的Server.xml:

<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
        type="org.apache.catalina.UserDatabase"
        description="User database that can be updated and saved"
        factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
        pathname="users.xml" />

    <Resource name="jms/MY_FACTORY" 
        auth="Container" 
        type="org.apache.activemq.ActiveMQConnectionFactory" 
        description="Queue Connection Factory"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
        brokerURL="tcp://localhost?wireFormat.maxInactivityDurationInitalDelay=40000" 
        brokerName="LocalActiveMQBroker" />
</GlobalNamingResources>
<Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
        connectionTimeout="20000"
        redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">
        <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
            resourceName="UserDatabase"/>
        </Realm>
        <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
            <Context docBase="../../my-app" path="/my-app" reloadable="true" />
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                prefix="localhost_access_log." suffix=".txt"
                pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        </Host>
    </Engine>
</Service>

的pom.xml:

<plugin>
<dependencies>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-all</artifactId>
        <version>5.9.1</version>
    </dependency>
</dependencies>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
    <port>8099</port>
    <path>/</path>
    <uriEncoding>UTF-8</uriEncoding>
    <serverXml>src/main/tomcatconf/server.xml</serverXml>
</configuration>
<executions>
    <execution>
        <id>tomcat7-run</id>
        <goals>
            <goal>run</goal>
        </goals>
        <phase>pre-integration-test</phase>
        <configuration>
            <fork>true</fork>
        </configuration>
    </execution>
    <execution>
        <id>tomcat7-shutdown</id>
        <goals>
            <goal>shutdown</goal>
        </goals>
        <phase>post-integration-test</phase>
    </execution>
</executions>

当我使用tomcat7:run加载我的应用程序时,我收到以下错误:

Caused by: javax.naming.NameNotFoundException: Name [jms/MY_FACTORY] is not bound in this Context. Unable to find [jms].

它正在拿起我的server.xml,但只是加载资源,任何想法?

0 个答案:

没有答案