Tuesday, May 4, 2010

Struts2 on Glassfish v3

OMG. It was not that trivial to get it going, at least not using Netbeans.

First trying to use maven since I need to have some EJBs, but I gave up after not being able to get the archetype for Struts2 do any project for me, first complaining about no commons-collections-3.2.1, downloading it and got a little bit longer, but then could not find anything for struts2.1.6.

So I went on creating a Struts2 project and got it to work by pointing out the jar files needed in Netbeans JavaEE webproject for Glassfish, YES there is a lot of jarfiles depending on each other since I also want to use TILES. Anyway, when I wanted the use the EJBs I had to create a EAR-project to hold everything together, what happens then?

Struts2 stops working, complaining of a lot of classes not loaded or cannot find. I spent almost all the afternoon before finally finding the problem.

Netbeans ant-script wants to copy every f...ing jar file that is not a TLD to the lib of the EAR, NOT into the Web applications WEB-INF/lib, which then makes sence for the errors in the log: when loading from that EAR/lib folder, it can not find struts-core classes since that jar file is in the Web-app because it includes TLDs,

So finally solved, hack the build-impl.xml and copy ALL jar files to the web-app so it works.Why Netbeans do this way I do not know, maybe someone can inform me?