Transfer Object loader constraints
If both EJBs and POJOs require access to the same TO, then where do I put the class?
I thought that EJB's had their own class loader, so I included the TO in the EJB jar and deployed it. However, when I use a POJO in my main application I get errors about violating class loader constraints.
The pattern does not seem to mention anything about this. I'm assuming I've missed something patently obvious (java basics level 1... :-) Can anyone enlighten me?!
Thanks,
Jon
[501 byte] By [
J_Carra] at [2007-9-29 22:20:44]

Create another jar that will contain all your POJO's. Put it on the J2EE classpath. Also put it on your application's classpath. I think that should do the trick. The classloaders will have different instances/references to the TO's, but as long as you are not trying to share the object amount classloaders, I believe you should be okay.
- Saish
"My karma ran over your dogma." - ANon
Another option is to package the TO with your EJB and also provide it in the ejb-client jar your application uses to access the EJBs. A package structure like this helps a lot:
com/somecompany/ejbstuff
..../ejb
..../MyEjb.java
..../MyEjbHome.java
..../MyEjbRemote.java
..../dto
..../MyDto.java
This allows the ejb-client jar to contain everything in package dto, plus the Home and Remote interfaces from the EJBs.