就在刚刚,纠结了n久的那个为什么在windows下测试正常但部署到linux下却总报错的问题终于被我解决拉!硬着头皮看了一堆的英文论坛,总算找到了解决方案。
问题描述:
我们新开发的Botwarden系统,采用SSH结构,在windows下测试通过,直接发布到的debian服务器上对应的webapps目录(注意发布web应用的目录为/var/lib/tomcat6/webapps,在/usr/share/tomcat6目录下的是tomcat的安装目录)下,却不能正常访问,查看tomcat启动日志(tomcat的启动日志记录在/var/lib/tomcat6/logs目录下,tomcat6是采用按天记录的),发现报错如下(关键点我用蓝色标出):
SEVERE: Error deploying web
application directory Skyeye
java.lang.NoClassDefFoundError:
org/springframework/core/NestedExceptionUtilsat
org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at
java.lang.Throwable.getLocalizedMessage(Throwable.java:267)
at java.lang.Throwable.toString(Throwable.java:343)
at
org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:150)
at java.lang.String.valueOf(String.java:2827)
at java.io.PrintWriter.println(PrintWriter.java:710)
at
java.lang.Throwable.printStackTrace(Throwable.java:509)
at
org.springframework.beans.factory.BeanCreationException.printStackTrace(BeanCreationException.java:176)
at
java.util.logging.SimpleFormatter.format(SimpleFormatter.java:72)
at
org.apache.juli.FileHandler.publish(FileHandler.java:129)
at java.util.logging.Logger.log(Logger.java:458)
at java.util.logging.Logger.doLog(Logger.java:480)
at java.util.logging.Logger.logp(Logger.java:680)
at
org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:167)
at
org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:135)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3847)
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:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
Caused by: java.lang.ClassNotFoundException:
org.springframework.core.NestedExceptionUtils
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 46 more
解决过程:
开始漫长的google之旅,开始以为是对应的spring包没有加进去,检查发现没有问题,师弟建议说换个版本的spring-core包,最后我思考了一下觉得应该不是这个问题,就没有尝试这个解决方法,事实证明我是对的,呵呵。接着google一般的NoClassDefFoundError错误原因,都说是环境变量的配置问题,但我确认jdk和tomcat对应的环境变量都没错,于是此原因排除之。然后继续google,有人建议说直接在windows下打包成war包再发布到linux下,于是尝试,依旧老问题。
(郁闷啊郁闷,中午亲爱的吃饭时叫我,我都没有心思去吃饭,亲爱的安慰了我半天,后来想想没有必要虐待自己,保持好心情,嘿嘿)
太晚了,亲爱的来接我回宿舍了,明天继续写完,现在心情好好,哈哈
to be continued……
接着写完:
改变关键字接着google,晃到了一个国外的论坛,硬着头皮看完了那些英文的讨论,貌似是tomcat
security的问题,应该是要将debian下tomcat
security禁止掉,否则访问不了那些spring的包吧,看那个人好像修改的init.d的脚本,想了想/etc/init.d下应该有对应的tomcat的配置文件,于是vi
/etc/init.d/tomcat6,将默认的TOMCAT6_SECURITY=yes改为TOMCAT6_SECURITY=no。重启tomcat(/etc/init.d/tomcat6
restart),在浏览器下激动地输入网址,发现终于看到web界面了,那个激动啊~~刚好亲爱的排练完节目打电话给我,兴奋地跟他说了一下,开心啊开心……
其实呢,还是有问题的,貌似是访问数据库的问题,继续解决吧