This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello, I am in the process of developing a J2EE app for one of my clients and I have been stuck with the same type problems, which I think are related to J2EE classloading. First, I will give an overview of the app.
There are three components that make up my app. 1st I have created an application (EAR 1) specific to the system user interface. This ear includes one web module and one EJB module that contains business logic specific to activites within the user interface. 2nd I have created another application (EAR2) that only contains one ejb module. This EJB module contains generic business logic and i forsee it being utilized by multiple different systems and clients. Finally, I have created a commons jar project, that basically contains all common value objects, exceptions, utilities etc. This commons jar file is being reference as a project utility jar within EAR1 and EAR2.
Well, hopefully you haven't fell asleep yet, because here are my specific questions. Inside my commons jar, I have a user heirarchy; lets just say I have a Parent User and a child user. Now, within my common EJB jar, I have a method that returns the Parent User. A session facade that resides in the UserInterface application makes a call to the method, and the method completes sucessfully and returns the Parent User object. However, when the facade attemps to cast the class to the child user, or even when I try to do it within the WSAD Universal test client, I keep getting a ClassCastException.
1). Is this because my classloader policy is set to Application; therefore, the classes are loaded in different namespaces? I even noticed that when I do an 'instance of' the check returns false, even though the returned object is definitly an instance of.
2). Does this have something to do with my build paths and references? I don't think so, because I do not get compile time errors or NoClassDefFound errors.
3). With any solution, will the app run into problems if the class loading policy is changed on the server?
How do I solve this problem? Any help will be greatly appreciated. I will exchange more info if needed.