1、今天同事遇到个问题,eclipse启动tomcat时,老是报错java.lang.ClassNotFoundException: com.common.entrance.JsdzListener,意思是无法启动监听功能,这个问题给我费了好长时间才解决,今天记录一下,省着以后忘记
2、首先报错内容如下
二月 23, 2018 1:39:02 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:wpms' did not find a matching property.
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.85
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Feb 7 2018 18:52:33 UTC
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 7.0.85.0
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 8
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.2
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jdk1.7.0_25\jre
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.7.0_25-b17
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: D:\Java\apache-tomcat-7.0.85
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: D:\Java\apache-tomcat-7.0.85
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=D:\Java\apache-tomcat-7.0.85
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=D:\Java\apache-tomcat-7.0.85
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=D:\Java\apache-tomcat-7.0.85\webapps
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=D:\Java\apache-tomcat-7.0.85\endorsed
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=GBK
二月 23, 2018 1:39:02 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_25\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.7.0_25/jre/bin/server;C:/Program Files/Java/jdk1.7.0_25/jre/bin;C:/Program Files/Java/jdk1.7.0_25/jre/lib/amd64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;d:\Program Files\Git\cmd;D:\Program Files\nodejs\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0_25\jre\bin;C:\Program Files\Java\jdk1.7.0_25\bin;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;C:\Users\admin\AppData\Roaming\npm;E:\eclipse;;.
二月 23, 2018 1:39:02 下午 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
二月 23, 2018 1:39:02 下午 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
二月 23, 2018 1:39:02 下午 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 671 ms
二月 23, 2018 1:39:02 下午 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
二月 23, 2018 1:39:02 下午 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.85
二月 23, 2018 1:39:05 下午 org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
二月 23, 2018 1:39:05 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class com.common.entrance.JsdzListener
java.lang.ClassNotFoundException: com.common.entrance.JsdzListener
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1907)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1750)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:534)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:516)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:148)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5034)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5641)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1700)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1690)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
二月 23, 2018 1:39:05 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
二月 23, 2018 1:39:05 下午 org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
二月 23, 2018 1:39:05 下午 org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/wpms] startup failed due to previous errors
二月 23, 2018 1:39:05 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Java\apache-tomcat-7.0.85\webapps\docs
二月 23, 2018 1:39:05 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Java\apache-tomcat-7.0.85\webapps\docs has finished in 41 ms
二月 23, 2018 1:39:05 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Java\apache-tomcat-7.0.85\webapps\examples
二月 23, 2018 1:39:05 下午 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
二月 23, 2018 1:39:05 下午 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
二月 23, 2018 1:39:05 下午 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('StockTicker', 'async.Stockticker@166c8a0b')
二月 23, 2018 1:39:05 下午 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@1b1f8236')
二月 23, 2018 1:39:05 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Java\apache-tomcat-7.0.85\webapps\examples has finished in 164 ms
二月 23, 2018 1:39:05 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Java\apache-tomcat-7.0.85\webapps\host-manager
二月 23, 2018 1:39:06 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Java\apache-tomcat-7.0.85\webapps\host-manager has finished in 80 ms
二月 23, 2018 1:39:06 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Java\apache-tomcat-7.0.85\webapps\manager
二月 23, 2018 1:39:06 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Java\apache-tomcat-7.0.85\webapps\manager has finished in 45 ms
二月 23, 2018 1:39:06 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Java\apache-tomcat-7.0.85\webapps\ROOT
二月 23, 2018 1:39:06 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Java\apache-tomcat-7.0.85\webapps\ROOT has finished in 42 ms
二月 23, 2018 1:39:06 下午 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
二月 23, 2018 1:39:06 下午 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
二月 23, 2018 1:39:06 下午 org.apache.catalina.startup.Catalina start
INFO: Server startup in 3522 ms
3、一开始我以为是jdk配置的问题,但是把环境变量啥的都配置了一遍发现还是不好使,然后一直感觉应该有这个类为啥就找不到呢,这时候才想起来去web-info下查看是否有这个classes文件,发现果然没有,这个问题发现自己一开始就走偏了没找到重点,说明还是欠缺经验啊。
4、WEB-INF\classes下无文件,project->build automatically 选上.然后重新clean一下就可以了。
以下是参考的文档:
1. 确保 project->build automatically 已经被选上.
2. 如果选上了,也不好使, 使用这一招: project->clean..->选第2个clean select project, 勾上start build immediatelly3.删除现在的项目,提前设置好编译文件输出路径,重新导入源文件,设置MyEclipse为保存时编译,然后在保存的时候就可以自动编译了
4.如果项目里引了某个不用的jar包,而那个包又被你删了,就会出现不报错但怎么也编译不出来class文件的情况,可以把所有包都删除,然后一个一个的再引入(需要的),不要一下子把所有包都引入来,没用的可能会引起不良后果.5. 想删掉某个class文件重新生成,删除class文件后,但classes目录下的文件夹被其它程序打开,比如Total Commander。此时编译也不会通过,在problems下可能会提示“con''t delete classes „„”。关掉其它程序重新编译即可。 6.还有种情况是remove掉 JRE System Library,重新导入即可编译。但是什么原因导致的还不清楚。
7.把build path中所有包都remove掉。然后又add jars,add libraries把需要的加进去,居然又开始编译了。。。
8.project->properties->java build path->source->.../WEB-INF/src的output folder不要默认,编辑让它指向../WEB-INF/classes
然后重新点击build工程即可自动编译。
我的问题出在这里,我把这个编译目录给误删了
9.再就是最重要的要看工程下面是否缺少了work目录,由于CVS控制时不把work加如版本,所以checkout后没有这个目录,要手工加上有的工程就能自动编译了