Glassfish 3.x - Jersey with bundled dependencies
I just wanted to make a small post regarding an issue I spent almost a day getting rid off. I have a quite typical web architecture :
- jar module encapsulating business logic (EJBs)
- war module providing front end web access
- war module for web service access (using JAX-RS)
The headache
Each war module depends on the ejb-client counterpart present in WEB-INF/lib. The problem I faced is that my @EJB injections was raising ClassNotFoundExceptions. I tried bypassing automatic injection with manual JNDI lookups but the same errors occurred. Playing with the debugger I found that the jars present in lib folder were not added into the web application's classloader.
The workaround
I spent a lot of time trying many things to fix this and found out the trick by downloading Jersey's sample. You simply have to have a sun-web.xml with the following content :
I hope it will help someone else!