最近在ubuntu上部署了一个网站,用的是tomcat但是老部署不成功,提示如下错误:
Jun 10, 2009 5:42:47 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.security.AccessControlException: access denied (java.util.PropertyPermission webapp.root read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:342)
at java.security.AccessController.checkPermission(AccessController.java:553)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302)
at java.lang.System.getProperty(System.java:669)
at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:130)
at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:117)
at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:51)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:123)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:145)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:769)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
Jun 10, 2009 5:42:48 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.ExceptionInInitializerError
at org.springframework.web.context.ContextLoader.<init>(ContextLoader.java:139)
at org.springframework.web.context.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:57)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
"localhost.2009-06-10.log" 133L, 10359C
后来在前辈指导下解决了这个问题,有2种可能:
1、ubuntu自带的JDK问题,请重新安装SUN的JDK #sudo apt-get install sun-java6-jre sun-java6-jdk sun-java6-demo sun-java6-doc sun-java6-source sun-java6-plugin sun-java6-fonts libmyodbc tdsodbc
相关设置如下
sudo gedit /etc/profile //这个配制文件就是一个纯文本的东西,用什么工具自己选择vi、vim、gvim、emacs什么的都可以,只要是你机器里有的文本编辑工具就可以
JAVA_HOME=/usr/lib/jvm/java-6-sun
CLASSPATH=.:/usr/lib/jvm/java-6-sun/lib
JRE_HOME=/usr/lib/jvm/java-6-sun/jre
export JRE_HOME
export CLASSPATH
export JAVA_HOME
sudo gedit /etc/environment
JAVA_HOME=/usr/lib/jvm/java-6-sun
CLASSPATH=.:/usr/lib/jvm/java-6-sun/lib
提示:如果要让它立刻生效可以在终端里输入: . /etc/environment
一般情况可以不做设置,因为在这些安装完成后,机器必须得重启下,所没必要设置,但如果只是设置一下
环境变量就要用它的话,就可以采用这种方法。
sudo gedit /etc/jvm
在文件顶部添加
/usr/lib/jvm/java-6-sun
提示:这一步是在设置JDK的优先级
sudo gedit ~/.bashrc
在文件的末尾,添加如下两行
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin
提示:这是在设置用户变量
如果您的机器里装着多个JDK用下面的方法来选择JDK版本(8.04默认是没有安装JDK的,上面的安装只安装了一个版本的JDK,可以不设置)
sudo update-alternatives --config java
更新当前系统的JDK版本
sudo update-java-alternatives -s java-6-sun
然后编辑 #sudo vim /etc/init.d/tomcat6
中找到JDK_DIRS的配置,将其替换为:JDK_DIRS="/usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.5-sun /usr/lib/j2sdk1.5-ibm"
然后重新启动tomcat OK解决了!
2、TOMCAT的安全模式打开了
直接编辑#sudo vim /etc/init.d/tomcat6
找到TOMCAT6_SECURITY=Yes 改为no就OK了,重新启动就能运行了