I have 2 different Java projects, one has 2 classes: dynamicbeans.DynamicBean2
and dynamic.Validator
.
On the other project, I load both of these classes dynamically and store them on an Object
class Form {
Class beanClass;
Class validatorClass;
Validator validator;
}
I then go ahead and create a Validator
object using validatorClass.newInstance()
and store it on validator
then I create a bean object as well using beanClass.newInstance()
and add it to the session.
portletRequest.setAttribute("DynamicBean2", bean);
During the lifecycle of the Form
project, I call validator.validate()
which loads the previously created bean object from the session (I'm running Websphere Portal Server). When I try to cast this object back into a DynamicBean2
it fails with a ClassCastException.
When I pull the object back out of the session using
faces.getApplication().createValueBinding("#{DynamicBean2}").getValue(faces);
and check the class of it using .getClass()
I get dynamicbeans.DynamicBean2
. This is the class I want to cast it to however when I try I get the ClassCastException.
Any reason why I'm getting this?