-->
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 4.2 Hibernate 3.2.4sp1 Session.load ClassCastException
PostPosted: Tue May 13, 2008 8:42 am 
Beginner
Beginner

Joined: Fri May 21, 2004 5:22 am
Posts: 24
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2.4.sp1 (shipped with JBoss 4.2.2)

Mapping documents:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 29, 2008 10:21:46 AM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
    <class name="com.mycompany.uresdemo.bean.Users" table="users" catalog="uresdemo">
        <id name="loginId" type="string">
            <column name="loginID" length="20" />
            <generator class="assigned" />
        </id>
        <many-to-one name="status" class="com.mycompany.uresdemo.bean.Status" fetch="select">
            <column name="status" length="2" not-null="true">
                <comment>Record status</comment>
            </column>
        </many-to-one>
        <property name="userFirstName" type="string">
            <column name="userFirstName" length="45" not-null="true">
                <comment>User first name</comment>
            </column>
        </property>
        <property name="userLastName" type="string">
            <column name="userLastName" length="45" not-null="true">
                <comment>User last name</comment>
            </column>
        </property>
        <property name="loginPassword" type="string">
            <column name="loginPassword" not-null="true">
                <comment>Encrypted login password</comment>
            </column>
        </property>
        <property name="lastLoginDateTime" type="timestamp">
            <column name="lastLoginDateTime" length="0" not-null="true">
                <comment>User last login date time</comment>
            </column>
        </property>
        <property name="lastUpdatedDate" type="timestamp">
            <column name="lastUpdatedDate" length="0" not-null="true">
                <comment>Record last updated date time</comment>
            </column>
        </property>
        <property name="lastUpdatedBy" type="string">
            <column name="lastUpdatedBy" length="20" not-null="true">
                <comment>Record last updated person</comment>
            </column>
        </property>
        <set name="clients" inverse="true">
            <key>
                <column name="loginId" length="20" not-null="true">
                    <comment>Login ID</comment>
                </column>
            </key>
            <one-to-many class="com.mycompany.uresdemo.bean.Client" />
        </set>
        <set name="supervisors" inverse="true">
            <key>
                <column name="loginID" length="20" not-null="true">
                    <comment>Login ID</comment>
                </column>
            </key>
            <one-to-many class="com.mycompany.uresdemo.bean.Supervisor" />
        </set>
    </class>
</hibernate-mapping>


Note:

This mapping file is deployed under SAR in JBOSS/default/deploy together with class file.

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

Code:
public Users findById(java.lang.String id) {
      log.debug("getting Users instance with id: " + id);
      try {
         Object obj = getSessionInstance().get(Users.class, id);
         Users instance = (obj instanceof Users ? (Users) obj : null);
         if (instance == null) {
            log.debug("get successful, no instance found");
         } else {
            log.debug("get successful, instance found");
         }
         return instance;
      } catch (RuntimeException re) {
         log.error("get failed", re);
         throw re;
      }
   }


Note:

When I ran under debugger mode, i always end up instance is NULL. Both obj and Users objects are same package.

Full stack trace of any exception that occurs:

Quote:
20:24:14,776 INFO [STDOUT] Hibernate: select users0_.loginID as loginID13_, use
rs0_.status as status13_, users0_.userFirstName as userFirs3_13_, users0_.userLa
stName as userLast4_13_, users0_.loginPassword as loginPas5_13_, users0_.lastLog
inDateTime as lastLogi6_13_, users0_.lastUpdatedDate as lastUpda7_13_, users0_.l
astUpdatedBy as lastUpda8_13_ from uresdemo.users users0_ where users0_.loginID=
?
20:24:24,348 ERROR [UsersHome] get failed
java.lang.ClassCastException: com.mycompany.uresdemo.bean.Users cannot be cast
to com.mycompany.uresdemo.bean.Users
at com.mycompany.uresdemo.home.UsersHome.findById(UsersHome.java:49)
at com.mycompany.uresdemo.logic.impl.URESDemoBusinessImpl.execLoginAtte
mpt(URESDemoBusinessImpl.java:201)
at com.mycompany.uresdemo.logic.impl.URESDemoBusinessImpl.execLoginAtte
mpt(URESDemoBusinessImpl.java:186)
at com.mycompany.uresdemo.logic.impl.URESDemoBusinessImpl.loginAttempt(
URESDemoBusinessImpl.java:164)
at com.mycompany.uresdemo.mobile.servlet.URESDemoUplink.execDoPost(URES
DemoUplink.java:85)
at com.mycompany.uresdemo.mobile.servlet.URESDemoUplink.doPost(URESDemo
Uplink.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
onnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
6)
at java.lang.Thread.run(Thread.java:619)
20:24:24,384 ERROR [[URESDemoUplink]] Servlet.service() for servlet URESDemoUpli
nk threw exception
java.lang.ClassCastException: com.mycompany.uresdemo.bean.Users cannot be cast
to com.mycompany.uresdemo.bean.Users
at com.mycompany.uresdemo.home.UsersHome.findById(UsersHome.java:49)
at com.mycompany.uresdemo.logic.impl.URESDemoBusinessImpl.execLoginAtte
mpt(URESDemoBusinessImpl.java:201)
at com.mycompany.uresdemo.logic.impl.URESDemoBusinessImpl.execLoginAtte
mpt(URESDemoBusinessImpl.java:186)
at com.mycompany.uresdemo.logic.impl.URESDemoBusinessImpl.loginAttempt(
URESDemoBusinessImpl.java:164)
at com.mycompany.uresdemo.mobile.servlet.URESDemoUplink.execDoPost(URES
DemoUplink.java:85)
at com.mycompany.uresdemo.mobile.servlet.URESDemoUplink.doPost(URESDemo
Uplink.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
onnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
6)
at java.lang.Thread.run(Thread.java:619)


Name and version of the database you are using: MySQL 5.0

The generated SQL (show_sql=true): Stated in stack trace above

Debug level Hibernate log excerpt: ?

What is wrong? I been using Jboss classloader configuration before but I need to load some other tomcat class. How should i resolve this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 12:28 pm 
Beginner
Beginner

Joined: Fri May 21, 2004 5:22 am
Posts: 24
I had posted cross link to http://forum.hibernate.org/viewtopic.ph ... 11#2385111


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.