Thursday, August 30, 2012

Struts 2 convention plugin in a WAR in a EAR in Jboss

This issue has been bugging my for a while and I have not found any solution to it so far. It seems from google results that I am not alone with this problem.

The problem occurs when you have a Struts 2 convention based web application (WAR) inside an EAR package. And deploy it on jboss. Because of Jboss using the vfszip packaging the open symphony ClassFinder fails with a message like

c.o.x.u.f.ClassFinder - Unable to read URL 
    [vfszip:/.../server/default/deploy/MyEar.ear/MyWebApp.war/WEB-INF/classes/]
    java.io.FileNotFoundException: 
    /.../server/default/deploy/MyEar.ear/MyWebApp.war/WEB-INF/classes/ 

So. Nobody solved it in a good way yet. I'm gonna go with this solution, it'll have to do for now.

Update: I tried to implement the linked solution using reflections, but failed. Basically it has the same issue and I'm still left with hard coding the list of classes.

Friday, August 10, 2012

Surefire plugin wont run my JUnit tests!

I spent way to much time on this trivial issue to not write it down. I ran into an issue where my unit tests (JUnit 4) were running fine in Eclipse but not by the maven surefire plugin.

Google served up numerous solutions to my problem but it didn't help me. My problem was much simpler. Eclipse will run any test in any class where the method is annotated with @Test. This does not apply to surefire. If the class is not named Test, surefire will not even look for tests in it. Hence, in maven projects, we should always name test classes that way.