2016-07-25 44 views
0

如果我直接在獨立的Tomcat 8上部署我的應用程序,服務器啓動時沒有任何錯誤。 Ony當我嘗試在IntelliJ中啓動Tomcat時,出現NoClassDefFoundError:org/slf4j/Logger,應用程序無法啓動。當我直接在外部Tomcat中部署WAR時,一切正常。 附加的是兩個POM文件: 我已經看過在SO上提供的解決方案,但這種情況對於IntelliJ是唯一的。 NoClassDefFoundError: org/slf4j/Logger在IntelliJ Java應用程序中運行Tomcat SLF4j記錄器錯誤

父POM

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>org.akaza.openclinica</groupId> 
<artifactId>OpenClinica</artifactId> 
<packaging>pom</packaging> 
<version>MAINLINE-SNAPSHOT</version> 
<name>OpenClinica</name> 
<description>OpenClinica</description> 

<modules> 
    <module>core</module> 
    <module>web</module> 
    <module>ws</module> 
</modules> 

... org.slf4j SLF4J-JDK14 1.6.4 org.slf4j SLF4J的API 1.7.6 org.slf4j slf4j -log4j12 1.7.6 org.slf4j 七月到SLF4J 1.7.6 org.slf4j JCL-過SLF4J 1.7.6 ch.qos.logback 的logback核 1.1.2 ch.qos.logback 的logback經典 1.1.2 ch.qos.logback 的logback訪問 1.1.2 ...

</dependencyManagement> 


<!-- These dependencies are used by _all_ child projects --> 
<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.5.1</version> 
       <configuration> 
        <source>8</source> 
        <target>8</target> 
        <compilerArgument>-Xlint:all</compilerArgument> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-resources-plugin</artifactId> 
       <version>3.0.1</version> 
       <configuration> 
        <delimiters> 
         <delimiter>${*}</delimiter> 
        </delimiters> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.19.1</version> 
       <configuration> 
        <skipTests>${skipTests}</skipTests> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-release-plugin</artifactId> 
       <version>2.5.3</version> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <version>2.6</version> 
       <configuration> 
        <outputDirectory>${openclinica.distros.dir}</outputDirectory> 
        <descriptors> 
         <descriptor>${project.basedir}/src/assemble/openclinica-assemble.xml</descriptor> 
        </descriptors> 
        <appendAssemblyId>false</appendAssemblyId> 
        <finalName>${assembly.name}-${project.version}</finalName> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-eclipse-plugin</artifactId> 
       <version>2.10</version> 
       <configuration> 
        <addVersionToProjectName>true</addVersionToProjectName> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.cargo</groupId> 
       <artifactId>cargo-maven2-plugin</artifactId> 
       <version>1.5.0</version> 
       <configuration> 
        <!-- Container configuration --> 
        <container> 
         <containerId>tomcat6x</containerId> 
         <home>${catalina.home}</home> 
        </container> 
        <configuration> 
         <home>${catalina.home}</home> 
         <type>existing</type> 
        </configuration> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.liquibase</groupId> 
       <artifactId>liquibase-plugin</artifactId> 
       <version>1.9.1.0</version> 
       <configuration> 
        <propertyFile>${config.file}</propertyFile> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.zeroturnaround</groupId> 
       <artifactId>jrebel-maven-plugin</artifactId> 
       <version>1.1.6</version> 
       <executions> 
        <execution> 
         <id>generate-rebel-xml</id> 
         <phase>process-resources</phase> 
         <goals> 
          <goal>generate</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>buildnumber-maven-plugin</artifactId> 
       <version>1.4</version> 
       <executions> 
        <execution> 
         <id>buildnumber</id> 
         <phase>validate</phase> 
         <goals> 
          <goal>create</goal> 
         </goals> 
         <configuration> 
          <doCheck>false</doCheck> 
          <doUpdate>false</doUpdate> 
          <shortRevisionLength>12</shortRevisionLength> 
          <buildNumberPropertyName>changeSet</buildNumberPropertyName> 
         </configuration> 
        </execution> 
        <execution> 
         <id>timestamp</id> 
         <phase>validate</phase> 
         <goals> 
          <goal>create-timestamp</goal> 
         </goals> 
         <configuration> 
          <timestampPropertyName>changeSetDate</timestampPropertyName> 
          <timestampFormat>yyyy-MM-dd HH:mm Z</timestampFormat> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.jvnet.jaxb2.maven2</groupId> 
       <artifactId>maven-jaxb2-plugin</artifactId> 
       <version>0.13.1</version> 
       <executions> 
        <execution> 
         <phase>generate-sources</phase> 
         <goals> 
          <goal>generate</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <schemaDirectory>src/main/webapp/WEB-INF/schemas</schemaDirectory> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-clean-plugin</artifactId> 
       <version>3.0.0</version> 
      </plugin> 
     </plugins> 
    </pluginManagement> 


    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.8</version> 
      <executions> 
       <execution> 
        <phase>install</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <artifactItems> 
          <artifactItem> 
           <groupId>com.github.jsimone</groupId> 
           <artifactId>webapp-runner</artifactId> 
           <version>8.0.33.0</version> 
           <destFileName>webapp-runner.jar</destFileName> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 


    <resources> 
     <resource> 
      <directory>src/main/resources</directory> 
      <filtering>true</filtering> 
      <includes> 
       <include>**/*.properties</include> 
       <include>**/*.xml</include> 
      </includes> 
     </resource> 
     <resource> 
      <directory>src/main/resources</directory> 
      <filtering>false</filtering> 
      <excludes> 
       <exclude>**/*.properties</exclude> 
       <exclude>**/*.xml</exclude> 
      </excludes> 
     </resource> 
    </resources> 


    <testResources> 
     <testResource> 
      <directory>src/test/resources</directory> 
      <filtering>true</filtering> 
      <includes> 
       <include>**/*.properties</include> 
       <include>**/*.xml</include> 
      </includes> 
     </testResource> 
    </testResources> 

    <!-- 
    <filters> 
     <filter>src/main/filters/default.properties</filter> 
     <filter>src/main/filters/${config.id}.properties</filter> 
    </filters> 
    --> 

</build> 
<scm> 
    <connection>scm:git:${git.url}</connection> 
    <developerConnection>scm:git:${git.url}</developerConnection> 
    <tag>HEAD</tag> 
</scm> 

<repositories> 
    <repository> 
     <snapshots> 
      <enabled>false</enabled> 
     </snapshots> 
     <id>central</id> 
     <name>libs-release</name> 
     <url>http://dev.openclinica.com/artifactory/libs-release</url> 
    </repository> 
    <repository> 
     <snapshots/> 
     <id>snapshots</id> 
     <name>libs-snapshot</name> 
     <url>http://dev.openclinica.com/artifactory/libs-snapshot</url> 
    </repository> 
    <repository> 
     <id>jboss-public-repository-group</id> 
     <name>JBoss Public Repository Group</name> 
     <url>http://repository.jboss.org/nexus/content/groups/public/</url> 
     <layout>default</layout> 
     <releases> 
      <enabled>true</enabled> 
      <updatePolicy>never</updatePolicy> 
     </releases> 
     <snapshots> 
      <enabled>true</enabled> 
      <updatePolicy>never</updatePolicy> 
     </snapshots> 
    </repository> 
</repositories> 
<pluginRepositories> 
    <pluginRepository> 
     <snapshots> 
      <enabled>false</enabled> 
     </snapshots> 
     <id>central</id> 
     <name>plugins-release</name> 
     <url>http://dev.openclinica.com/artifactory/plugins-release</url> 
    </pluginRepository> 
    <pluginRepository> 
     <snapshots/> 
     <id>snapshots</id> 
     <name>plugins-snapshot</name> 
     <url>http://dev.openclinica.com/artifactory/plugins-snapshot</url> 
    </pluginRepository> 
    <pluginRepository> 
     <id>jboss-public-repository-group</id> 
     <name>JBoss Public Repository Group</name> 
     <url>http://repository.jboss.org/nexus/content/groups/public/</url> 
     <releases> 
      <enabled>true</enabled> 
     </releases> 
     <snapshots> 
      <enabled>true</enabled> 
     </snapshots> 
    </pluginRepository> 
</pluginRepositories> 

<distributionManagement> 
    <repository> 
     <id>openclinica-artifactory</id> 
     <name>dev.openclinica.com-releases</name> 
     <url>http://dev.openclinica.com/artifactory/libs-release-local</url> 
    </repository> 
    <snapshotRepository> 
     <id>openclinica-artifactory</id> 
     <name>dev.openclinica.com-snapshots</name> 
     <url>http://dev.openclinica.com/artifactory/libs-snapshot-local</url> 
    </snapshotRepository> 
</distributionManagement> 

兒童POM

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<artifactId>OpenClinica-web</artifactId> 
<packaging>war</packaging> 
<name>OpenClinica Web Application</name> 
<parent> 
    <groupId>org.akaza.openclinica</groupId> 
    <artifactId>OpenClinica</artifactId> 
    <version>MAINLINE-SNAPSHOT</version> 
</parent> 
<dependencies> 
    <dependency> 
     <groupId>${project.groupId}</groupId> 
     <artifactId>OpenClinica-core</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>net.sf.saxon</groupId> 
     <artifactId>saxon</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>net.sf.saxon</groupId> 
     <artifactId>saxon-dom</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>rome</groupId> 
     <artifactId>rome-fetcher</artifactId> 
     <scope>compile</scope> 
     <exclusions> 
      <!-- We are using jdom 1.1 lib below --> 
      <exclusion> 
       <groupId>jdom</groupId> 
       <artifactId>jdom</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>rome</groupId> 
     <artifactId>rome</artifactId> 
     <scope>compile</scope> 
     <exclusions> 
      <!-- We are using jdom 1.1 lib below --> 
      <exclusion> 
       <groupId>jdom</groupId> 
       <artifactId>jdom</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <dependency> 
     <groupId>com.mockrunner.jdk15.jee5</groupId> 
     <artifactId>mockrunner</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.mockrunner.jdk15.jee5</groupId> 
     <artifactId>mockrunner-servlet</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.transaction</groupId> 
     <artifactId>transaction-api</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-web</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>net.sourceforge.pjl-comp-filter</groupId> 
     <artifactId>pjl-comp-filter</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-taglibs</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-acl</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-core</artifactId> 

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

    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-config</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>cglib</groupId> 
     <artifactId>cglib-nodep</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>joda-time</groupId> 
     <artifactId>joda-time</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>opensymphony</groupId> 
     <artifactId>sitemesh</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>com.lowagie</groupId> 
     <artifactId>itext</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.jmesa</groupId> 
     <artifactId>jmesa</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>commons-beanutils</groupId> 
     <artifactId>commons-beanutils</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>commons-validator</groupId> 
     <artifactId>commons-validator</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <!-- Needed by commons-validator --> 
    <dependency> 
     <groupId>oro</groupId> 
     <artifactId>oro</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>commons-collections</groupId> 
     <artifactId>commons-collections</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>commons-math</groupId> 
     <artifactId>commons-math</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>commons-digester</groupId> 
     <artifactId>commons-digester</artifactId> 
     <scope>compile</scope> 
     <exclusions> 
      <exclusion> 
       <artifactId>commons-collections</artifactId> 
       <groupId>commons-collections</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>xml-apis</artifactId> 
       <groupId>xml-apis</groupId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>commons-fileupload</groupId> 
     <artifactId>commons-fileupload</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>httpunit</groupId> 
     <artifactId>httpunit</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.jdom</groupId> 
     <artifactId>jdom</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>jstl</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>javax.servlet-api</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet.jsp</groupId> 
     <artifactId>jsp-api</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>javax.mail</groupId> 
     <artifactId>mail</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>taglibs</groupId> 
     <artifactId>standard</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.poi</groupId> 
     <artifactId>poi</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>net.sourceforge.jexcelapi</groupId> 
     <artifactId>jxl</artifactId> 
     <scope>compile</scope> 
    </dependency> 
    <!-- Struts web framework --> 
    <dependency> 
     <groupId>struts</groupId> 
     <artifactId>struts</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.quartz-scheduler</groupId> 
     <artifactId>quartz</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.quartz-scheduler</groupId> 
     <artifactId>quartz-oracle</artifactId> 
    </dependency> 

    <!-- XML serializer--> 
    <dependency> 
     <groupId>net.sf.json-lib</groupId> 
     <artifactId>json-lib</artifactId> 
     <version>2.4</version> 
     <classifier>jdk15</classifier> 
    </dependency> 
    <dependency> 
     <groupId>xom</groupId> 
     <artifactId>xom</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>net.sf.ezmorph</groupId> 
     <artifactId>ezmorph</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-server</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-client</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey.contribs</groupId> 
     <artifactId>jersey-spring</artifactId> 
     <exclusions> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-core</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-web</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-beans</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-context</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-asm</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-aop</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.freemarker</groupId> 
     <artifactId>freemarker</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.mockito</groupId> 
     <artifactId>mockito-all</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
    <groupId>com.fasterxml.jackson.core</groupId> 
    <artifactId>jackson-databind</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/org.springframework.ws/spring-ws-core --> 
    <dependency> 
     <groupId>org.springframework.ws</groupId> 
     <artifactId>spring-ws-core</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>net.sf.ehcache</groupId> 
     <artifactId>ehcache-web</artifactId> 
    </dependency> 
    <!--<dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
    </dependency>--> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-jdk14</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>com.stormpath.spring</groupId> 
     <artifactId>stormpath-default-spring-boot-starter</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.ws.commons.schema</groupId> 
     <artifactId>XmlSchema</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.codehaus.castor</groupId> 
     <artifactId>castor-core</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>commons-beanutils</groupId> 
     <artifactId>commons-beanutils-core</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.xmlgraphics</groupId> 
     <artifactId>batik-svg-dom</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --> 
</dependencies> 

任何幫助是極大的讚賞。

回答

0

缺少的org.slf4j.Logger接口包含在slf4j-api罐子中。您已經指出(該版本的1.7.6版)該jar包含在您父pom的dependencyManagement部分中,但是您沒有顯示實際的依賴關係。有沒有機會有provided或其他一些非默認範圍?

無論如何,您的NoClassDefFound錯誤表明,當您嘗試通過IntelliJ運行應用程序時,該jar不在類路徑中。

0

範圍在Maven的DM中「提供」。 我想我的問題是我使用的maven配置文件。它正在刪除所有的jar文件,只保留war文件(爲了在Heroku上部署這個文件),所以Tomcat無法找到這個jar文件,因此也沒有找到這個jar文件。

相關問題