wood burning stoves 2.0*
The moose likes Servlets and the fly likes Error:  IllegalName: /SearchServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Error:  IllegalName: /SearchServlet" Watch "Error:  IllegalName: /SearchServlet" New topic
Author

Error: IllegalName: /SearchServlet

J Derzaph
Greenhorn

Joined: May 29, 2008
Posts: 7
Ok, I've seen this error in a couple of other posts but the solution doesn't work for me. My xml is a little different so I'll post it.

<servlet>
<servlet-name>SearchServlet</servlet-name>
<servlet-class>.SearchServlet</servlet-class>
<servlet>
<servlet-mapping>
<servlet-name>SearchServlet</servlet-name>
<url-pattern>/SearchServlet</url-pattern>
</servlet-mapping>

And here's the error I get:
exception

javax.servlet.ServletException: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:417)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:300)
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:374)
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:743)
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:675)
org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:866)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:595)


root cause

java.lang.NoClassDefFoundError: IllegalName: /SearchServlet
java.lang.ClassLoader.preDefineClass(ClassLoader.java:476)
java.lang.ClassLoader.defineClass(ClassLoader.java:614)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
java.security.AccessController.doPrivileged(Native Method)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:417)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:300)
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:374)
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:743)
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:675)
org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:866)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:595)

What's really annoying about it is that the app works perfectly well on my computer locally but when I uploaded the files to a web server I get this error. I suspect the versions are different.
Any suggestions?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30146
    
150


Typo? A class name can't start with a dot. It needs to start with the package name if it is in a package or just the class name if it is not.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
J Derzaph
Greenhorn

Joined: May 29, 2008
Posts: 7
Oops. That's not supposed to be there. It has the error without the dot though.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4168
    
  21

Originally posted by J Derzaph:
Oops. That's not supposed to be there. It has the error without the dot though.



So the real servlet isn't in a package? What version of Tomcat? With some combinations of servers and JDKs you need to put the Servlet in a package for it to be recognized.
[ September 05, 2008: Message edited by: Steve Luke ]

Steve
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Is the servlet in a package? If not, put it in one to eliminate that as a source of error.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
J Derzaph
Greenhorn

Joined: May 29, 2008
Posts: 7
I have another servlet that is set up the same way and is running just fine though so I don't think its an issue with packages.
the version of Tomcat on the server is 5.0.27.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Servlets that are not packaged may or may not work. Not only is it a poor practice to have unpackaged classes, eliminating that as a source of error is just common sense.

Why would you not follow this accepted practice?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I have another servlet that is set up the same way and is running just fine though so I don't think its an issue with packages.


When a JVM sees a class without a named package (ie, the default package) it looks for that class in the "current" directory. Depending on the "current" directory to always be correct leads to exactly the problem you have.

This is a well known and frequently remarked on trap for programmers new to servlets.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error: IllegalName: /SearchServlet
 
Similar Threads
Illegal constant pool type
commons-fileupload
ExceptionInInitializerError in Axis 1.1 with Tomcat 5.0.27
Jforum install problems on godaddy
Simple panelTabbedPane