Hi, I use hibernate in jboss3.2.6 and Mysql4.0.18.
I got an exception in jboss while using the hibernate session object in a session bean.
The Exception:
Quote:
2004-10-20 20:47:46,573 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=40288183ffb608fd00ffb608ff9c0000
2004-10-20 20:47:46,573 DEBUG [net.sf.hibernate.impl.SessionImpl] opened session
2004-10-20 20:47:47,574 INFO [STDOUT] net.sf.hibernate.MappingException: No persister for: com.gumreal.hibernate.TestHiber
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:345)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2686)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2693)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:763)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at com.gumreal.ejb.EjbForHibernate.HiberClientBean.getName(HiberClientBean.java:45)
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:324)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:111)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
at org.jboss.ejb.Container.invoke(Container.java:709)
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:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
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:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] flushing session
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushing entities and processing referenced collections
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] Processing unreferenced collections
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] Scheduling collection removes/(re)creates/updates
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] executing flush
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] post flush
2004-10-20 20:47:47,785 DEBUG [net.sf.hibernate.impl.SessionImpl] closing session
2004-10-20 20:48:01,795 DEBUG [net.sf.hibernate.impl.SessionImpl] running Session.finalize()
The session method:
Code:
import com.gumreal.hibernate.TestHiber;
......
public String getName()throws java.rmi.RemoteException{
Session session = HibernateContext.getSession("java:/hibernate/SessionFactory");
TestHiber testHiber = new TestHiber();
//testHiber.setName("hiber name");
//testHiber.setId(new Integer(3));
try{
session.load(testHiber,new Integer(1));
//session.save(testHiber);
return testHiber.getName();
}catch(Exception e){
e.printStackTrace();
}
return "failed.";
}
The structure of my HAR file is:
-com
---gumreal
------hibernate
---------TestHiber.class
-META-INF
---hibernate-service.xml
---TestHiber.hbm
The content in TestHiber.hbm is:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.gumreal.hibernate">
<class name="TestHiber" table="test_hiber">
<id
column="id"
name="Id"
type="integer"
>
<generator class="vm" />
</id>
<property
column="name"
length="100"
name="Name"
not-null="true"
type="string"
/>
</class>
</hibernate-mapping>
I am sure that HibernateSessionFactory MBean and Datasource had been started successfully. And how to add the hbm file to the HibernateSessionFactory? Thanks for your help:)