3 Replies Latest reply on Feb 18, 2004 5:47 PM by somsackt

    hibernate not bound

    eric g Newbie

      Dear all,

      I got the following messages when I issued standalone client Jndi look up to look for
      java:/hibernate/HibernateFactory

      javax.naming.NameNotFoundException: hibernate not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)

      jndi view from jboss seems to indicate jndi successfully employed using sar as per hibernate JMX mbean installed method


      java: Namespace
      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
      +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
      +- PostgresDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
      +- DefaultJMSProvider (class: org.jboss.jms.jndi.JBossMQProvider)
      +- comp (class: javax.naming.Context)
      +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- jaas (class: javax.naming.Context)
      | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
      +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=null
      +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
      +- Mail (class: javax.mail.Session)
      +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
      +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
      +- TransactionManager (class: org.jboss.tm.TxManager)
      +- hibernate (class: org.jnp.interfaces.NamingContext)
      | +- HibernateFactory (class: net.sf.hibernate.impl.SessionFactoryImpl)
      +- MSSQLDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)


      jboss log out related to sar file employed

      15:17:24,457 INFO [Environment] Hibernate 2.1 beta 5
      15:17:24,487 INFO [Environment] hibernate.properties not found
      15:17:24,507 INFO [Environment] using CGLIB reflection optimizer
      15:17:24,527 INFO [Configuration] Mapping resource: src/grp.hbm.xml
      15:17:25,128 INFO [Binder] Mapping class: src.grp -> grp
      15:17:25,548 INFO [Configuration] Mapping resource: src/codemaster.hbm.xml
      15:17:25,659 INFO [Binder] Mapping class: src.codemaster -> codemaster
      15:17:25,669 INFO [Configuration] processing one-to-many association mappings
      15:17:25,669 INFO [Binder] Mapping collection: src.grp.codemaster -> codemaster
      15:17:25,679 INFO [Configuration] processing one-to-one association property references
      15:17:25,679 INFO [Configuration] processing foreign key constraints
      15:17:25,779 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.PostgreSQLDialect
      15:17:25,779 INFO [SettingsFactory] Use outer join fetching: false
      15:17:25,809 INFO [NamingHelper] JNDI InitialContext properties:{}
      15:17:25,829 INFO [DatasourceConnectionProvider] Using datasource: java:/PostgresDS
      15:17:25,849 INFO [TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
      15:17:25,869 INFO [NamingHelper] JNDI InitialContext properties:{}
      15:17:25,879 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
      15:17:25,899 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      15:17:25,909 INFO [NamingHelper] JNDI InitialContext properties:{}
      15:17:25,909 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
      15:17:25,909 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      15:17:26,920 INFO [SettingsFactory] Use scrollable result sets: true
      15:17:26,920 INFO [SettingsFactory] JDBC 2 max batch size: 15
      15:17:26,920 INFO [SettingsFactory] echoing all SQL to stdout
      15:17:26,930 INFO [SettingsFactory] Query language substitutions: {}
      15:17:26,930 INFO [SettingsFactory] cache provider: net.sf.hibernate.cache.JCSCacheProvider
      15:17:26,940 INFO [Configuration] instantiating and configuring caches
      15:17:27,341 INFO [SessionFactoryImpl] building session factory
      15:17:28,062 INFO [SessionFactoryObjectFactory] Factory name: java:/hibernate/HibernateFactory
      15:17:28,062 INFO [NamingHelper] JNDI InitialContext properties:{}
      15:17:28,072 INFO [NamingHelper] Creating subcontext: hibernate
      15:17:28,072 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:/hibernate/HibernateFactory
      15:17:28,072 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
      15:17:28,072 INFO [NamingHelper] JNDI InitialContext properties:{}


      extract of the standalone clinet issuing the lookup

      try{
      Context ctxh=new InitialContext();
      env=ctxh.getEnvironment();
      System.out.println(env);
      Object oHiber;
      oHiber=ctxh.lookup("java:/hibernate/HibernateFactory");
      SessionFactory factory=(SessionFactory)PortableRemoteObject.narrow(oHiber,SessionFactory.class);
      System.out.println("factory= "+factory);
      Session session=factory.openSession();
      Transaction tx=null;
      try{tx=session.beginTransaction();


      messages and error related to initial context
      {java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.provider.url=OPSMERP1:1099, jnp.timeout=0, jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces, jnp.sotimeout=0}
      javax.naming.NameNotFoundException: hibernate not bound


      I have no idea why this is so , could somebody help me to resolve this?

      the same hibernate configuration xml mapping files work fine using client programme with jndi look up as well as hibernator 0.96 in the eclipse environment.


      Thanks in advance

        • 1. Re: hibernate not bound
          Adrian Brock Master

          You cannot access java:/
          from outside the virtual machine

          Regards,
          Adrian

          • 2. Re: hibernate not bound
            eric g Newbie

            Dear Adrian,


            thanks for your reply, I have in fact wrap the hibernater jndi lookup using a stateless session bean and local interface concept to perform the Hibenate jndi lookup but met with partial success as the following shown.


            {java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.provider.url=localhost:1099, jnp.timeout=0, jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces, jnp.sotimeout=0}
            RelHome
            RelHome
            home1=RelHome
            rnate.impl.SessionFactoryImpl - deserializing
            ----------------------------------------------------------------

            jboss log out indicate jndi successfully bond


            10:40:36,193 INFO [TxConnectionManager] Started jboss.jca:service=LocalTxCM,name=PostgresDS
            10:40:36,193 INFO [HibernateServiceMBean] starting service at JNDI name: java:/HibernateFactory
            10:40:36,193 INFO [HibernateServiceMBean] service properties: {hibernate.session_factory_name=java:/HibernateFactory, hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup, hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect, hibernate.show_sql=true, hibernate.use_outer_join=false, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory, hibernate.connection.datasource=java:/PostgresDS}
            10:40:36,353 INFO [Environment] Hibernate 2.1 rc1
            10:40:36,383 INFO [Environment] hibernate.properties not found
            10:40:36,413 INFO [Environment] using CGLIB reflection optimizer
            10:40:36,423 INFO [Configuration] Mapping resource: src/grp.hbm.xml
            10:40:37,124 INFO [Binder] Mapping class: src.grp -> grp
            10:40:37,525 INFO [Configuration] Mapping resource: src/codemaster.hbm.xml
            10:40:37,625 INFO [Binder] Mapping class: src.codemaster -> codemaster
            10:40:37,635 INFO [Configuration] processing one-to-many association mappings
            10:40:37,635 INFO [Binder] Mapping collection: src.grp.codemaster -> codemaster
            10:40:37,645 INFO [Configuration] processing one-to-one association property references
            10:40:37,645 INFO [Configuration] processing foreign key constraints
            10:40:37,745 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.PostgreSQLDialect
            10:40:37,745 INFO [SettingsFactory] Use outer join fetching: false
            10:40:37,775 INFO [NamingHelper] JNDI InitialContext properties:{}
            10:40:37,795 INFO [DatasourceConnectionProvider] Using datasource: java:/PostgresDS
            10:40:37,815 INFO [TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
            10:40:37,825 INFO [NamingHelper] JNDI InitialContext properties:{}
            10:40:37,845 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
            10:40:37,865 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
            10:40:37,865 INFO [NamingHelper] JNDI InitialContext properties:{}
            10:40:37,865 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
            10:40:37,865 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
            10:40:40,619 INFO [SettingsFactory] Use scrollable result sets: true
            10:40:40,619 INFO [SettingsFactory] JDBC 2 max batch size: 15
            10:40:40,629 INFO [SettingsFactory] echoing all SQL to stdout
            10:40:40,629 INFO [SettingsFactory] Query language substitutions: {}
            10:40:40,629 INFO [SettingsFactory] cache provider: net.sf.ehcache.hibernate.Provider
            10:40:40,659 INFO [Configuration] instantiating and configuring caches
            10:40:41,080 INFO [SessionFactoryImpl] building session factory
            10:40:41,961 INFO [SessionFactoryObjectFactory] Factory name: java:/HibernateFactory
            10:40:41,961 INFO [NamingHelper] JNDI InitialContext properties:{}
            10:40:41,961 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:/HibernateFactory
            10:40:41,971 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
            10:40:41,971 INFO [NamingHelper] JNDI InitialContext properties:{}


            partial Rel session bean look up to test the factory look up only


            try {
            Context ctxh = new InitialContext();
            Hashtable env = ctxh.getEnvironment();
            Object oHiber;

            oHiber = ctxh.lookup("java:/HibernateFactory");

            //factory=(SessionFactory)PortableRemoteObject.narrow(oHiber,SessionFactory.class);
            SessionFactory factory = (SessionFactory) oHiber;
            System.out.println("factory= " + factory);
            harr.add(factory);

            session = factory.openSession();
            tx = session.beginTransaction();
            }

            //---- catch exception errors

            ---------------------------------------------------

            partial client session bean look up procedure

            public void GetCon2() {
            try {
            Context ctx1 = new InitialContext();
            env = ctx1.getEnvironment();

            Object oRef1;
            Object oRef2;

            System.out.println(env);
            oRef1 = ctx1.lookup("Rel");
            System.out.println(oRef1);


            System.out.println(oRef1);

            RelHome home1 = (RelHome) PortableRemoteObject.narrow(oRef1,
            RelHome.class);
            System.out.println("home1=" + home1);
            Rel remote1;
            remote1 = home1.create();
            System.out.println("result=" + remote1.HiberData());
            }///
            etc ....

            I also got the following messages from the jboss log output , where the harr is the ArrayList return from the session bean indicating the sql works and at least something for the session factory

            17:39:03,100 INFO [STDOUT] factory= net.sf.hibernate.impl.SessionFactoryImpl@1c047f017:39:04,111 INFO [STDOUT] Hibernate: select grp0_.grpcode as grpcode, grp0_.grpdesp as grpdesp from grp grp0_ limit ?
            17:39:04,602 INFO [STDOUT] harr =[net.sf.hibernate.impl.SessionFactoryImpl@1c047f0]


            But
            I could not understand the following errors from Eclipse


            {java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.provider.url=localhost:1099, jnp.timeout=0, jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces, jnp.sotimeout=0}
            RelHome
            RelHome
            home1=RelHome
            0 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionFactoryImpl - deserializing
            20 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionFactoryImpl - deserialized: 4028819af93126a000f93126a4f40000
            30 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionFactoryImpl - Resolving serialized SessionFactory
            30 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
            60 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionFactoryObjectFactory - lookup: uid=4028819af93126a000f93126a4f40000
            60 [AWT-EventQueue-0] WARN net.sf.hibernate.impl.SessionFactoryObjectFactory - Not found: 4028819af93126a000f93126a4f40000
            60 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionFactoryObjectFactory - {}
            60 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionFactoryObjectFactory - lookup: name=java:/HibernateFactory
            60 [AWT-EventQueue-0] WARN net.sf.hibernate.impl.SessionFactoryObjectFactory - Not found: java:/HibernateFactory
            60 [AWT-EventQueue-0] DEBUG net.sf.hibernate.impl.SessionFactoryObjectFactory - {}


            java.io.InvalidObjectException: Could not find a SessionFactory named: java:/HibernateFactory at net.sf.hibernate.impl.SessionFactoryImpl.readResolve(SessionFactoryImpl.java:393)
            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 java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:925)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1655)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
            at java.util.ArrayList.readObject(ArrayList.java:547)
            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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)
            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
            at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
            at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:136)
            at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
            at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
            at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
            at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
            at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
            at $Proxy1.HiberData(Unknown Source)
            at javaPrg.MSSC_MENU.GetCon2(MSSC_MENU.java:583)
            at javaPrg.MSSC_MENU$3.actionPerformed(MSSC_MENU.java:130)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
            at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
            at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
            at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
            at java.awt.Component.processMouseEvent(Component.java:5100)
            at java.awt.Component.processEvent(Component.java:4897)
            at java.awt.Container.processEvent(Container.java:1569)
            at java.awt.Component.dispatchEventImpl(Component.java:3615)
            at java.awt.Container.dispatchEventImpl(Container.java:1627)
            at java.awt.Component.dispatchEvent(Component.java:3477)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
            at java.awt.Container.dispatchEventImpl(Container.java:1613)
            at java.awt.Window.dispatchEventImpl(Window.java:1606)
            at java.awt.Component.dispatchEvent(Component.java:3477)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)




            After analysing the error output , I may be correct to say that the java:/HibernateFactory has been properly located for but just could not understand all those warning output by the eclipse.

            The other thing that puzzle me is that , if my hibernate xml mapping files and jboss-service are packages as SAR and installed as bean , How do I located the classes packaged with the SAR files ?

            What am I intend to do is to make use of the session bean to perform the hibernate transaction call via session bean remote interface , so that external programme could make call to the session bean


            But I just run out of idea on how to accessing the relevant class pack inside the SAR files

            Could anyone provide guidance pls?


            Thanks









            • 3. Re: hibernate not bound
              somsackt Newbie

              Hi, I've recently started working with Hibernate and using it as a service in JBoss and I'm encountering similar errors as those mentioned here.

              I was wondering if you found out what your troubles were and if it isn't too much trouble, would you please post what you found out.

              But if you're still stuck, and I figure something out, I'll post my findings.

              Thanks,
              Somsack Tsai