Announcement Announcement Module
Collapse
No announcement yet.
problem with ejb+spring+hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem with ejb+spring+hibernate

    hi,all
    i am now using ejb(slsb)+spring+dao(hibernate).
    my work directory is as follow:
    TestEjb/META-INF/MANIFEST.MF(not have anything)
    /META-INF/ejb-jar.xml,jboss.xml......
    TestEjb/lib/all the jars which hibernate uses
    /lib/all the jars which spring uses(of course include commons- clllictions.jar)
    /lib/all the jars about database and other
    TestEjb/com/......all the classes i uses in my test
    TestEjb/beanRefContext.xml
    /spring-context.xml
    when i dont use dao,i run my test successfully,at this time spring-context.xml file just inclue datasource:
    <bean id="mysqlDataSource"
    class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>java:MySqlDS</value>
    </property>
    </bean>
    but when i added the following to this file,errors occured:
    <bean id="mysqlSessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource">
    <ref local="mysqlDataSource" />
    </property>
    <property name="mappingResources">
    <list>
    <value>com/test/test.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.M ySQLDialect</prop>
    <prop key="hibernate.query.substitutions">true=1 false=0</prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    </bean>
    error is as follow:
    14:45:42,177 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from file [E:\eclipse\workspace\EjbTestClient\src\test.xml]
    14:45:42,757 INFO [FileSystemXmlApplicationContext] Bean factory for application context [org.springframework.context.support.FileSystemXmlA pplicationContext;hashCode=12893404]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [userManagerService]; Root of BeanFactory hierarchy
    14:45:42,757 INFO [FileSystemXmlApplicationContext] 1 beans defined in ApplicationContext [org.springframework.context.support.FileSystemXmlA pplicationContext;hashCode=12893404]
    14:45:42,773 INFO [FileSystemXmlApplicationContext] No MessageSource found for context [org.springframework.context.support.FileSystemXmlA pplicationContext;hashCode=12893404]: using empty default
    14:45:42,773 INFO [FileSystemXmlApplicationContext] No ApplicationEventMulticaster found for context [org.springframework.context.support.FileSystemXmlA pplicationContext;hashCode=12893404]: using default
    14:45:42,773 INFO [FileSystemXmlApplicationContext] Refreshing listeners
    14:45:42,789 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [userManagerService]; Root of BeanFactory hierarchy]
    14:45:42,789 INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'userManagerService'
    14:45:43,244 INFO [SimpleRemoteStatelessSessionProxyFactoryBean] Located object with JNDI name [UserManager]: value=[UserManagerHome]
    14:45:43,275 INFO [CollectionFactory] Using JDK 1.4 collections
    Exception in thread "main" org.springframework.remoting.RemoteAccessException : Cannot access remote service [UserManager]; nested exception is java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.ServerException: EJBException:; nested exception is:
    javax.ejb.EJBException: null; CausedByException is:
    Error creating bean with name 'servicelayer-context' defined in URL [jar:file:/D:/jboss4/server/default/tmp/deploy/tmp52859SwanEjb.jar!/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.FatalBeanException: Could not instantiate class [org.springframework.context.support.ClassPathXmlAp plicationContext]; constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mysqlSessionFactory' defined in class path resource [spring-system.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.ServerException: EJBException:; nested exception is:
    javax.ejb.EJBException: null; CausedByException is:
    Error creating bean with name 'servicelayer-context' defined in URL [jar:file:/D:/jboss4/server/default/tmp/deploy/tmp52859SwanEjb.jar!/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.FatalBeanException: Could not instantiate class [org.springframework.context.support.ClassPathXmlAp plicationContext]; constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mysqlSessionFactory' defined in class path resource [spring-system.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:325)
    at sun.rmi.transport.Transport$1.run(Transport.java:1 53)
    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:460)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:701)
    at java.lang.Thread.run(Thread.java:595)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(StreamRemoteCall.java:247)
    at sun.rmi.transport.StreamRemoteCall.executeCall(Str eamRemoteCall.java:223)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:1 26)
    at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub. invoke(Unknown Source)
    at org.jboss.invocation.jrmp.interfaces.JRMPInvokerPr oxy.invoke(JRMPInvokerProxy.java:118)
    at org.jboss.invocation.InvokerInterceptor.invoke(Inv okerInterceptor.java:96)
    at org.jboss.proxy.TransactionInterceptor.invoke(Tran sactionInterceptor.java:46)
    at org.jboss.proxy.SecurityInterceptor.invoke(Securit yInterceptor.java:55)
    at org.jboss.proxy.ejb.StatelessSessionInterceptor.in voke(StatelessSessionInterceptor.java:97)
    at org.jboss.proxy.ClientContainer.invoke(ClientConta iner.java:86)
    at $Proxy2.getUser(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.springframework.remoting.rmi.RmiClientIntercep torUtils.doInvoke(RmiClientInterceptorUtils.java:9 8)
    at org.springframework.ejb.access.SimpleRemoteSlsbInv okerInterceptor.doInvoke(SimpleRemoteSlsbInvokerIn terceptor.java:73)
    at org.springframework.ejb.access.AbstractRemoteSlsbI nvokerInterceptor.invoke(AbstractRemoteSlsbInvoker Interceptor.java:72)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
    at $Proxy1.getUser(Unknown Source)
    at com.rusty.test.ejb.UserManagerSpringTest.main(User ManagerSpringTest.java:27)
    Caused by: java.rmi.ServerException: EJBException:; nested exception is:
    javax.ejb.EJBException: null; CausedByException is:
    Error creating bean with name 'servicelayer-context' defined in URL [jar:file:/D:/jboss4/server/default/tmp/deploy/tmp52859SwanEjb.jar!/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.FatalBeanException: Could not instantiate class [org.springframework.context.support.ClassPathXmlAp plicationContext]; constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mysqlSessionFactory' defined in class path resource [spring-system.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
    at org.jboss.ejb.plugins.LogInterceptor.handleExcepti on(LogInterceptor.java:347)
    at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInt erceptor.java:195)
    at org.jboss.ejb.plugins.ProxyFactoryFinderIntercepto r.invoke(ProxyFactoryFinderInterceptor.java:122)
    at org.jboss.ejb.SessionContainer.internalInvoke(Sess ionContainer.java:624)
    at org.jboss.ejb.Container.invoke(Container.java:854)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invok e(ReflectedDispatcher.java:141)
    at org.jboss.mx.server.Invocation.dispatch(Invocation .java:80)
    at org.jboss.mx.server.Invocation.invoke(Invocation.j ava:72)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(Ab stractMBeanInvoker.java:242)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanSe rverImpl.java:642)
    at org.jboss.invocation.jrmp.server.JRMPInvoker$MBean ServerAction.invoke(JRMPInvoker.java:775)
    at org.jboss.invocation.jrmp.server.JRMPInvoker.invok e(JRMPInvoker.java:382)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:294)
    at sun.rmi.transport.Transport$1.run(Transport.java:1 53)
    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:460)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:701)
    at java.lang.Thread.run(Thread.java:595)

  • #2
    Seems like the commons-collections.jar is missing in your classpath.

    Regards,
    Andreas

    P.S.: Please format your postings more reader-friendly

    Comment


    • #3
      yeah,i think it seems like commons-collections.jar is not in my classpath too.But i want to know why????????
      As i descriped above,i put all jars in TestEjb/lib directory already.
      I think maybe /META-INF/menifest.mf file is wrong.My menifest.mf file has nothing.(I think it should have somthing,but it will run successfully with just spring and ejb).So who can tell me how to write this file?
      Spring-context.xml file is as follow:
      <bean id="mysqlDataSource"
      class="org.springframework.jndi.JndiObjectFactoryB ean">
      <property name="jndiName">
      <value>java:MySqlDS</value>
      </property>
      </bean>

      <bean id="mysqlSessionFactory"
      class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
      <property name="dataSource">
      <ref local="mysqlDataSource"/>
      </property>
      <property name="configLocation">
      <value>classpath:hibernate.cfg.xml</value>
      </property>
      </bean>

      Comment


      • #4
        my xml is:

        <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
        <property name="jndiName">
        <value>EmsDataSource</value>
        </property>
        </bean>
        <!-- Hibernate SessionFactory -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
        <property name="dataSource"><ref bean="dataSource"/></property>
        <property name="mappingResources">
        <list>
        <value>com/xxx/bo/resource/Xxx.hbm.xml</value>
        </list>
        </property>
        <property name="hibernateProperties">
        <props>
        <prop key="hibernate.dialect">net.sf.hibernate.dialect.I nformixDialect</prop>
        <prop key="hibernate.show_sql">false</prop>
        <prop key="hibernate.cglib.use_reflection_optimizer">tru e</prop>
        <prop key="hibernate.cache.provider_class">net.sf.hibern ate.cache.HashtableCacheProvider</prop>
        <!--prop key="hibernate.hbm2ddl.auto">update</prop-->
        </props>
        </property>
        </bean>

        I hope it is useful for you.

        Comment

        Working...
        X