3
我在將應用程序部署到我的Tomcat服務器時出現問題。我得到以下跟蹤我每次部署:WAR上的記錄錯誤使用Tomcat7,Apache Wink和Mongo DB部署
27-Oct-2013 17:02:34 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/JsonTest.war
Handler error
java.io.IOException: Couldn't get lock for %h/java%u.log
at java.util.logging.FileHandler.openFiles(FileHandler.java:389)
at java.util.logging.FileHandler.<init>(FileHandler.java:225)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at java.lang.Class.newInstance0(Class.java:374)
at java.lang.Class.newInstance(Class.java:327)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:521)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:464)
at org.apache.juli.ClassLoaderLogManager$2.run(ClassLoaderLogManager.java:377)
at org.apache.juli.ClassLoaderLogManager$2.run(ClassLoaderLogManager.java:373)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.juli.ClassLoaderLogManager.getClassLoaderInfo(ClassLoaderLogManager.java:373)
at org.apache.juli.ClassLoaderLogManager.getLogger(ClassLoaderLogManager.java:223)
at java.util.logging.LogManager.demandLogger(LogManager.java:381)
at java.util.logging.Logger.demandLogger(Logger.java:310)
at java.util.logging.Logger.getLogger(Logger.java:341)
at org.apache.juli.logging.DirectJDKLog.<init>(DirectJDKLog.java:71)
at org.apache.juli.logging.DirectJDKLog.getInstance(DirectJDKLog.java:196)
at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:170)
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:311)
at org.apache.catalina.core.ContainerBase.getLogger(ContainerBase.java:446)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5150)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:536)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1467)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
服務器方面:
- 的Ubuntu 12.04.3 LTS 32位(我會補償64後..)
- 的Tomcat 7(只股票修飾的事情是安裝用於添加Manager用戶[-gui])
的Java
$ java -version java version "1.6.0_27" OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.2) OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)
應用程序上下文:
我想簡單的「書REST應用」概括here使用Mongo的連接轉換。我有一種感覺,Mongo部分在這裏是無關緊要的。我也使用Maven和Eclipse來部署/構建項目。
某些文件:
的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">
<!-- Project detailes -->
<modelVersion>4.0.0</modelVersion>
<groupId>net.navatwo</groupId>
<artifactId>jsontest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Test JSON Marshalling</name>
<build>
<finalName>JsonTest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/src/main/webapp/WEB-INF</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>tomcat-server</server>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
</plugins>
</build>
<!-- Dependency on Wink SDK library -->
<dependencies>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-component-test-support</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-server</artifactId>
<version>1.4</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-server</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.0</version>
</dependency>
<dependency>
<groupId>woodstox</groupId>
<artifactId>wstx-asl</artifactId>
<version>3.2.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0-beta</version>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-jackson-provider</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.mongojack</groupId>
<artifactId>mongojack</artifactId>
<version>2.0.0-RC5</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
</dependencies>
<packaging>war</packaging>
</project>
BookWebApp.java
/**
*
*/
package org.navatwo.jsontest;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.core.Application;
import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.codehaus.jackson.map.AnnotationIntrospector;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.mongodb.DB;
import com.mongodb.MongoClient;
public class BookWebApp extends Application {
private Logger log;
private static class AppModule extends AbstractModule {
/* (non-Javadoc)
* @see com.google.inject.AbstractModule#configure()
*/
@Override
protected void configure() {
bind(BookService.class).to(BookServiceImpl.class);
// MONGO
try {
MongoClient mongoClient = new MongoClient("localhost");
bind(MongoClient.class).toInstance(mongoClient);
bind(DB.class).toInstance(mongoClient.getDB("db"));
} catch (UnknownHostException e) {
throw new RuntimeException("AppModule#configure threw UnknownHostException", e);
}
// LOGGING
bind(Logger.class).toInstance(LoggerFactory.getLogger(BookWebApp.class));
}
}
private Injector injector = Guice.createInjector(new AppModule());
private Set<Object> svc_singletons = new HashSet<Object>();
private Set<Class<?>> svc_classes = new HashSet<Class<?>>();
public BookWebApp() {
svc_singletons.add(injector.getInstance(BookService.class));
// svc_singletons.add(injector.getInstance(JacksonJsonProvider.class));
svc_singletons.add(injector.getInstance(Logger.class));
log.info("Started?");
log = injector.getInstance(Logger.class);
}
@Override
public Set<Object> getSingletons() {
return svc_singletons;
}
@Override
public Set<Class<?>> getClasses() {
return svc_classes;
}
}
我不想污染與代碼的帖子,所以,如果你認爲別人會有用,請讓我知道。
我感謝所有幫助。
我會稍後再檢查一下,我很抱歉,我現在無法訪問機器。 – Nava2