File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes ClassNotFoundException for class in WEB-INF/classes! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ClassNotFoundException for class in WEB-INF/classes!" Watch "ClassNotFoundException for class in WEB-INF/classes!" New topic
Author

ClassNotFoundException for class in WEB-INF/classes!

Jack J. Jackson
Greenhorn

Joined: Apr 20, 2002
Posts: 27
I went back to do some maintenance on a deployed web app and when accessing it on my test server, I'm getting a ClassNotFoundException for a class in my WEB-INF/classes directory!

So I put this code in my servlet's doGet() method to check:

Of course, the first thing I did was check to see if the com.domain.myapp.web.SelectPageAction.class was deployed in the WEB-INF/classes directory - and it was.

I'm running JBoss 3.2.x with embedded Tomcat 4.1.x, but have been all along, so I'm not sure what has changed regarding classloading.

Maybe I've just been looking at this too long!

Any suggestions.

Jack


Jack
Jack J. Jackson
Greenhorn

Joined: Apr 20, 2002
Posts: 27
FYI: In my original post I forgot to mention that, indeed, the catch block was entered indicating the class could not be found.

jack
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
Is it possible that a jar file exists in the app or somewhere in JBoss that has a package "com.domain.myapp.web"? If so, maybe that package got loaded first.


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

a class in my WEB-INF/classes directory


Directly? Or in the appropriate folder structure for the package?

IOW, is the class file at /WEB-INF/classes/com/domain/myapp/web/SelectPageAction.class?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jack J. Jackson
Greenhorn

Joined: Apr 20, 2002
Posts: 27
William,

>> Is it possible that a jar file exists in the app or somewhere in JBoss that has a package "com.domain.myapp.web"? If so, maybe that package got loaded first.<<

This is the only app server instance running on the machine and no JARs with that package have been deployed, except in the WAR file.

But let's assume some other JAR containing a com.domain.myapp.web package got loaded first. The package represents little more than a directory for namespace protection. If it doesn't contain the SelectPageAction.class file, then the search would continue and should find the class in my WAR file's WEB-INF/classes directory.

However, I think we agree there's some classpath issue, but I haven't ever had this kind of error about not finding a class in the WEB-INF directory when it's really there.
Jack J. Jackson
Greenhorn

Joined: Apr 20, 2002
Posts: 27
Bear,

>> IOW, is the class file at /WEB-INF/classes/com/domain/myapp/web/SelectPageAction.class <<

The class is in the appropriate directory structure.

Actually, that was my first concern, too. When building the WAR, did the class get put into some incorrect directory? Since the buid is done with an Ant WAR task, I was pretty confident it went into the right place - and it did.

Thanks for the response though!
Joe Nguyen
Ranch Hand

Joined: Apr 20, 2001
Posts: 161
Could you verify whether the size of your deployed class is the same as the size of the compiled class? Are they indentical? Once I used ftp to deploy a single class and got class not found exception because content of my deployed class was messed up.
Jack J. Jackson
Greenhorn

Joined: Apr 20, 2002
Posts: 27
Joey (et al),

Thank you all for your responses. I was finally able to find the problem and here is what happened:

The class not being found inherited from another class. It was a JAR file that contained that class that was missing from my deployment. I'm not sure why the ClassLoader was complaining about the subclass not being found instead of the super class, but that's my story and I'm sticking to it!

Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ClassNotFoundException for class in WEB-INF/classes!