Discussion:
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
Vasiliy Keretsman
2006-11-08 14:56:14 UTC
Permalink
Hi!

I've got the following problem during Tomcat 5.5.20 startup

- Error configuring application listener of class
myapp.util.WebApplicationContextSupport
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener

servlet-api.jar is in common/lib.


I've never had such problem with Tomcat 5.0.28.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Caldarale, Charles R
2006-11-08 16:52:10 UTC
Permalink
Post by Vasiliy Keretsman
javax/servlet/ServletContextListener
- Error configuring application listener of class
myapp.util.WebApplicationContextSupport
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
servlet-api.jar is in common/lib.
Is the jar perchance in some other directory as well - such as inside
the webapp? It shouldn't be in more than one place.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Martin Gainty
2006-11-08 17:01:22 UTC
Permalink
Vasily-
Can we see the web.xml listener element configuration for ServletContextListener and any listener's deriving from ServletContextListener
have you verified your $CATALINA_HOME/commons/lib/servlet-api.jar is the same as the OS specific distro jar?

Anyone else?
M-
This e-mail communication and any attachments may contain confidential and privileged information for the use of the
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its
contents
----- Original Message -----
From: "Vasiliy Keretsman" <***@gmail.com>
To: <***@tomcat.apache.org>
Sent: Wednesday, November 08, 2006 9:56 AM
Subject: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
Post by Vasiliy Keretsman
Hi!
I've got the following problem during Tomcat 5.5.20 startup
- Error configuring application listener of class
myapp.util.WebApplicationContextSupport
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
servlet-api.jar is in common/lib.
I've never had such problem with Tomcat 5.0.28.
---------------------------------------------------------------------
Vasiliy Keretsman
2006-11-08 17:24:18 UTC
Permalink
Martin, Chuck

Thanks for reply.

1. servlet-api.jat is only in tomcat/common/lib

2. cut from web.xml
Post by Martin Gainty
Can we see the web.xml listener element configuration for ServletContextListener and any listener's deriving from ServletContextListener
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
<listener-class>myapp.util.WebApplicationContextSupport</listener-class>
</listener>
Post by Martin Gainty
have you verified your $CATALINA_HOME/commons/lib/servlet-api.jar is the same as the OS specific distro jar?
Downloaded binary distro from Tomcat site. OS Linux (archlinux & debian)

Just tried 5.5.15 and 5.5.17 - the same problem.

it doesn't happen in 5.0.28 though.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Vasiliy Keretsman
2006-11-08 18:12:04 UTC
Permalink
Hi!

The problem was solved.

Linux version of catalina/bin/setclasspath.sh in 5.5.15,17,20 hides
the following classpath setting under condition. With tools.jar in
classpath it works.

if [ "$1" = "debug" -o "$1" = "javac" ] ; then
CLASSPATH="$JAVA_HOME"/lib/tools.jar
fi

Btw, setclasspath.bat does not contain such condition as well as
bat/sh of 5.0.28

Sounds odd, but it helped.


Best regards,
Vasiliy

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Caldarale, Charles R
2006-11-08 18:19:14 UTC
Permalink
Post by Vasiliy Keretsman
javax/servlet/ServletContextListener
Linux version of catalina/bin/setclasspath.sh in 5.5.15,17,20 hides
the following classpath setting under condition. With tools.jar in
classpath it works.
That makes no sense at all, since there are no javax.* classes in
tools.jar. The only thing that Tomcat might use out of tools.jar is the
javac classes, and then only if you configure it to use javac instead of
the default compiler.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Vasiliy Keretsman
2006-11-08 18:29:16 UTC
Permalink
Post by Caldarale, Charles R
That makes no sense at all, since there are no javax.* classes in
tools.jar. The only thing that Tomcat might use out of tools.jar is the
javac classes, and then only if you configure it to use javac instead of
the default compiler.
I know it looks strange.
I manually added servlet-api.jar to CLASSPATH at first and Tomcat
started without errors.
Afterwards i've just compared setclasspath.sh in both 5.0 and 5.5.

Vasiliy

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Caldarale, Charles R
2006-11-08 18:36:18 UTC
Permalink
Post by Vasiliy Keretsman
javax/servlet/ServletContextListener
I manually added servlet-api.jar to CLASSPATH at first and Tomcat
started without errors.
You've got something else going on. Tomcat completely ignores any
existing CLASSPATH setting and establishes its own; the system
classloader is used only for bin/bootstrap.jar.
Post by Vasiliy Keretsman
Afterwards i've just compared setclasspath.sh in both 5.0 and 5.5.
They are different because 5.0 used the javac classes from tools.jar
whereas 5.5 includes its own Java compiler. That's why 5.0 required a
JDK and 5.5 needs only a JRE.

You might want to run with -verbose:class just to see where classes are
really being loaded from.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Vasiliy Keretsman
2006-11-09 09:27:47 UTC
Permalink
hi!
Post by Caldarale, Charles R
Post by Vasiliy Keretsman
I manually added servlet-api.jar to CLASSPATH at first and Tomcat
started without errors.
You've got something else going on. Tomcat completely ignores any
existing CLASSPATH setting and establishes its own; the system
classloader is used only for bin/bootstrap.jar.
Sorry, forgot to mention that just for test i had added
servlet-api.jar in setclasspath.sh after CLASSPATH reset line.
Post by Caldarale, Charles R
They are different because 5.0 used the javac classes from tools.jar
whereas 5.5 includes its own Java compiler. That's why 5.0 required a
JDK and 5.5 needs only a JRE.
You might want to run with -verbose:class just to see where classes are
really being loaded from.
Thanks. Just did it.

Without tools.jar in classpath the exception still occures (See at the bottom).

With tools.jar in classpath it goes well:

[Loaded javax.servlet.ServletContextListener from
file:/opt/apache-tomcat-5.5.20/common/lib/servlet-api.jar]
[Loaded enCode.util.spring.WebApplicationContextSupport from
file:/home/vasya/prj/trunk/WEB-INF/classes/enCode/util/spring/We
bApplicationContextSupport.class]


I thought it might have been problem related to SpringFramework somhow
and tested it without spring context. But it didn't help either



[Loaded org.apache.log4j.spi.NullWriter from
file:/home/vasya/prj/trunk/WEB-INF/lib/jakarta-log4j.jar]
- Error configuring application listener of class
enCode.util.spring.WebApplicationContextSupport
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1270)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3711)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
- Skipped installing application listeners due to previous error(s)

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Peter Björkman
2006-11-09 14:34:09 UTC
Permalink
Hi! I have a web-app residing in "/", the docBase is relative to appBase. I have an issue where I want to serve static files located outside the web-app. For example:

/mydir/index.jsp
comes from the relative docBase as usual.
/images/myimage.gif
comes from /var/static/images/myimage.gif, an absolut directory in the servers filesystem.

Is this possible without creating a separate web-app with another docBase? Could you map "/images" to that file system path "/var/static/images/"? I've been looking through the documentation (5.0) for this, but cannot find it anywhere...

Regards
Peter
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Mark Thomas
2006-11-09 23:14:23 UTC
Permalink
When starting a new thread (ie sending a message to the list about a
new topic) please do not reply to an existing message and change the
subject line. To many of the list archiving services and mail clients
used by list subscribers this makes your new message appear as part
of the old thread. This makes it harder for other users to find
relevant information when searching the lists.

This is known as thread hijacking and is behaviour that is frowned
upon on this list. Frequent offenders will be removed from the list.
It should also be noted that many list subscribers automatically
ignore any messages that hijack another thread.

The correct procedure is to create a new message with a new subject.
This will start a new thread.

Mark
tomcat-user-owner

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Peter Björkman
2006-11-10 08:11:54 UTC
Permalink
(And sorry for hijacking the previous thread - my bad, won't happen again).

Hi! I have a web-app residing in "/", the docBase is relative to appBase. I have an issue where I want to serve static files located outside the web-app. For example:

/mydir/index.jsp
comes from the relative docBase as usual.
/images/myimage.gif
comes from /var/static/images/myimage.gif, an absolut directory in the servers filesystem.

Is this possible without creating a separate web-app with another docBase? Could you map "/images" to that file system path "/var/static/images/"? I've been looking through the documentation (5.0) for this, but cannot find it anywhere...

Regards
Peter


PETER BJÖRKMAN - SYSTEM ARCHITECT
josh / together is better / www.josh.se
sveavagen 59 / 113 59 stockholm / sweden
phone +46 (0)8 650 21 07 / mobile +46 (0)709 687 887
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Rashmi Rubdi
2006-11-10 11:30:15 UTC
Permalink
Peter,

I'm not too sure if this will help but, you might want to try URL Rewriting, if you have Apache as the web server you could use it's rewrite features.

I don't think Tomcat5.0 has a Rewrite feature built in but I came accross this one: URLRewriteFilter http://tuckey.org/urlrewrite/ it works with Tomcat.

Then you could map <from>(*.)/images(*.)</from> , to <to>(*.)/var/static/images/(*.)</to>

I'm not sure if it'll work since as you've mentioned /var/static/images/ is outside your applications context.

-Regards
Rashmi

----- Original Message ----
From: Peter Björkman <***@josh.se>
To: ***@tomcat.apache.org
Sent: Friday, November 10, 2006 3:11:54 AM
Subject: Path mapping...


(And sorry for hijacking the previous thread - my bad, won't happen again).

Hi! I have a web-app residing in "/", the docBase is relative to appBase. I have an issue where I want to serve static files located outside the web-app. For example:

/mydir/index.jsp
comes from the relative docBase as usual.
/images/myimage.gif
comes from /var/static/images/myimage.gif, an absolut directory in the servers filesystem.

Is this possible without creating a separate web-app with another docBase? Could you map "/images" to that file system path "/var/static/images/"? I've been looking through the documentation (5.0) for this, but cannot find it anywhere...

Regards
Peter


PETER BJÖRKMAN - SYSTEM ARCHITECT
josh / together is better / www.josh.se
sveavagen 59 / 113 59 stockholm / sweden
phone +46 (0)8 650 21 07 / mobile +46 (0)709 687 887
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Mark Thomas
2006-11-10 18:10:38 UTC
Permalink
Post by Rashmi Rubdi
I'm not too sure if this will help but, you might want to try URL Rewriting, if you have Apache as the web server you could use it's rewrite features.
I'm not sure if it'll work since as you've mentioned /var/static/images/ is outside your applications context.
This won't work. Given the paths you have provided, you aren't using
Windows so you could create a symbolic link in your webapp directory
the links to the images directory. You will need to set allowLinking
to true for this to work.

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: ***@tomcat.apache.org
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Loading...