These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Jboss ClassCastException
PostPosted: Thu Mar 20, 2008 2:14 pm 
Newbie

Joined: Thu Mar 20, 2008 10:11 am
Posts: 2
I've been wading through a lot of docs in this forum to figure out an exception I'm getting while trying to integrate Hibernate into my J2EE application that I'm deploying to jboss 4.2. I've got a simple pojo named Job, from which xdoclet creates the mapping document below. I create an ear file, which contains a war, and a har. It deploys fine. In my DAO code below, when I try and cast the Object to a Job, I get a ClassCastException. Even if I return it as an Object from the DAO, it just prolongs the exception, since it's raised when I cast it in the service class that calls the DAO.

I've made sure my mappings are correct. I thought this might be due to having the Job.class in my war *and* my har, but I can't seem to deploy the har with just the .hbm.xml files.

Any ideas about why this exception is being thrown?

Hibernate version: 3.2

Mapping documents:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class table="super_job" name="com.na.model.Job">
<id name="id">
<generator class="native"/>
</id>
<property name="jobType" column="job_type"/>
<property name="createdTS" column="created_ts"/>
<property name="updatedTS" column="updated_ts"/>
<property name="completedTS" column="completed_ts"/>
<property name="name" column="name"/>
<property name="description" column="description"/>
<property name="projectId" column="project_id"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Session hsession = HibernateUtil.getSession();
Job aJob = (Job)hsession.get(Job.class, id); // ***ClassCastException here***
hsession.close();
return aJob;

Full stack trace of any exception that occurs:

18:28:45,935 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
java.lang.ClassCastException: com.na.model.Job
at com.na.dao.HibernateDAO.getJob(HibernateDAO.java:40)
at com.na.SuperJob.getJob(PoyJob.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:595)


Name and version of the database you are using:

MySQL 5.0.51-2


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 3:48 pm 
Newbie

Joined: Thu Mar 20, 2008 10:11 am
Posts: 2
Come to think of it, this probably should have been posted to the jboss forums. Mea culpa.

In any event, I fixed this problem. It was a class loader issue. I took the duplicate .class files out of the war, instead of the har. This doesn't seem very intuitive, but I guess as long as they're being loaded into the JVM then who cares where they come from.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.