class double in directories ?

  • Thread starter Alexander Burger
  • Start date
A

Alexander Burger

Hi,

I have the following code on my apache-tomcat server (see below).
(debian, java 1.5)

it should call HelloWorldServlet, which is in the same directory.

but I get again and again the following error-message (see below).

I tried to find an answer in the web, but only could find that may be there
is a class double in different directories with different versions.
for compilation and for running there would be used different
java-classpathes.

I do compilation on that server of that HelloWorldServlet2-java-class
without problems.

could there be another problem ?
how could I find out, which class I have double on my server ?

thanks a lot for help in advance.

regards
Alex


--- code ---------------



import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class HelloWorldServlet2 extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
String url="./servlet/HelloWorldServlet";
request.getRequestDispatcher(url).forward(request,response);
}
}

--- error-message------------

java.lang.LinkageError: Class javax/servlet/RequestDispatcher violates
loader constraints
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1815)

org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:869)

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1322)

org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
HelloWorldServlet2.doGet(HelloWorldServlet2.java:16)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
J

Jan Thomä

I have the following code on my apache-tomcat server (see below).
(debian, java 1.5)

it should call HelloWorldServlet, which is in the same directory.

but I get again and again the following error-message (see below).
java.lang.LinkageError: Class javax/servlet/RequestDispatcher violates
loader constraints
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

Can it be that you have the servlet.jar deployed inside your WAR file? Your
servlet code usually has a dependency on this library and every now and
then one forgets that this library is provided by tomcat already. The error
message sounds like tomcat is complaining about this, so check if you have
deployed this library inside your war file and remove it from there if you
have...

Best regards,
Jan
 
A

Alexander Burger

Jan said:
Can it be that you have the servlet.jar deployed inside your WAR file?
Your servlet code usually has a dependency on this library and every now
and then one forgets that this library is provided by tomcat already. The
error message sounds like tomcat is complaining about this, so check if
you have deployed this library inside your war file and remove it from
there if you have...

Best regards,
Jan

Hi Jan,

thanks a lot for your answer.
but I don't have any *.war -file on my server :-(
with servlet.jar:
so far I can see there is only one on the whole server :-(

find . -name "servlet*" -print
../usr/share/java/servlet-api.jar
../usr/share/java/servlet-api-2.4.jar
../usr/share/java/servlet-2.3.jar
../usr/share/tomcat5.5/common/lib/servlet-api.jar
../usr/share/tomcat5.5/server/lib/servlets-ssi.renametojar
../usr/share/tomcat5.5/server/lib/servlets-default.jar
../usr/share/tomcat5.5/server/lib/servlets-webdav.jar
../usr/share/tomcat5.5/server/lib/servlets-cgi.renametojar
../usr/share/tomcat5.5/server/lib/servlets-invoker.jar

regards
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,228
Latest member
MikeMichal

Latest Threads

Top