2

I had just started working with tomcat and was working well,however since yesterday i am facing trouble in starting it.I have re-installed it too.the error report i got in its log file is posted below.....

Blockquote

   2013-01-01 19:10:21 Commons Daemon procrun stderr initialized
   java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:60)
   Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at sun.misc.Launcher$ExtClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 1 more

Exception in thread "main"

nobalG
  • 4,544
  • 3
  • 34
  • 72
  • Does `$tomcat_home/bin/tomcat-juli.jar` exist and is readable/not corrupted? Do you set any bootclasspath by a chance? – mindas Jan 02 '13 at 11:03
  • @mindas: the tomcat-juli exists – nobalG Jan 02 '13 at 11:07
  • can u please list the of jars u have inside the lib folder – Suresh Atta Jan 02 '13 at 14:00
  • 1
    @TheSureshAtta 1)annotations-api 2)catalina 3)catalina-ant 4)catalina-ha 5)catalina-tribes 6)ecj-4.2.1 7)el-api 8)jasper 9)jasper-el 10)jsp-api 11)servlet-api 12)tomcat-api 13)tomcat-coyote 14)tomcat dbcp 15)tomcat jdbc 15)tomcat util 16)tomcat-i18n-fr 17)tomcat-i18n-ja 18) tomcat-i18n-es.........ahhh..done that..: – nobalG Jan 02 '13 at 14:10
  • please paste the bin/tomcat-juli.jar in lib folder and give a try ... – Suresh Atta Jan 02 '13 at 14:28
  • This can happen when you polluted the `/WEB-INF/lib` folder of the deployed webapp with servletcontainer-specific JAR files. Please list the JARs you have in `/WEB-INF/lib` folder of the webapp you're trying to deploy. Further, this can also happen if you polluted `/lib` or `/lib/ext` folder of the JRE/JDK installation like that in a careless attempt to "fix" compilation errors when compiling by `javac` in command prompt instead of by an IDE or some decent build tool. Have you ever touched the lib folders of JRE/JDK like that? Please also tell how exactly you're building/deploying/starting. – BalusC Jan 02 '13 at 15:22
  • @BalusC:actually i copied the libraries from tomcat into the ext folder of jdk... – nobalG Jan 02 '13 at 16:06

1 Answers1

4

actually i copied the libraries from tomcat into the ext folder of jdk..

You shouldn't be doing that. It causes a classloading disaster. You should not move/copy/change servletcontainer's own libraries. You should untouch them and never drop arbitrary JARs which are not in any way related to Java SE in the JRE/JDK /lib or /lib/ext folder. Cleanup those folders.

On a related note, even though you seem to not have done that, you should also not be placing servletcontainer-specific JAR files in webapp's /WEB-INF/lib folder.

This is a common starter's mistake in order to circumvent compilation errors on JSP/Servlet APIs or to "simplify" compilation without fiddling with %CLASSPATH% or -cp/-classpath. If you're using an IDE like Eclipse/Netbeans, then you should actually have registered the server runtime in the IDE and associated it with the web project as "target runtime". If you're using plain javac, then you should actually have used -cp/-classpath argument to specify the servletcontainer-specific JAR files for compile. To abstract that further away in order to avoid retyping the whole classpath value, you should just have placed the command in a reusable .bat or .cmd file or just have a decent build tool like Maven, Gradle or even an IDE like Eclipse/Netbeans.

See also:

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • gosshhhhh.....atleast i came to know the real problem...i was searching over the internet since last two days,anyhow yet after cleaning the mess,the log files now started showing some other errors.....i think reinstalling the jdk might solve the problem for me – nobalG Jan 02 '13 at 17:04
  • But both the facts stated by you,which i should not have to do,are preferred by many authors of various books...including the one which i am reading... – nobalG Jan 02 '13 at 17:11
  • Either you misinterpreted the book, or the author is a [beep]. – BalusC Jan 02 '13 at 17:12
  • this is certain that i have not misinterpreted... :p ...as he explained the logic behind doing so(easier,shorthands etc.).....but i want to know from you,that what is the real problem....why not to do this..what actually happened by doing so? – nobalG Jan 02 '13 at 17:17
  • The JARs in those wrong locations are not only used during compiletime, but also used during runtime while really servletcontainer's own ones should be used instead. The bootstrap (JRE) classloader doesn't have access to other JARs internally used by the container. So if a container specific class is loaded by the bootstrap classloader, it wouldn't be able to find other JARs internally used by the container which are not been placed in JRE/JRK `/lib(/ext)`. Copying the *entire* container-specific library collection of JARs to there would theoretically also solve it, but that's utterly wrong. – BalusC Jan 02 '13 at 17:25
  • Also, it would run into classloading disaster if you install and use another servletcontainer of different make (or version!) at the same machine like Glassfish or JBoss AS. The JAR file of a completely different container make/version (in this case, Tomcat) would be loaded from JRE/JRK lib and totally clash with internal workings of the container actually being used. – BalusC Jan 02 '13 at 17:33