File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Embedding Struts in JBoss 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 » Products » JBoss/WildFly
Bookmark "Embedding Struts in JBoss" Watch "Embedding Struts in JBoss" New topic
Author

Embedding Struts in JBoss

Virendra Rahatpuri
Greenhorn

Joined: Nov 08, 2002
Posts: 14
Hi,
I am using Apache2.0.44 + JBoss3.0.4_tomcat 4.1.12. My question is how do you configure Struts in this architecture.
Thx,
Virendra.
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi there,
I'm using JBoss 3.2 RC 3 / Tomcat and just include the Struts JAR files, XML files, etc. in the EAR file that I deploy in JBoss. As long as you declare the struts-config.xml and various support files in the web.xml file, then once you deploy your WAR or EAR file, everything should work fine. There is nothing JBoss-specific that you need to do to get Struts up and running.
Err, wait. There is one thing. You may need to copy the Struts JAR files to the /lib directory of your server instance. For instance, if you're using the default server, copy the files to <jboss_home>/server/default/lib. It seems that Struts doesn't properly register some of its classes with the class loader and in some environment, this can cause a ClassNotFound error when loading up.
To verify that nothing JBoss specific is needed to get Struts up and running on the server, download Struts, place its example war file in <jboss_home>/server/default/deploy and then start up JBoss. Once it's up, you should be able to try the Struts example.
Darryl
Virendra Rahatpuri
Greenhorn

Joined: Nov 08, 2002
Posts: 14
Thx Darryl.
Virendra Rahatpuri
Greenhorn

Joined: Nov 08, 2002
Posts: 14
I am using JBoss 3.0.4 and tomcat 4.1.24 and Struts 1.1. Now, if I make a change in one of the action classes JBoss does not recognize the change till I restart the server. Is there a fix to this problem?
Thx,
Virendra.
norman richards
Author
Ranch Hand

Joined: Jul 21, 2003
Posts: 367
Originally posted by Darryl A. J. Staflund:
Hi there,
Err, wait. There is one thing. You may need to copy the Struts JAR files to the /lib directory of your server instance. For instance, if you're using the default server, copy the files to <jboss_home>/server/default/lib. It seems that Struts doesn't properly register some of its classes with the class loader and in some environment, this can cause a ClassNotFound error when loading upl

I strongly recommend NOT doing this. You will run into lots of problems if you follow this approach. Only put the JBoss jar files in in your war file. If you have classloader problems, you need to investigate the true cause and not cover it up by placing the jars in the wrong location...
(just some friendly advice from someone who has been bitten my improperly scoped jars FAR too many times)
Virendra Rahatpuri
Greenhorn

Joined: Nov 08, 2002
Posts: 14
Hi Richard,
Derryl
My Struts.jar is in the deploy directory. I have my own action classes which extend the Struts action class, My action classes are bundled up in a jar and deployed in the deploy directory and not under the WEB-INF/classes directory. I did that because I had to reference some classes in the deploy directory and If I put these jars under the Under the WEB-INF/classes they were not able to load the other classes under the deploy directory.
Now, when I change my action classes the changes in the execute method does not reflect immediately i.e when ever I make the change I remove the old jar which contains the old classes and I update the jar with the new changes.( Assuming that jboss does a hot deploy when I replace the old jar with the new one) I do get all the logs saying the new jars have been deployed but when I execute the page I don't see the changes in the new jar.
Some way or the other the old action classes have been cached. And its not getting refreshed with the new changes.
Thx,
Virendra.
norman richards
Author
Ranch Hand

Joined: Jul 21, 2003
Posts: 367
The quirkiness you are seeing comes from the nature of the classloaders in JBoss. They aren't really meant for what you are doing. Trust me. If you want it to work, put your jars in WEB-INF/lib in your war file.
You don't want any library jars in the deploy directory. If you have a global jar (like a database driver) you can put it in the lib directory of your server, you are just begging for problems by putting it in the deploy directory. (my opinion, of course)
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi there,
Sorry I haven't been active as of late -- I am working on a ColdFusion project and am not able to visit the Java boards as often as I'd like. As for my previous comment on adding the jar file to the lib drectory, I think this was a dirty work-around to a problem I was addressing on a particular version of JBoss. I believe once we upgraded to JBoss 3.2.1 the problem no longer appeared and I no longer had need to place the file in the directory mentioned. I wish I could be more specific but my memory is a bit hazy on the details of that particular problem.
Cheers and good luck.
Darryl
Dennis Staiger
Greenhorn

Joined: Oct 22, 2003
Posts: 1
I am completely new to jboss and struts and would like to do it right straight away from the beginning. Unfortunately, I was not successful in finding a hands on tutorial doing exactly this. Perhaps anybody can provide me a short step by step instruction about how to integrate struts in jboss and how to get the struts example war file to run? Or can anybody point me to a website explaining the necessary steps?
I am using JBoss 3 with Tomcat which is up and running. I further was able to get the struts example war file to run using a standalone tomcat container.
norman richards
Author
Ranch Hand

Joined: Jul 21, 2003
Posts: 367
I don't use tomcat, but I seem to recall the struts example app running out of the box for me in JBoss. What is the specific problem you see deploying it?
vijay_radha
Greenhorn

Joined: Dec 08, 2003
Posts: 3
Originally posted by norman richards:
I don't use tomcat, but I seem to recall the struts example app running out of the box for me in JBoss. What is the specific problem you see deploying it?

Hello Mr.Norman Richards,
I have seen your suggestions in the JavaRanch site.
I�m looking for a help from you that is I have integrated EasyStruts plug-in with Eclipse2.1 IDE. And I added struts support thro EasyStruts plug-in to the J2EE application which is created using Lomboz plug-in in Eclipse. After that I started the JBoss server thro the Lomboz plug-in, it throws the error:
java.lang.ClassNotFoundException: org.apache.catalina.Container
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
Any solution for this?!
--Vijay
Raffaele Cafiero
Greenhorn

Joined: Apr 30, 2004
Posts: 1
Hi Norman, I am having the very same problem. I cannot install the struts web applications, for example the struts-example.war webapp. When I try to deploy it I get a ClassNotFoundException on the ActionServlet class.
I agree with you that one must NOT put jar archives everywhere in the jboss's directories.
But, after that, what is in your opinion the cause of my problem?
What can I do in order to use struts 1.1 on JBOSS 3.2.3?
thanks
Raffaele
Originally posted by norman richards:
The quirkiness you are seeing comes from the nature of the classloaders in JBoss. They aren't really meant for what you are doing. Trust me. If you want it to work, put your jars in WEB-INF/lib in your war file.
You don't want any library jars in the deploy directory. If you have a global jar (like a database driver) you can put it in the lib directory of your server, you are just begging for problems by putting it in the deploy directory. (my opinion, of course)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Embedding Struts in JBoss