0 Replies Latest reply on Oct 15, 2008 5:20 PM by chahua wang

    javax.naming.NameNotFoundException: hibernate not bound

    chahua wang Newbie

      Hi Folks,

      I tried to setup junit test in the eclipse.

      But I got the following exception in the test:


      the exception is threw from here in the test case.

      new InitialContext().lookup("java:/hibernate/SessionFactory");

      javax.naming.NameNotFoundException: hibernate not bound

      in the jboss i need to have
      hibernate-service.xml. my application runs correctly in the Jboss.

      but in the test case, how to steup SessionFactory, so hibernate cab be bound?

      something like System.setProperty("SessionFactoryName,"java:/hibernate/SessionFactory");?


      Please help. Thank you,

      Chaohua


      This is a hibernate-service.xml file

      <server>
       <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
       <attribute name="DatasourceName">java:/RewardsDS</attribute>
       <attribute name="Dialect">org.hibernate.dialect.SQLServerDialect</attribute>
       <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
       <atttribute name="transaction.manager_lookup_class">
       org.hibernate.transaction.JBossTransactionManagerLookup</atttribute>
       <attribute name="CacheProviderClass">
       org.hibernate.cache.HashtableCacheProvider
       </attribute>
       <attribute name="QueryCacheEnabled">true</attribute>
       </mbean>
      </server>
      




      [main] ERROR net.ussouth.incomm.postpay.rewards.dataPersistence.access.RewardDAO - Could not locate SessionFactory in JNDI

      at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
      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: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:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at net.ussouth.incomm.postpay.rewards.dataPersistence.access.RewardDAO.getSessionFactory(RewardDAO.java:27)