问题描述
我在将应用程序部署到tomcat服务器上时遇到问题.每次部署它时,都会得到以下跟踪:
I am having problems deploying my application onto my tomcat server. I get the following trace every time I deploy it:
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(仅从库存安装中进行修改的内容是为经理[-gui]添加用户)
-
Java
- Ubuntu 12.04.3 LTS 32-bit (I'll make it 64 later..)
- Tomcat 7 (only thing modified from stock install is adding users for 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应用程序"转换使用Mongo连接.我觉得Mongo的部分在这里无关紧要.我还使用Maven和Eclipse来部署/构建项目.
I'm trying to convert the simple "books REST application" outlined here to use a Mongo connection. I have a feeling the Mongo part is irrelevant here. I'm also using Maven and Eclipse to deploy/build the project.
某些文件:
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
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;
}
}
我不想用代码来污染帖子,所以如果您认为其他人会有用的话,请告诉我.
I don't want to pollute the post with code, so if you think others would be useful, please let me know.
感谢您的帮助.
推荐答案
看起来Tomcat没有文件系统权限来写入日志文件. %h
变量是user.home
系统属性的值,通常是运行Tomcat进程的系统用户的主目录.确保Tomcat具有对该目录的写权限.
It looks like Tomcat does not have filesystem permissions to write to the log file. The %h
variable is the value of the user.home
system property, which is usually the home directory of the system user running the Tomcat process. Make sure that Tomcat has write permissions to that directory.
该Directoy的位置可能会有所不同,但是您可以通过以下方式以编程方式找到它:
The location of that directoy can vary, but you can find it programmatically with:
System.getProperty("user.home")
您还可以通过将参数-Duser.home=/your/path
提供给Tomcat启动脚本来修改默认值.
You can also modify the default value by providing the argument -Duser.home=/your/path
to the Tomcat startup script.
这篇关于使用Tomcat7,Apache Wink和Mongo DB进行WAR Deploy时记录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!