2 Replies Latest reply on Jan 20, 2007 1:59 AM by gblack

    javax.naming.NameNotFoundException hibernate service

    gblack

      Hello everybody,
      I am learning server technology and now I want to do small application. JSF - EJB2 - Hibernate - MySQL.
      I defined this mbean in my .har

      <server>
       <mbean code="org.jboss.hibernate.jmx.Hibernate"
       name="sprava:name=MySqlSessionFactory">
       <attribute name="DatasourceName">java:/MySqlDS</attribute>
       <attribute name="Dialect">
       org.hibernate.dialect.MySQLDialect
       </attribute>
       <attribute name="SessionFactoryName">
       java:/hibernate/MySqlSessionFactory
       </attribute>
       <attribute name="ShowSqlEnabled">true</attribute>
       </mbean>
      </server>
      


      During the deploying look all fine. And it ends

      2007-01-19 07:54:11,206 INFO [org.jboss.hibernate.jmx.Hibernate] SessionFactory successfully built and bound into JNDI [java:/hibernate/MySqlSessionFactory]


      I write in my EJBBean this code
       try {
       InitialContext ctx = new InitialContext();
       this.factory = (SessionFactory) ctx
       .lookup("java:/hibernate/MySessionFactory");
       } catch (Exception e) {
       throw new RuntimeException("ulozEJB", e);
       }
      
       TNepritomnost novy = new TNepritomnost();
       novy.setDatum_od(d_od);
       novy.setDatum_do(d_do);
       novy.setZkratkaPracovnika(zkr);
       novy.setDuvod(duv);
       novy.setSpzAuta(spz);
       novy.setPoznamka(pozn);
       novy.setPocetObedu(obedy);
      
       Session session = this.factory.openSession();
       Transaction transaction = session.beginTransaction();
       session.save(novy);
       transaction.commit();
       session.close();
      


      But red row throw

      javax.naming.NameNotFoundException: MySessionFactory not bound
      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:296)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at sprava.web.TestDSBean.uloz(TestDSBean.java:63)


      I mean that I should wirte some reference from ejb to hibernate mbean service but I don't know how.

      Please help me or send any link for more information. I was finding it here and in wiki too but not succesfully.

      Thanks for your time.

      Georg Black.



        • 1. Re: javax.naming.NameNotFoundException hibernate service
          jaikiran

          As mentioned in the log, the service is bound at :

          java:/hibernate/MySqlSessionFactory


          However you are looking up java:/hibernate/MySessionFactory. Change the lookup code to

          this.factory = (SessionFactory) ctx.lookup("java:/hibernate/MySqlSessionFactory");


          • 2. Re: javax.naming.NameNotFoundException hibernate service
            gblack

             

            "jaikiran" wrote:
            As mentioned in the log, the service is bound at :
            java:/hibernate/MySqlSessionFactory


            However you are looking up java:/hibernate/MySessionFactory. Change the lookup code to

            this.factory = (SessionFactory) ctx.lookup("java:/hibernate/MySqlSessionFactory");


            Thank you very match. There are so many config files then I wasn't able to find my typing error.

            yours faithfully GB.