1 Reply Latest reply on Jun 22, 2008 1:55 AM by lmc_paul

    JBOSS4.2 with spring hibernate JNDI

    lmc_paul

      I USE THE SPRING,HIBERNATE WITH JNDI ,the problems follows:

      IN THE APPLICATION.XML deploy like this:



      com/moreflurish/domain/article/InfoArticle.hbm.xml




      net.sf.hibernate.dialect.MySQLDialect
      true
      hibernateJNDI
      <!--prop key="hibernate.connection.datasource">jdbc/moreflurish</prop-->
      java:/moreflurish





      client application :

      public static void main(String[] args) {
      // TODO Auto-generated method stub
      try {
      Properties prop = new Properties();
      prop.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      prop.setProperty("java.naming.provider.url", "jnp://localhost:1099");
      prop.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      InitialContext ctx = new InitialContext(prop);
      System.out.println("111111111111");
      //IMyBean bean = ( IMyBean) ctx.lookup("MyBean/remote");
      //bean.dosomething();
      //Object obj = bean.getHibernateJndI();
      //System.out.println(obj);
      //SessionFactory sf = (SessionFactory)obj;
      Object obj = ctx.lookup("hibernateJNDI");
      System.out.println(obj);
      } catch (NamingException e) {
      e.printStackTrace();
      }

      }



      results ::::

      2008-6-22 13:32:13 net.sf.hibernate.impl.SessionFactoryObjectFactory getInstance
      è¦å‘Š: Not found: 402880521aae7fa0011aae7fad740000
      null


      the jboss JNDI VIEW LIKE THIS:

      Global JNDI Namespace
      +- hibernateJNDI (class: net.sf.hibernate.impl.SessionFactoryImpl)
      +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
      +- jmx (class: org.jnp.interfaces.NamingContext)
      | +- invoker (class: org.jnp.interfaces.NamingContext)
      | | +- RMIAdaptor (proxy: $Proxy47 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
      | +- rmi (class: org.jnp.interfaces.NamingContext)
      | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)


      WHY THE SESSIONFACTORY IS NULL!!!

      THANK YOU!!!

        • 1. Re: JBOSS4.2 with spring hibernate JNDI
          lmc_paul

          ""<<<<<<<"
          <!--property name="dataSource">

          </property-->


          com/moreflurish/domain/OaPersonoaPress.hbm.xml
          com/moreflurish/domain/OaPersonoaFeedback.hbm.xml
          com/moreflurish/domain/OaPersonoaUserPressRelation.hbm.xml
          com/moreflurish/domain/article/InfoArticle.hbm.xml




          <!-- net.sf.hibernate.dialect.DB2Dialect,net.sf.hibernate.dialect.MySQLDialect
          net.sf.hibernate.dialect.OracleDialect,net.sf.hibernate.dialect.SQLServerDialect
          -->
          net.sf.hibernate.dialect.MySQLDialect
          true
          hibernateJNDI
          <!--prop key="hibernate.connection.datasource">jdbc/moreflurish</prop-->
          java:/moreflurish

          """">>>>>>>>>>>"""""""""""'