开发者

Using hibernate on ejb 2.X

I've created a simple application with ejb 2X and web module. App is packaged as EAR. I want to test hibernate on ejb, but i have some problems testing on ejb-module. Test on web module works fine and I can do CRUD operations with hibernate.

The problem is when I try list from Table.

The method test on EJB throws Exception

The code

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
java.util.List list = session.createQuery("from DatosIsla").list();

The Exception deploying app

12:56:23,365 WARN  [EJBDeployer] Verify failed; continuing
java.lang.NoClassDefFoundError: org/hibernate/Session
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
    at java.lang.Class.privateGetPublicMethods(Class.java:2519)
    at java.lang.Class.getMethods(Class.java:1406)
    at org.jboss.verifier.strategy.AbstractVerifier.hasEJBCreateMethod(AbstractVerifier.java:667)
    at org.jboss.verifier.strategy.EJBVerifier20.verifySessionBean(EJBVerifier20.java:1058)
    at org.jboss.verifier.strategy.EJBVerifier20.checkSession(EJBVerifier20.java:113)
    at org.jboss.verifier.BeanVerifier.verify(BeanVerifier.java:180)
    at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:515)
    at org.jboss.deployment.MainDeployer.create(MainDeployer.java:795)
    at org.jboss.deployment.MainDeployer.create(MainDeployer.java:787)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:652)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:616)
    at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:74)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:76)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:68)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:96)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:213)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:484)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:184)
    at $Proxy7.deploy(Unknown Source)
    at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:316)
    at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:472)
    at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:213)
    at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:286)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:74)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:76)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:68)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:96)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:213)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:484)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:968)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:404)
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:74)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:76)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:68)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:96)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:213)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:484)
    at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:194)
    at sun.reflect.GeneratedMethodAccessor112.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:74)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:76)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:68)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:96)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:213)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:484)
    at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:273)
    at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:74)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:76)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:68)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:96)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:213)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:484)
    at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:179)
    at sun.reflect.GeneratedMethodAccessor103.invoke开发者_StackOverflow社区(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:74)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:76)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:68)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:96)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:213)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:484)
    at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:374)
    at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    at sun.rmi.transport.Transport$1.run(Transport.java:153)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
    at java.lang.Thread.run(Thread.java:595)

If i comment third line app is deployed fine

 SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
 Session session = sessionFactory.openSession();
 //java.util.List list = session.createQuery("from DatosIsla").list();

Whats wrong?

I'm using eclipse helios jboss 3.2.8 jboss-tools


It seems to me that the hibernate libraries are not in the classpath of the application:

java.lang.NoClassDefFoundError: org/hibernate/Session

Check in your project configuration and your launcher, that the hibernate jars are referenced. Same to the ear, are the jars included. Also check that not multiple versions are deployed (from the application container as well as in the ear).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜