1 Reply Latest reply on Sep 13, 2004 7:30 AM by milesif

    SessionFactory with name [java:/hibernate/SessionFactory] no

    milesif

      I have followed indications in JBossHibernate wiki with JBoss4.0. The application and .har deployments have no problems, but when I call SessionContext.getSession("java:/hibernate/SessionFactory") in a stateless session bean method I get the following exception

      20:44:39,418 ERROR [LogInterceptor] RuntimeException in method: public abstract java.lang.String prova.interfaces.Prova.doIt() throws java.rmi.RemoteException:
      java.lang.IllegalStateException: SessionFactory with name [java:/hibernate/SessionFactory] not yet registered with SessionContext
      at org.jboss.hibernate.session.SessionContext.getStorage(SessionContext.java:135)
      at org.jboss.hibernate.session.SessionContext.getSession(SessionContext.java:43)
      at prova.ejb.ProvaBean.doIt(ProvaBean.java:93)
      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 org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
      at org.jboss.ejb.plugins.AbstractInterceptor.invoke(AbstractInterceptor.java:96)
      at org.jboss.hibernate.session.EjbInterceptor.invoke(EjbInterceptor.java:81)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:859)
      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 org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:236)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:775)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
      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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      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:536)


      Note that my scope is transaction and I have associated e required transaction to my method.
      I do not know what is worng.
      If anybody has any ideas please help.
      Sorry if this is the worng forum for such question.

      Thanks in advance
      Francesco

        • 1. Re: SessionFactory with name [java:/hibernate/SessionFactory
          milesif

          Hi everybody,

          I solved the problem looking at the sources of importXml(Element config) merthod of EjbInterceptor class. From that I found out that I had to add a parameter named bindName with value equal to the name of the hibernate session factory to be used in the jBoss.xml configuration file. That is not indicated in the examples.


          <container-configurations>
          <container-configuration extends="Standard Stateless SessionBean">
          <container-name>Hibernate Stateless SessionBean</container-name>
          <call-logging>true</call-logging>
          <container-interceptors>
          org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor
          org.jboss.ejb.plugins.LogInterceptor
          org.jboss.ejb.plugins.SecurityInterceptor
          <!-- CMT -->
          org.jboss.ejb.plugins.TxInterceptorCMT
          org.jboss.ejb.plugins.MetricsInterceptor
          org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor
          <!-- BMT -->
          org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor
          org.jboss.ejb.plugins.TxInterceptorBMT
          org.jboss.ejb.plugins.MetricsInterceptor
          org.jboss.resource.connectionmanager.CachedConnectionInterceptor
          org.jboss.hibernate.session.EjbInterceptor
          </container-interceptors>
          </container-configuration>
          </container-configurations>


          regards
          Francesco Milesi