ClassCastException - revisited
aradka Feb 20, 2004 4:09 PMI've seen allot of posts on this general topic, but it seems what I am doing is so basic, I'm hoping it's just a 'moment' and I'm just not packaging everything correctly.
I am trying to connect to an ejb deployed in another ear. I have ALWAYS gotten ClassCastExceptions but I've always been able to just put my ejb's and wars in the same ear, and it would work. Now I really need to seperate everything.
I'm using jboss-3.2.3, hibernate-2.1, and xdoclet-1.2. No errors at deployment time of either ear.
My ejb's are deployed in hibernate-repository.ear
META-INF/
META-INF/MANIFEST.MF
mv.jar <----- hibernate POJO's
hibernate-repository.sar <----- hibernate mapping files
hibernate-service.jar <----- wrapper session bean
.
.other hibernate libraries.
.
META-INF/jboss-app.xml
META-INF/application.xml
Session bean interfaces and util are created with Xdoclet.
application.xml is pretty standard
jboss-app.xml
<jboss-app>
<loader-repository>hibernate:loader=hibernate.ear</loader-repository>
hibernate-repository.sar
</jboss-app>
My client is in mv-test.ear
META-INF/
META-INF/MANIFEST.MF
mv.jar <----same as in hibernate-service.ear
hibernate-interface.jar <----interface and util classes created by xdoclet
mv-test.war <----webworks client
META-INF/application.xml
META-INF/jboss-app.xml
jboss-app.xml
<jboss-app>
<loader-repository>mv-test:loader=mv-test.war</loader-repository>
</jboss-app>
Here's where I try to access a session bean in my action class
try {
// obtain sesison bean
IHibernateService hs = HibernateServiceUtil.getHome().create();
org = ( Orginization ) hs.load( Orginization.class, new Long(1) );
}
catch( Exception ex )
{
_log.error( "exception: ", ex );
}
}
Here's the code that throws the ClassCastException (created by xdoclet)
HibernateServiceUtil.java
public static com.rubicon.repository.hibernate.IHibernateServiceHome getHome() throws javax.naming.NamingException
{
if (cachedRemoteHome == null) {
cachedRemoteHome = (com.rubicon.repository.hibernate.IHibernateServiceHome) lookupHome(null, com.rubicon.repository.hibernate.IHibernateServiceHome.JNDI_NAME, com.rubicon.repository.hibernate.IHibernateServiceHome.class);
}
return cachedRemoteHome;
}
Let's see what else....
xdoclet from HibernateServiceEJB.java
/**
* @created December 12, 2002
* @ejb.bean name="HibernateService" type="Stateless" view-type="remote"
* description="hibernate service"
* jndi-name="ejb/HibernateService"
* @ejb.util generate="physical"
* @ejb.permission unchecked="true"
* @ejb.transaction type="Required"
*/
O.K. that's all I can thin k of that would be relevant. What am I doing wrong???!!!
Thanks,
Alex