1 Reply Latest reply on Sep 22, 2009 3:13 AM by jaikiran pai

    "Hibernate not bound" error

    Chris Walters Newbie

      I am having a problem retrieving a Hibernate session factory in my JBOSS web app. I am using JBOSS 5.1.0, Hibernate 3.3.1 and Netbeans 6.7.1.

      I get this error:

      javax.naming.NameNotFoundException: hibernate not bound


      when I run this code:

      _session_factory = (SessionFactory) ctx.lookup("java:/hibernate/GGGoMobileSessionFactory");


      Contents of my hibernate-service.xml file:

      <?xml version="1.0" encoding="utf-8"?>
      <server>
       <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.gggomobile:name=GGGoMobileSessionFactory">
       <attribute name="DatasourceName">java:/GGGoMobileDS</attribute>
       <attribute name="Dialect">
       org.hibernate.dialect.MySQLDialect
       </attribute>
       <attribute name="SessionFactoryName">
       java:/hibernate/GGGoMobileSessionFactory
       </attribute>
       <attribute name="CacheProviderClass">
       org.hibernate.cache.HashtableCacheProvider
       </attribute>
       <attribute name="ShowSqlEnabled">true</attribute>
       <attribute name="ScanForMappingsEnabled">true</attribute>
       </mbean>
      </server>
      


      The Hibernate MBean is successfully started but the SessionFactory doesn't seem to be running. If I invoke the "rebuildSessionFactory" method on the Hibernate MBean, I get the following error:

      13:16:15,707 INFO [Environment] Hibernate 3.3.1.GA
      13:16:15,737 INFO [Environment] hibernate.properties not found
      13:16:15,744 INFO [Environment] Bytecode provider name : javassist
      13:16:15,754 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
      13:16:16,040 ERROR [[HtmlAdaptor]] Servlet.service() for servlet HtmlAdaptor threw exception
      java.lang.IllegalArgumentException: Must set one of the resources, root or harUrl: org.jboss.hibernate.jmx.Hibernate@58a36 [BeanName=null, JNDI=java:/hibernate/GGGoMobileSessionFactory]
       at org.jboss.hibernate.jmx.Hibernate.handleMappings(Hibernate.java:281)
       at org.jboss.hibernate.jmx.Hibernate.buildSessionFactory(Hibernate.java:189)
       at org.jboss.hibernate.jmx.Hibernate.rebuildSessionFactory(Hibernate.java:528)
       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:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
       at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
       at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:223)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet$3.run(HtmlAdaptorServlet.java:380)
      
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet$3.run(HtmlAdaptorServlet.java:377)
       at java.security.AccessController.doPrivileged(Native Method)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:376)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:287)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:104)
       at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:86)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
       at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
       at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      


      Your help would be much appreciated because I have been stuck on this problem for a few days now. Thanks.

      - CW

        • 1. Re:
          jaikiran pai Master

           

          java.lang.IllegalArgumentException: Must set one of the resources, root or harUrl: org.jboss.hibernate.jmx.Hibernate@58a36 [BeanName=null, JNDI=java:/hibernate/GGGoMobileSessionFactory]


          Are you deploying as a .har file? If yes then try setting the harURL attribute of the MBean.