Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot Compile Servlet with Tomcat

 
Mickey Smith
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

I have written a servlet which resides in webapps/myApp/WEB-INF/classes/com/myappln/ in tomcat.

now whenever i invoke this servlet with the url http://localhost:8080/myApp/servlet/com.myappln.MyServlet.

Can this issue be related to the CLASSPATH VARIABLE.

Thanks in Advance....
[ July 12, 2006: Message edited by: Mickey Smith ]
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your question in missing half a sentence that describes what is actually happening...

If by "reside" you mean that that's the directory the servlet class is in, then it won't work. All classes need to be inside WEB-INF/classes or WEB-INF/lib.

It also looks like you might be using the invoker servlet - read this for why that's not such a good idea. You should properly map your servlets to URL patterns in the web.xml file.
[ July 12, 2006: Message edited by: Ulf Dittmer ]
 
Mickey Smith
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am sorry the full path is: webapps/myApp/WEB-INF/classes/com/myappln/

Do i need to comment the script which invokes invoker servlet inside conf/web.xml?
 
Mickey Smith
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have disabled the invoker servlet even after that the problem is present. The main thing is that ClassLoader is unable to get the .class file because the servlet has not yet compiled. I have also set the CLASSPATH variable and all the settings are correct.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to compile the servlet yourself. The container won't do this for you.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand how accessing the URL relates to compiling the servlets (servlets are not automatically compiled if they are accessed). The problem description is still missing something. Be aware that Tomcat does not use the CLASSPATH variable.

If you disable the invoker, then the URL will definitely not work (since it contains "/servlet/", which is what accesses the invoker servlet).
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Satou has correctly noted, Tomcat does not compile Servlet code.
You need to do this yourself with Javac and place the .class file under WEB-INF/classes/{package structure}/{class files}

Moving to the Tomcat forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic