使用maven tomcat7插件时出错 - context.xml异常

时间:2016-05-20 19:30:44

标签: java maven tomcat

使用以下设置

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <port>9090</port>
          <path>/</path>
          <contextFile>src/main/resources/config/tomcat/context.xml</contextFile>
          <executions>
                <execution>
                <id>start-tomcat</id>
                <phase>pre-integration-test</phase>
                <goals>                   
                    <goal>run</goal>
                </goals>
            </execution>
            <execution>
                <id>stop-tomcat</id>
                <phase>post-integration-test</phase>
                <goals>
                    <goal>shutdown</goal>
                </goals>
            </execution>
        </executions>
 </plugin>

我跑的时候

mvn integration-test

我收到以下错误

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

我在context.xml中有这个资源(src / main / resources / config / tomcat / context.xml)

<?xml version="1.0" encoding="UTF-8"?>
<Context>  
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <Resource name="url/btoconfig" 
        auth="Container" 
        type="java.net.URL"
        maxActive="10" 
        initialSize="1" 
        factory="com.benny.naming.factory.URLFactory"
        url="file:///tools/BTO/config/DEV/bto.properties" />

</Context>

我一定会错过一些愚蠢的东西,任何提示都会非常感激。

REF:申请POM

<?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.benny.oms.bto</groupId>
        <artifactId>bto</artifactId>
        <version>1.03.00.00</version>
    </parent>
    <artifactId>application</artifactId>
    <name>application</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
        </dependency>
        <!-- OMS artifacts -->


        <dependency>
            <groupId>com.benny.oms</groupId>
            <artifactId>oms-application</artifactId>
            <type>war</type>                    
        </dependency>

        <dependency>
            <groupId>com.benny.oms</groupId>
            <artifactId>oms-application</artifactId>
            <type>jar</type>
            <classifier>classes</classifier>
        </dependency>

        <!-- End OMS artifacts -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.ibm</groupId>
            <artifactId>mqjms</artifactId>
            <version>${mq.version}</version>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <scope>test</scope>         
        </dependency>

        <dependency>
          <groupId>org.mockito</groupId>
          <artifactId>mockito-all</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>p6spy</groupId>
            <artifactId>p6spy</artifactId>
        </dependency>

        <dependency>
            <artifactId>spring-test</artifactId>
            <groupId>org.springframework</groupId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>jdbc</groupId>
            <artifactId>jdbc-jconn3</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
        </dependency>

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
        </dependency>

<!--
        <dependency> 
          <groupId>org.apache.geronimo.specs</groupId> 
          <artifactId>geronimo-jms_1.1_spec</artifactId>
        </dependency>
-->

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </dependency>

        <!-- Seeing if this is the problem
                As suggested by http://stackoverflow.com/questions/8218629/active-mq-helloworld-example-exception   
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
        </dependency>
         -->

        <dependency>
            <groupId>javax.resource</groupId>
            <artifactId>connector-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom</artifactId>
        </dependency>

        <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
        </dependency>

        <dependency>
            <groupId>xalan</groupId>
            <artifactId>serializer</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-api</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.geronimo.specs</groupId>
                    <artifactId>geronimo-activation_1.1_spec</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.geronimo.specs</groupId>
                    <artifactId>geronimo-javamail_1.4_spec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-impl</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.geronimo.specs</groupId>
                    <artifactId>geronimo-activation_1.1_spec</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.geronimo.specs</groupId>
                    <artifactId>geronimo-javamail_1.4_spec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>maven-cobertura-plugin</artifactId>
                    <groupId>maven-plugins</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>maven-findbugs-plugin</artifactId>
                    <groupId>maven-plugins</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>com.ibm.icu</artifactId>
                    <groupId>icu4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.ws.xmlschema</groupId>
            <artifactId>xmlschema-core</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.stream</groupId>
            <artifactId>sjsxp</artifactId>
        </dependency>

        <!-- Spring Security -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-xml</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>

        <dependency>
            <groupId>ch.ralscha</groupId>
            <artifactId>extdirectspring</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-security</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
        </dependency>


        <dependency>
            <groupId>benny.extjs</groupId>
            <artifactId>extjs-benny-jar</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.xml.stream</groupId>
                    <artifactId>stax-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>stax</groupId>
                    <artifactId>stax-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>sweetdev</groupId>
            <artifactId>sweetdev-spring-core</artifactId>
        </dependency>

        <dependency>
            <groupId>net.sf.dozer</groupId>
            <artifactId>dozer</artifactId>
        </dependency>

        <dependency>
            <groupId>xmlunit</groupId>
            <artifactId>xmlunit</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.stream.buffer</groupId>
            <artifactId>streambuffer</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>activation</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>annogen</groupId>
            <artifactId>annogen</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
        </dependency>


        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>

        <dependency>
            <groupId>org.milyn</groupId>
            <artifactId>milyn-smooks-all</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency> 
          <groupId>org.apache.geronimo.specs</groupId> 
          <artifactId>geronimo-jms_1.1_spec</artifactId> 
        </dependency>

        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
        </dependency>

        <dependency>
            <groupId>com.benny.oms.bto</groupId>
            <artifactId>dao</artifactId>
        </dependency>

        <!--to share test code-->
        <dependency>
            <groupId>com.benny.oms.bto</groupId>
            <artifactId>model</artifactId>
            <version>${project.version}</version><!--$NO-MVN-MAN-VER$-->
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.benny.oms.bto</groupId>
            <artifactId>interfaces</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>

        <dependency>
            <groupId>SSO</groupId>
            <artifactId>benny-SSO-Client</artifactId>
        </dependency>

    </dependencies>


    <build>
        <finalName>bto</finalName>

        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                      <port>9090</port>
                      <path>/</path>
                      <contextFile>src/main/resources/config/tomcat/context.xml</contextFile>
                      <executions>
                            <execution>
                            <id>start-tomcat</id>
                            <!-- <phase>pre-integration-test</phase>  -->
                            <phase>generate-resources</phase>
                            <goals>                   
                                <goal>run</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-tomcat</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>shutdown</goal>
                            </goals>
                        </execution>
                      </executions>
                    </configuration>
             </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>xls</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>src/main/webapp/WEB-INF</directory>
                            <includes>
                                <include>classes/**/*</include>
                                <include>lib/**/*</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
                    <wtpmanifest>true</wtpmanifest>
                    <wtpapplicationxml>true</wtpapplicationxml>
                    <wtpversion>2.0</wtpversion>
                    <manifest>${basedir}/src/main/resources/META-INF/MANIFEST.MF</manifest>
                </configuration>
            </plugin>

            <!-- plugin allows to set variable containing all lib Container will ignore 
                scanning lib inside -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.9-benny</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-classpath</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <!-- <goals> <goal>build-classpath</goal> </goals> -->
                        <configuration>
                            <useAbsolutePaths>false</useAbsolutePaths>
                            <outputProperty>was.ignorescan.archives</outputProperty>
                            <includeScope>runtime</includeScope>
                            <pathSeparator>, </pathSeparator>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <attachClasses>true</attachClasses>              
                    <dependentWarIncludes>**/common/**, **/resources/**</dependentWarIncludes>              
                    <packagingExcludes>WEB-INF/lib/validation-api-1.0.0.GA.jar,WEB-INF/lib/geronimo-stax-api_1.0_spec-1.0.1.jar,WEB-INF/lib/geronimo-jms_1.1_spec-1.1.1.jar,WEB-INF/lib/mqjms-6.0.jar,WEB-INF/lib/xmlParserAPIs-2.6.2.jar</packagingExcludes>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Version>${project.version}</Implementation-Version>
                            <Ignore-Scanning-Archives>${was.ignorescan.archives}</Ignore-Scanning-Archives>
                        </manifestEntries>
                    </archive>
                    <webResources>
                        <webResource>
                            <directory>/src/main/webapp/WEB-INF</directory>
                            <includes>
                                <include>web.xml</include>
                            </includes>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </webResource>
                    </webResources>

                    <overlays>
                        <overlay>
                          <groupId>com.benny.oms</groupId>
                          <artifactId>oms-application</artifactId>                       
                          <excludes>
                            <exclude>**/.xml</exclude>
                            <exclude>WEB-INF/lib/validation-api-1.0.0.GA.jar</exclude>
                            <exclude>WEB-INF/lib/geronimo-stax-api_1.0_spec-1.0.1.jar</exclude>
                            <exclude>WEB-INF/lib/geronimo-jms_1.1_spec-1.1.1.jar</exclude>
                            <exclude>WEB-INF/lib/mqjms-6.0.jar</exclude>
                          </excludes>
                        </overlay>
                    </overlays>

                </configuration>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <excludes>
                        <exclude>**/*ScreenTest.java</exclude>
                    </excludes>

                    <classpathDependencyExcludes>
                        <!-- exclude code absent api -->
                        <classpathDependencyExclude>javax.faces:javax.faces-api</classpathDependencyExclude>
                    </classpathDependencyExcludes>
                </configuration>
            </plugin>

        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
        </resources>
    </build>    
</project>

0 个答案:

没有答案