-->
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.  [ 5 posts ] 
Author Message
 Post subject: java.lang.ClassCastException and Struts -Please help
PostPosted: Mon Dec 20, 2004 9:43 am 
Beginner
Beginner

Joined: Sun Sep 07, 2003 9:04 am
Posts: 48
Hibernate version:

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

I am using C:\jboss-4.0.0DR4\jboss-4.0.0DR4 and C:\j2sdk1.4.2_04.

I have relativ small code. that give me java.lang.ClassCastException, after while I decided to look for help.
Her.
*************************************************************public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws HibernateException
{
UserForm loginForm = (UserForm)form;
_RootDAO.initialize();
Session session =_RootDAO.createSession();
try {

Persons p = new Persons();
p.setFirstName("sofus");
p.setId(new Integer(2));
p.setLastName("julius");
session.save(p);
} catch (Exception e) {
e.printStackTrace();

} finally {

session.close();
}
if (loginForm.getUsererName().equals("jln")
&& loginForm.getPassword().equals("jln")) {
request.setAttribute("userName", loginForm.getUsererName());
return mapping.findForward("success");
}

return mapping.findForward("failure");

}
************************************************************
and her is hibernate.cfg.xml
************************************************************
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory">

<!-- datasource connection properties -->
<property name="connection.datasource">java:/OracleDS</property>
<!-- dialect for Oracle (any version) -->
<property name="dialect">
org.hibernate.dialect.OracleDialect
</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JBossTransactionManagerLookup
</property>
<property name="jta.UserTransaction">
java:comp/UserTransaction
</property>
<mapping resource="Persons.hbm.xml" />
<mapping resource="Reservations.hbm.xml" />
<mapping resource="Flights.hbm.xml" />
</session-factory>
</hibernate-configuration>
************************************************************
And her is the errors
*************************************************************
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

java.lang.ClassCastException
net.sf.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:34)
net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:77)
net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
src.base._BaseRootDAO.initialize(_BaseRootDAO.java:54)
src.base._BaseRootDAO.initialize(_BaseRootDAO.java:38)
com.yourcompany.struts.action.LoginAction.execute(LoginAction.java:52)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.25 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.25


Top
 Profile  
 
 Post subject: Re: java.lang.ClassCastException and Struts -Please help
PostPosted: Mon Dec 20, 2004 12:42 pm 
Beginner
Beginner

Joined: Thu Dec 16, 2004 11:54 am
Posts: 26
Location: Brussels, Belgium
Is that line
Code:
UserForm loginForm = (UserForm)form;

the line 52 of LoginAction.java as mentionned here:
Code:
com.yourcompany.struts.action.LoginAction.execute(LoginAction.java:52)

Could it be that you ClassCastException is not hibernate problem, but rather you having you struts-config wrong?


Top
 Profile  
 
 Post subject: Re: java.lang.ClassCastException and Struts -Please help
PostPosted: Tue Dec 21, 2004 5:34 am 
Beginner
Beginner

Joined: Sun Sep 07, 2003 9:04 am
Posts: 48
Thanks for your time but the line 52 is
_RootDAO.initialize();


greenhorn wrote:
Is that line
Code:
UserForm loginForm = (UserForm)form;

the line 52 of LoginAction.java as mentionned here:
Code:
com.yourcompany.struts.action.LoginAction.execute(LoginAction.java:52)

Could it be that you ClassCastException is not hibernate problem, but rather you having you struts-config wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 11:15 am 
Newbie

Joined: Tue Feb 15, 2005 7:57 am
Posts: 5
Hi seybaa !!
I have the same problem in my project. Did you find the solution to it????

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 11:57 pm 
Newbie

Joined: Mon Feb 14, 2005 12:14 am
Posts: 14
Location: Boston, USA
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JBossTransactionManagerLookup
</property>
is wrong.

It can be like this:

<property name="transaction.factory_class">
net.sf.hibernate.transaction.JTATransactionFactory
</property>
<property name="hibernate.transaction.manager_lookup_class">
net.sf.hibernate.transaction.JBossTransactionManagerLookup
</property>

You are assigning look up class the transaction factory class, that is why the classCastException.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.