- This topic has 3 replies, 2 voices, and was last updated 20 years ago by Riyad Kalla.
-
AuthorPosts
-
jeanlucnobourgMemberI used C:\jboss-4.0.0DR4\jboss-4.0.0DR4;
and C:\j2sdk1.4.2_04.
Here is my java file.
*************************************************************
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.2/xslt/JavaClass.xslpackage com.yourcompany.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import src.Persons;
import src.dao._RootDAO;import com.yourcompany.struts.form.UserForm;
/**
* MyEclipse Struts Creation date: 11-15-2004
*
* XDoclet definition:
*
* @struts:action path=”/login” name=”loginForm” input=”/ogin.jsp”
* scope=”request” validate=”true”
* @struts:action-forward name=”succes” path=”/Login.jsp”
* @struts:action-forward name=”failure” path=”/UserLogin.jsp”
*/
public class LoginAction extends Action {// ——————————————————— Instance
// Variables// ——————————————————— Methods
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
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”);
}
}
*************************************************************
Her is my hibernate.cfg.xml
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.2/xslt/JavaClass.xslpackage com.yourcompany.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import src.Persons;
import src.dao._RootDAO;import com.yourcompany.struts.form.UserForm;
/**
* MyEclipse Struts Creation date: 11-15-2004
*
* XDoclet definition:
*
* @struts:action path=”/login” name=”loginForm” input=”/ogin.jsp”
* scope=”request” validate=”true”
* @struts:action-forward name=”succes” path=”/Login.jsp”
* @struts:action-forward name=”failure” path=”/UserLogin.jsp”
*/
public class LoginAction extends Action {// ——————————————————— Instance
// Variables// ——————————————————— Methods
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
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”);
}
}
************************************************************
Her is my struts config//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.2/xslt/JavaClass.xslpackage com.yourcompany.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import src.Persons;
import src.dao._RootDAO;import com.yourcompany.struts.form.UserForm;
/**
* MyEclipse Struts Creation date: 11-15-2004
*
* XDoclet definition:
*
* @struts:action path=”/login” name=”loginForm” input=”/ogin.jsp”
* scope=”request” validate=”true”
* @struts:action-forward name=”succes” path=”/Login.jsp”
* @struts:action-forward name=”failure” path=”/UserLogin.jsp”
*/
public class LoginAction extends Action {// ——————————————————— Instance
// Variables// ——————————————————— Methods
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
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”);
}
}
************************************************************
Her is the errors
5:31:27,912 INFO [NamingHelper] JNDI InitialContext properties:{}
15:31:27,962 INFO [DatasourceConnectionProvider] Using datasource: java:/OracleDS
15:31:27,972 INFO [TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JBossTransactionManagerLookup
15:31:28,052 WARN [RequestProcessor] Unhandled Exception thrown: class java.lang.ClassCastException
15:31:28,082 ERROR [Engine] StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
java.lang.ClassCastException
at net.sf.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:34)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:77)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
at src.base._BaseRootDAO.initialize(_BaseRootDAO.java:54)
at src.base._BaseRootDAO.initialize(_BaseRootDAO.java:38)
at com.yourcompany.struts.action.LoginAction.execute(LoginAction.java:52)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:277)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:80)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:122)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
at java.lang.Thread.run(Thread.java:534)
Riyad KallaMemberjava.lang.ClassCastException
at net.sf.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:34)This looks like a hibernate exception… any idea why it would die trying to create your TransactionFactory? What does your hibernate config file look like?
jeanlucnobourgMemberHere is my 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>
<!– datasource connection properties –>
<property name=”connection.datasource”>java:/OracleDS</property>
<!– dialect for Oracle (any version) –>
<property name=”dialect”>
or.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>@support-rkalla wrote:
java.lang.ClassCastException
at net.sf.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:34)This looks like a hibernate exception… any idea why it would die trying to create your TransactionFactory? What does your hibernate config file look like?
Riyad KallaMemberFew things:
1) Shouldn’t your datasource start with: java:/comp/env
2) Shouldn’t your dialog be “org.XXXXX” instead of “or.XXXXX”
3) Did you remove any of the JARs that MyEclipse adds to your project when you add Hibernate capabilities?
4) Your mapping sources should be in packages with your Java classes, which means they should look more like:
<mapping resource=”com.test.Persons.hbm.xml” />Either I’m missing something, or this application is currently very broken.
-
AuthorPosts