views:

47

answers:

2

Hey, I'm trying to run Apache Tomcat 6.0.26 on Mac OS X - Snow Leopard, but with no luck :(

I've downloaded Tomcat core from: http://tomcat.apache.org/download-60.cgi unarchived it at /Livrary/Tomcat directory, but when I'm trying to run it using ./bin/startup.sh command from log/catalina.out logs it seem's that it can't find servlet-api:

SEVERE: Error deploying configuration descriptor host-manager.xml
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
    at org.apache.catalina.core.StandardHost$MemoryLeakTrackingListener.lifecycleEvent(StandardHost.java:561)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4462)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    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:519)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    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:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

During startup it logs in console CLASSPATH it's using:

Using CLASSPATH:       /Library/Tomcat/bin/bootstrap.jar

I've not tried to deploy my own application (*.war) it's just "clean" Tomcat.

A: 

Are your CATALINA_BASE and CATALINA_HOME variables correct?

(they should be printed along with the CLASSPATH on startup).

I just tried exactly what you did (downloaded a fresh tomcat 6.0.26 on OS X 10.6.3), unzipped it (I downloaded the core/zip), then set all the .sh files to executable: (in the bin folder):

chmod a+x *.sh

After that, running startup.sh worked without a hitch.

I can only think that prior CATALINA variables are conflicting?

desau
I've tried "chmod a+x *.sh", but result is same.Here's full log of ./startup.sh command:Using CATALINA_BASE: /Library/TomcatUsing CATALINA_HOME: /Library/TomcatUsing CATALINA_TMPDIR: /Library/Tomcat/tempUsing JRE_HOME: /Library/Java/HomeUsing CLASSPATH: /Library/Tomcat/bin/bootstrap.jar
giolekva
+2  A: 

Probably your system classpath somehow get polluted with pre-2.5 servlet API jar.

You may check it by running java javax.servlet.http.HttpServlet - it should throw NoClassDefFound. If it throws NoSuchMethodError, check your classpath (especially CLASSPATH environment variable and lib/ext subfolder of JRE installation).

EDIT: Try the following code - at least it will show the location of the offending jar:

public class Test {
    public static void main(String[] args) throws Exception {   
        System.out.println(
            Test.class.getClassLoader().getResource("javax/servlet/http/HttpServlet.class"));
    }
}
axtavt
I've not set CLASSPATH variable and I can't find servlet API in /Library/Java/Home/lib/ext, but it throws NoSuchMethodError
giolekva
Thanks :), with your code I've found jar which contained HttpServlet. It was Google's Closure library which I've had at /Users/giolekva/Lirary/Java/Extensions directory. Thanks again :)
giolekva