I'm having a problem with a little example application since some days ago.
Working with Struts 1.2.4, Tomcat 4.1.29, Mac OS X 10.3.8, Java 1.4.2. Inside the WEB-INF folder I have the usual files (struts-config.xml, .tlds, web.xml) and in the classes folder I have two compiled classes, ProbaForm.class and ProbaAction.class.
When I try to access to index.jsp I get the error
This is my struts-config file
Perhaps I'm missing something obvious, but I have tested those classes from a command-line program and worked fine. All the packages are in place ( /WEB-INF/lib/struts.jar et al.). I can't figure out where the problem is.
Any ideas. Thanks for your time, Santi
Dudo, your brain is vanishing like the fog.- Fraggel Rock
In fact, I used the default package because I was getting the same error with the classes grouped in packages.
Just in case I had done something wrong, I have package them and try it again with the same result: org.apache.jasper.JasperException: classNotFoundException org.contratempos.wiki.ProbaForm
I don't know what to think� I didn't use any IDE for avoiding "interferences" with the classpath and all the environment; I just use a plain editor. I also tested the classes with a main() method from command-line and the classes were found without problems.
I am a newbie in Struts, but the only thing I can think about that could be causing this error is something in the Struts chain.
I am stucked with this because I can't do anything more while this error isn't solved and I really trying to learn Struts to apply it in real projects.
this is not to address the issue you're facing (since i've always set up my apps using an IDE), but an opinion that may help you move on.
since you're using struts 1.2 and declarative form-bean, why use a 3rd party ActionForm class and not org.apache.struts.action.DynaActionForm. better yet DynaValidatorActionForm (since you'll eventually use validation). i've rarely seen the need to have a form extending these classes any way.
the 2 classes above are among the struts-provided classes (that if everything is set up properly with struts, you'll find out when you switch). by switching, i mean declare the 'type' to 'org.apache.struts.action.DynaActionForm' instead of 'ProbaForm'. switching over to one of the struts form classes may be sufficient to help you continue learning struts.
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Before you start using things like DynaValidatorActionForm Or IDE's I strongly recommend that you get the basics right. If you are having Classpath problems those options will not help, they will only mask the problem so it can come back and bite you later, but with bigger teeth. The first thing to do is to ensure that you can run the provided struts-blank app, if that works then try building a very simple app that doesn't use it. If that works, then start adding your own code to that, a small step at a time until you get it to work. Here is a very, very simple app, that can be used as a start:
Here's the source for the 5 files
As you can see, this uses no optional features, not even EL or validation, it doesn't use forms or packages and it does work if your struts install is good.
Joined: Nov 09, 2004
Regarding your comment about using DynaActionForm, I began my tests following a book that use Struts 1.0 and then I realised that the API had changed a bit from that version to the actual one. But my class (ProbaForm) is derived from org.apache.struts.action.ActionForm, so there should not be any problem with it. Anyway I'll give it a try if anything more works.
I agree with you that it's necessary to understand the basics right before using "advanced tools" (in fact I teach Java using plain text editors) and that's the reason I chose the most direct way to code a basic struts application. But I'm used to work with IDES -actually, XCode and NetBeans- and, though I sometimes had problems when trying new environments, never was anything important.
I have tried your application but unfortunately still doesn't work:
Mmm... this is an error with access control. I don't understand why. I gave a 777 mode to the application directory.
By the way, the struts-blank application works (I have an error about not finding message resources but I guess that it's because I'm working with locale es_ES).
One more thing, in my first application I included a standard servlet (one out of the control of Struts) and it worked fine. And it was in the same package that the rest of my classes. That's what I say that I'm missing something with the struts configuration but I can't figure out what could it be; I have the TLD, JAR and XML files inside the corresponding folders.
This is turning into a thriller .
Thanks to everybody for your suggestions. Going on with the investigations Santi
Joined: Jun 13, 2004
Originally posted by Santiago Conde: By the way, the struts-blank application works (I have an error about not finding message resources but I guess that it's because I'm working with locale es_ES).
I tried setting my locale to Spanish-Spain on W2K and I get all of Tomcat's messages in Spanish and the struts-blank still works fine, as does my little example. The MessageResources.properties is in the classes directory, so the inability to find that has the same cause as the ClassNotFound that occurs when you try to run my little app. Do you have a $CLASSPATH set in the environment? If so, try removing it.
Which versions of Tomcat and Struts are you using? I'm using Tomcat 5.5.7 and Struts 1.2.6 on Windows and Solaris with no problems.
Joined: Nov 09, 2004
I'm using Struts 1.2.4 (jakarta-struts-1.2.4 it's the package name) and Tomcat 4.1.29 running over a Mac OS X 10.3.8 , but
(A few hours later)� The thrill is gone!! Your comment about the CLASSPATH made me check it once again and...
Although I had said that I have no duplicates of struts.jar that was not true. I had an old struts.jar inside a forgotten directory, in the depths of the my home directory, which was in my class path.
(Here goes a lot of improper words for a cultivated person) For my consolation I'm not completely idiot: It had to do with Struts configuration but I'll have to be more careful with old installations.
Thanks to everybody for your patience and hints. This stupid error helped me to look carefully into the Struts flow.
Santi [ May 16, 2005: Message edited by: Santiago Conde ]
subject: ClassNotFound when everything is in place