Well! Here goes!
Hi All!
After a tiring, brain ratting fight, i was finally able to solve this problem.
IN A NUTSHELL, THE PROBLEM IS WITH JARS, THEIR LOCATION AND RELATIVE PATHS OF OTHER RESOURCES, IF YOU GET THIS ERROR WHEN DEVELOPING PROJECTS IN AN IDE
I ran into this error as many of my friends at JavaRanch here did.
I was developing my "First Struts Program" (though not officially the first one) via Eclipse IDE 3.2.1
I am using Apache Tomcat 5.5.27
Struts 1.3.10 download
I integrated Tomcat into Eclipse and was trying to get my project work via Eclipse thorugh the Run on Server option.
Earlier, working out another sample project on Tomcat Deployment Directory (as recommended in HFSJ), i had been able to work out the project with ease.
(No WAR-ring and putting it in tomcat/webapps though, all from scratch under tomcat)
In Eclipse, i was creating a "Dynamic Web Project".
If App1 is the name of my project, the folder structure that gets created is a
1)App1/src - where your java code goes
2)App1/src/Libraries - where the jars go
On expanding Libraries, you see 3 folders.
i)JRE System Library
ii)Apache Tomcat Library (depends on the server used, I used Apache Tomcat)
iii)Web App Libraries
3)App1/build/classes - the classes go here
4)App1/WebContent - which has WEB-INF/lib, META-INF and the jsps - WEB-INF has the .tld files, the
web.xml and the
struts-config.xml as peers to the lib folder.
What I did? (Has a lot of relevance to the errors that arised)
1) I created a package java inside src and put my Action and ActionForm classes here
2) Right clicked the project App1 -> Properties -> Java Build Path -> Add External Jars -> added all jars (struts) here.
Now once you do this, the App1/src/Libraries reloads to show all the libraries that are now added to the project, as peers to JRE and Apache Folders
3) Put my jsps under App1/WebContent
Errors Encountered:
ERROR 1: When i hit index.jsp,(this had a struts html tag in it) by launching the server from Eclipse, i got the
org.apache.jasper.JasperException: Module 'null' not found
error. And my tomcat always started with a
java.lang.ClassNotFoundException: org.apache.commons.beanutils.Converter error, but i didn't bother as it still started (bad programming discipline, i know
)
Solution: I was missing jars, thanks to help at JavaRanch.
But i already had all my jars added to the project's build path!! Here they are, under the src/Libraries folder!!
In a desperate attempt,
i copied all the struts jars to the WebContent/WEB-INF/lib folder. But nothing gets reflected here.
Instead the Web App Libraries under src/Libraries got reloaded with the libraries. So it seems that the project is picking up the taglib jars only from this folder.
ERROR 2: Now my tomcat started clean and the index.jsp got rendered perfect. ERROR 1 fixed!!!
When i clicked the link, which navigates to the form, i got the following error:
org.apache.jasper.JasperException: Exception creating bean of class java.CustomerForm under form name CustomerForm
Oh man! This was getting bad!
Solution:Looks like the way the setup expects the .class files is right under the classes directory instead of some other package under classes like classes/java
So it was looking for the CustomerForm.class right under classes and not some directory under classes when they actually existed under classes/java
So i put my .java files right under src and built the project again. Changed path entries in struts-config.xml accordingly.
Now they got picked up right and the CustomerForm got created.
Finally, there were some similar relative path problems with the jsps being referred in struts-config.xml.
When i changed them, everything worked.
I'm sure there's a better way of dealing with this problem as its simply a code-organization problem.
But i just thought i'd update folks on this one solution that i got.
Sorry for making the post too long! Wanted to give all details
Best wishes,
Suresh Ramanan