i succeed use the hibrnate in the mbean of jboss,but,when i operate the database ,the JSP page tell me the error(but i debug the code in the eclipse,the whole code runs ok):
the console of the jboss tell me(it seems like ok)
Code:
.....
.....
23:35:38,685 INFO [SettingsFactory] Use scrollable result sets: true
23:35:38,695 INFO [SettingsFactory] Use JDBC3 getGeneratedKeys(): false
23:35:38,695 INFO [SettingsFactory] Optimize cache for minimal puts: false
23:35:38,695 INFO [SettingsFactory] Query language substitutions: {}
23:35:38,695 INFO [SettingsFactory] cache provider: net.sf.ehcache.hibernate.Pr
ovider
23:35:38,695 INFO [Configuration] instantiating and configuring caches
23:35:38,695 INFO [SessionFactoryImpl] building session factory
but after building session factory,the JSP page tell me the error:
Code:
net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem
here is my JSP page code:
Code:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="net.sf.hibernate.SessionFactory" %>
<%@ page import="net.sf.hibernate.Session" %>
<%@ page import="net.sf.hibernate.Transaction" %>
<%!
javax.sql.DataSource ds;
SessionFactory sf;
Session objSession;
Transaction tx;
%>
<%
try {
Context ctx = new InitialContext();
out.println("start use the hibernate<br>");
sf = (SessionFactory)ctx.lookup("java:/hibernate/HibernateFactory");
objSession = sf.openSession();
tx = objSession.beginTransaction();
......
objSession.flush();
tx.commit();
out.println("end use the hibernate<br>");
} catch (Exception e) {
out.println("error!!!!!!!!!!!!!!" + e.toString());
}
%>
but i only use hibernate in the eclipse to debug without jboss,the whole code runs ok!
how does it happen!!
thanks a lot!!