我有一个 Java EE 项目,它在我们的一台带有 tomcat 容器的远程服务器上运行良好。每当我们想对我们的应用程序进行一些更改时,我们都会在本地机器上进行,然后构建它并将其复制到ws.war
服务器上的 tomcat 根目录中。
我想设置可以对应用程序进行更改的本地开发环境。我有项目源文件。我做了以下事情:
1. Install tomcat7 in my home directory and set up `CATALINA_HOME`
environment variable in `.bashrc`
2. Install oracle-java and setup JAVA_HOME in `.bashrc`
3. Install Netbeans 7 and import the project in it.
4. Since, the Netbeans came with `glassfish` as default server, I added
a tomcat as the server with proper configuration.
5. I try running the application (through Netbeans), and I receive the following error:
Jun 04, 2013 2:39:58 AM org.apache.catalina.core.AprLifecycleListener init
2 INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/ lib:/usr/lib
3 Jun 04, 2013 2:39:59 AM org.apache.coyote.AbstractProtocol init
4 INFO: Initializing ProtocolHandler ["http-bio-8080"]
5 Jun 04, 2013 2:39:59 AM org.apache.coyote.AbstractProtocol init
6 INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
7 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.Catalina load
8 INFO: Initialization processed in 1100 ms
9 Jun 04, 2013 2:39:59 AM org.apache.catalina.core.StandardService startInternal
10 INFO: Starting service Catalina
11 Jun 04, 2013 2:39:59 AM org.apache.catalina.core.StandardEngine startInternal
12 INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
13 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.HostConfig deployDescriptor
14 INFO: Deploying configuration descriptor /home/frrole/apache-tomcat-7.0.40/conf/Catalina/localhost/ws.xml
15 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.HostConfig deployDescriptor
16 WARNING: A docBase /home/frrole/apache-tomcat-7.0.40/webapps/projectfrrole/target/ws inside the host appBase has been specified, and will be ignored
17 Jun 04, 2013 2:40:00 AM org.apache.catalina.core.ContainerBase addChildInternal
18 SEVERE: ContainerBase.addChild: start:
19 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ws]]
20 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
21 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
22 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
23 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
24 at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
25 at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636)
26 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
27 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
28 at java.util.concurrent.FutureTask.run(FutureTask.java:166)
29 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
30 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
31 at java.lang.Thread.run(Thread.java:722)
32 Caused by: java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;
33 at java.lang.Class.getDeclaredFields0(Native Method)
34 at java.lang.Class.privateGetDeclaredFields(Class.java:2317)
35 at java.lang.Class.getDeclaredFields(Class.java:1762)
36 at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
37 at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
38 at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
39 at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)
40 at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
41 at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
42 at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
43 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
44 at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
45 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
46 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
47 ... 11 more
48 Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
49 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
我做了一些研究,发现与 1.6.1 版本和以前版本的slf4j
. 但是,我无法找到解决此问题的方法。
任何帮助表示赞赏。我的 POM.xml 如下:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.frrole.service</groupId>
<artifactId>ws</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>frrole web service</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springframework-version>3.0.5.RELEASE</springframework-version>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>
WEB-INF/lib/*spring*.jar,
WEB-INF/lib/*common*.jar,
WEB-INF/lib/*http*.jar,
WEB-INF/lib/*connector*.jar,
WEB-INF/lib/*json*.jar,
WEB-INF/lib/*jackson*.jar,
WEB-INF/lib/*aspect*.jar,
WEB-INF/lib/*aop*.jar,
WEB-INF/lib/*c3p*.jar,
WEB-INF/lib/*jta*.jar,
WEB-INF/lib/*4j*.jar
</packagingExcludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
<!--
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springframework-version}</version>
<scope>test</scope>
</dependency>
-->
<!--<dependency>
<groupId>mm.mysql</groupId>
<artifactId>mm.mysql</artifactId>
<version>2.0.7</version>
</dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${springframework-version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>3.0.3</version>
</dependency>
</dependencies>
</project>