1 2 3 Previous Next 30 Replies Latest reply: Dec 1, 2011 6:19 AM by jilani2423 RSS

naming context read only while creating hibernate session

jilani2423 Newbie

Hi,

 

I have implemented an application with hibernate and tried to deploy the same in JBoss AS 7, But it is giving exception. Please check the below stack trace of the exception shown in JBoss AS 7 console.

 

I have deployed the same in JBoss As 7.0.2 final and nightly build. But both are giving the same exception.

 

21:45:38,830 INFO  [stdout] (http--127.0.0.1-80-2) LoginBean.login()

21:45:38,830 INFO  [stdout] (http--127.0.0.1-80-2) -- -- -- -- -- -- -- -- -- --

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

21:45:38,834 INFO  [stdout] (http--127.0.0.1-80-2) BaseDAO.getJNDIConnection() i

nitialContext: javax.naming.InitialContext@5c64bc1e

21:45:38,842 INFO  [stdout] (http--127.0.0.1-80-2) BaseDAO.getJNDIConnection() r

esult: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@2bfd96c5

21:45:38,843 INFO  [stdout] (http--127.0.0.1-80-2) -- -- -- -- -- -- -- -- -- --

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

21:45:38,908 ERROR [stderr] (http--127.0.0.1-80-2) SLF4J: Failed to load class "

org.slf4j.impl.StaticLoggerBinder".

21:45:38,912 ERROR [stderr] (http--127.0.0.1-80-2) SLF4J: Defaulting to no-opera

tion (NOP) logger implementation

21:45:38,978 ERROR [stderr] (http--127.0.0.1-80-2) SLF4J: See http://www.slf4j.o

rg/codes.html#StaticLoggerBinder for further details.

21:45:39,149 INFO  [com.ahadanfal.common.dao.SessionFactoryUtil] (http--127.0.0.

1-80-2) Hibernate Configuration created.

21:45:39,346 SEVERE [com.ahadanfal.common.dao.SessionFactoryUtil] (http--127.0.0

.1-80-2) Initial SessionFactory creation failed.: java.lang.UnsupportedOperation

Exception: Naming context is read-only

        at org.jboss.as.naming.NamingContext.rebind(NamingContext.java:228)

        at javax.naming.InitialContext.rebind(InitialContext.java:412) [:1.6.0_2

6]

        at org.hibernate.util.NamingHelper.bind(NamingHelper.java:97) [hibernate

3.jar:]

        at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFac

toryObjectFactory.java:113) [hibernate3.jar:]

        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:

367) [hibernate3.jar:]

        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav

a:1872) [hibernate3.jar:]

        at com.ahadanfal.common.dao.SessionFactoryUtil.<clinit>(SessionFactoryUt

il.java:32) [classes:]

        at com.ahadanfal.common.dao.BaseDAO.getHibernateSession(BaseDAO.java:88)

[classes:]

        at com.ldm.bean.LoginBean.login(LoginBean.java:37) [classes:]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_2

6]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39) [:1.6.0_26]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25) [:1.6.0_26]

        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

        at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0

.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:2

76) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpress

ion.java:105) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Met

hodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.j

ar:2.0.0.Beta1]

        at com.sun.faces.application.ActionListenerImpl.processAction(ActionList

enerImpl.java:102) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-

jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1

259) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicat

ionPhase.java:81) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3

-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

[jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss

-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:329) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:248) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV

alve.java:275) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV

alve.java:161) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(Secu

rityContextAssociationValve.java:151) [jboss-as-web-7.1.0.Alpha2-SNAPSHOT.jar:7.

1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j

ava:155) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j

ava:102) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal

ve.java:109) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav

a:362) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java

:877) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce

ss(Http11Protocol.java:671) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:93

0) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

 

 

21:45:39,359 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (htt

p--127.0.0.1-80-2) #{loginBean.login}: java.lang.ExceptionInInitializerError: ja

vax.faces.FacesException: #{loginBean.login}: java.lang.ExceptionInInitializerEr

ror

        at com.sun.faces.application.ActionListenerImpl.processAction(ActionList

enerImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-

jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1

259) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicat

ionPhase.java:81) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3

-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

[jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss

-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:329) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:248) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV

alve.java:275) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV

alve.java:161) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(Secu

rityContextAssociationValve.java:151) [jboss-as-web-7.1.0.Alpha2-SNAPSHOT.jar:7.

1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j

ava:155) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j

ava:102) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal

ve.java:109) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav

a:362) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java

:877) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce

ss(Http11Protocol.java:671) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:93

0) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

Caused by: javax.faces.el.EvaluationException: java.lang.ExceptionInInitializerE

rror

        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Met

hodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.

jar:2.0.0.Beta1]

        at com.sun.faces.application.ActionListenerImpl.processAction(ActionList

enerImpl.java:102) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        ... 20 more

Caused by: java.lang.ExceptionInInitializerError

        at com.ahadanfal.common.dao.SessionFactoryUtil.<clinit>(SessionFactoryUt

il.java:39) [classes:]

        at com.ahadanfal.common.dao.BaseDAO.getHibernateSession(BaseDAO.java:88)

[classes:]

        at com.ldm.bean.LoginBean.login(LoginBean.java:37) [classes:]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_2

6]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39) [:1.6.0_26]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25) [:1.6.0_26]

        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

        at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0

.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:2

76) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpress

ion.java:105) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Met

hodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.j

ar:2.0.0.Beta1]

        ... 21 more

Caused by: java.lang.UnsupportedOperationException: Naming context is read-only

        at org.jboss.as.naming.NamingContext.rebind(NamingContext.java:228)

        at javax.naming.InitialContext.rebind(InitialContext.java:412) [:1.6.0_2

6]

        at org.hibernate.util.NamingHelper.bind(NamingHelper.java:97) [hibernate

3.jar:]

        at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFac

toryObjectFactory.java:113) [hibernate3.jar:]

        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:

367) [hibernate3.jar:]

        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav

a:1872) [hibernate3.jar:]

        at com.ahadanfal.common.dao.SessionFactoryUtil.<clinit>(SessionFactoryUt

il.java:32) [classes:]

        ... 31 more

 

 

21:45:39,373 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-

host].[/ldm].[Faces Servlet]] (http--127.0.0.1-80-2) Servlet.service() for servl

et Faces Servlet threw exception: java.lang.UnsupportedOperationException: Namin

g context is read-only

        at org.jboss.as.naming.NamingContext.rebind(NamingContext.java:228)

        at javax.naming.InitialContext.rebind(InitialContext.java:412) [:1.6.0_2

6]

        at org.hibernate.util.NamingHelper.bind(NamingHelper.java:97) [hibernate

3.jar:]

        at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFac

toryObjectFactory.java:113) [hibernate3.jar:]

        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:

367) [hibernate3.jar:]

        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav

a:1872) [hibernate3.jar:]

        at com.ahadanfal.common.dao.SessionFactoryUtil.<clinit>(SessionFactoryUt

il.java:32) [classes:]

        at com.ahadanfal.common.dao.BaseDAO.getHibernateSession(BaseDAO.java:88)

[classes:]

        at com.ldm.bean.LoginBean.login(LoginBean.java:37) [classes:]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_2

6]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39) [:1.6.0_26]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25) [:1.6.0_26]

        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

        at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0

.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:2

76) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpress

ion.java:105) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Met

hodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.j

ar:2.0.0.Beta1]

        at com.sun.faces.application.ActionListenerImpl.processAction(ActionList

enerImpl.java:102) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-

jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1

259) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicat

ionPhase.java:81) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3

-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

[jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss

-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:329) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:248) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV

alve.java:275) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV

alve.java:161) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(Secu

rityContextAssociationValve.java:151) [jboss-as-web-7.1.0.Alpha2-SNAPSHOT.jar:7.

1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j

ava:155) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j

ava:102) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal

ve.java:109) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav

a:362) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java

:877) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce

ss(Http11Protocol.java:671) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:93

0) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

        at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

 

 

Thank You,

Jilani

  • 1. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    That is reported by jira issue AS7-218  which was blocked by another issue.  Could you test again with the nightly build to see if that helps?  The link is http://community.jboss.org/thread/167590

     

    Scott

  • 2. Re: naming context read only while creating hibernate session
    jilani2423 Newbie

    Thank you for reply.

     

    I have seen the jira issues mentioned here. I have taken the latest build before 6 hrs from now and deployed the application on the same. I am downloading the latest successful build again now and will deploy it again and let you know the result.

     

    Thank You,

    Jilani

  • 3. Re: naming context read only while creating hibernate session
    jilani2423 Newbie

    Hi Scott,

     

    I have tested the same on build# 1944 and still the same error. Please let me know any alternative for getting hibernate session.

     

    Thank You,

    Jilani

  • 4. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    Hi Jilani,

     

    If you wanted to work around this bug, you could switch to using JPA (using a persistence.xml to define the persistence unit) and then inject a @PersistenceUnit into a Hibernate SessionFactory.  Since you are using Hibernate 3, you might want to try a proof of concept test, to make sure it works with Hibernate 3 (I see no reason why it shouldn't).  I have used it with Hibernate 4.

     

     

    import org.hibernate.SessionFactory;
    
    @PersistenceUnit(unitName="pu_name") SessionFactory factory;
    
    

     

     

    For other alternatives, we need to understand more about how https://issues.jboss.org/browse/AS7-421 was fixed.

  • 5. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    Do you have "hibernate.session_factory_name" set?  if yes, what have you set it to?  Changing "hibernate.session_factory_name" might help (with the nightly build that you downloaded) but I'm not yet sure what you should change it to.

  • 6. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    Another question, do you have "name" property in <session-factory> of your  hibernate.cfg.xm?

  • 7. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    Please post your  hibernate.cfg.xm here so we can see it.

  • 8. Re: naming context read only while creating hibernate session
    jilani2423 Newbie

    Hi Scott,

     

    Please find the attached files for hibernate.cfg.xml and persistence.xml.

     

    I have tried using the injection as mentioned above which is giving me null.

     

    The code snippet for this is as follows.

     

    public class DAO {

    @PersistenceUnit(unitName="ldm_pu") static SessionFactory factory;

     

     

        public static EntityManagerFactory getEMF()

        {

            EntityManagerFactory emf = Persistence.createEntityManagerFactory("ldm_pu");

            System.out.println("BaseDAO.getEMF() emf: "+emf); 

            /*EntityManager em = emf.createEntityManager();

            System.out.println("BaseDAO.getEMF() em: "+em);*/

            /*Session session = (Session)em.getDelegate();

            System.out.println("BaseDAO.getEMF() session: "+session);*/

            System.out.println("BaseDAO.getEMF() factory: "+factory);

            return emf;

        }

     

    }

     

    Thank You,

    Jilani

  • 9. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    By the way, the JPA 2.0 way to do "Session session = (Session)em.getDelegate()", is "Session session = (Session)em.unwrap(Session.class)". 

     

    Thanks for the update, I'll look at the attachments now...

  • 10. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    I just confirmed that the JNDI name space is still read-only. 

  • 11. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    What happens if you remove the "hibernate.session_factory_name" property?  Are you actually looking up the session factory later via a JNDI lookup?

  • 12. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    I created a new jira for this problem, the link is.  Vote for it if this is important to you.

  • 13. Re: naming context read only while creating hibernate session
    jilani2423 Newbie

    I have removed below line in hibernate cfg xml file.

    "hibernate.session_factory_name"

     

    Still no use.

     

    I am getting null pointer exception while trying entity manager approach. Please suggest me, What is missing in my implementaion.

     

     

     

    import javax.persistence.EntityManager;

    import javax.persistence.EntityManagerFactory;

    import javax.persistence.Persistence;

    import javax.persistence.PersistenceUnit;

     

     

    import org.hibernate.Session;

    import org.hibernate.SessionFactory;

     

     

    public class DAO

    {

       

        @PersistenceUnit(unitName="ldm_pu") static SessionFactory factory;

       

        public static EntityManagerFactory getEMF()

        {

            EntityManagerFactory emf = Persistence.createEntityManagerFactory("ldm_pu");

            System.out.println("BaseDAO.getEMF() emf: "+emf);

            EntityManager em = emf.createEntityManager();

            System.out.println("BaseDAO.getEMF() em: "+em);

            Session session = (Session)em.unwrap(Session.class);

            System.out.println("BaseDAO.getEMF() session: "+session);

    }

    }

     

     

     

    The exception stacktrace is as mentioned below

     

    23:13:23,337 INFO  [org.hibernate.dialect.Dialect] (http-java.sun.com-127.0.0.1-

    80-6) HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect

    23:13:23,341 INFO  [org.hibernate.engine.transaction.internal.TransactionFactory

    Initiator] (http-java.sun.com-127.0.0.1-80-6) HHH000268: Transaction strategy: o

    rg.hibernate.engine.transaction.internal.jta.CMTTransactionFactory

    23:13:23,343 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (h

    ttp-java.sun.com-127.0.0.1-80-6) HHH000397: Using ASTQueryTranslatorFactory

    23:13:23,356 INFO  [stdout] (http-java.sun.com-127.0.0.1-80-6) BaseDAO.getEMF()

    emf: org.hibernate.ejb.EntityManagerFactoryImpl@5ffa6fb6

    23:13:23,359 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (htt

    p-java.sun.com-127.0.0.1-80-6) #{loginBean.login}: java.lang.NullPointerExceptio

    n: javax.faces.FacesException: #{loginBean.login}: java.lang.NullPointerExceptio

    n

            at com.sun.faces.application.ActionListenerImpl.processAction(ActionList

    enerImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-

    jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

            at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

    [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

            at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1

    259) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

            at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicat

    ionPhase.java:81) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3

    -b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

    [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss

    -jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

    icationFilterChain.java:329) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

    ilterChain.java:248) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV

    alve.java:275) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV

    alve.java:161) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmC

    loserValve.java:50) [jboss-as-jpa-7.1.0.Alpha2-SNAPSHOT.jar:7.1.0.Alpha2-SNAPSHO

    T]

            at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(Secu

    rityContextAssociationValve.java:151) [jboss-as-web-7.1.0.Alpha2-SNAPSHOT.jar:7.

    1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j

    ava:155) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j

    ava:102) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal

    ve.java:109) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav

    a:362) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java

    :877) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce

    ss(Http11Protocol.java:671) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:93

    0) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

    Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException

            at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Met

    hodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.

    jar:2.0.0.Beta1]

            at com.sun.faces.application.ActionListenerImpl.processAction(ActionList

    enerImpl.java:102) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            ... 21 more

    Caused by: java.lang.NullPointerException

            at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStat

    us(JtaStatusHelper.java:73) [hibernate-core-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActiv

    e(JtaStatusHelper.java:115) [hibernate-core-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMT

    Transaction.java:149) [hibernate-core-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractE

    ntityManagerImpl.java:1201) [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityMa

    nagerImpl.java:172) [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:90)

    [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(Entity

    ManagerFactoryImpl.java:111) [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(Entity

    ManagerFactoryImpl.java:106) [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at com.ahadanfal.common.dao.BaseDAO.getEMF(BaseDAO.java:36) [classes:]

            at com.ldm.bean.LoginBean.login(LoginBean.java:39) [classes:]

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_2

    6]

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

    java:39) [:1.6.0_26]

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

    sorImpl.java:25) [:1.6.0_26]

            at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

            at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0

    .3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:2

    76) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpress

    ion.java:105) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Met

    hodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.j

    ar:2.0.0.Beta1]

            ... 22 more

     

     

    23:13:23,390 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-

    host].[/ldm].[Faces Servlet]] (http-java.sun.com-127.0.0.1-80-6) Servlet.service

    () for servlet Faces Servlet threw exception: java.lang.NullPointerException

            at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStat

    us(JtaStatusHelper.java:73) [hibernate-core-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActiv

    e(JtaStatusHelper.java:115) [hibernate-core-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMT

    Transaction.java:149) [hibernate-core-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractE

    ntityManagerImpl.java:1201) [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityMa

    nagerImpl.java:172) [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:90)

    [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(Entity

    ManagerFactoryImpl.java:111) [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(Entity

    ManagerFactoryImpl.java:106) [hibernate-entitymanager-4.0.0.CR6.jar:4.0.0.CR6]

            at com.ahadanfal.common.dao.BaseDAO.getEMF(BaseDAO.java:36) [classes:]

            at com.ldm.bean.LoginBean.login(LoginBean.java:39) [classes:]

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_2

    6]

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

    java:39) [:1.6.0_26]

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

    sorImpl.java:25) [:1.6.0_26]

            at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

            at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0

    .3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:2

    76) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpress

    ion.java:105) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Met

    hodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.j

    ar:2.0.0.Beta1]

            at com.sun.faces.application.ActionListenerImpl.processAction(ActionList

    enerImpl.java:102) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-

    jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

            at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

    [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

            at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1

    259) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

            at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicat

    ionPhase.java:81) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3

    -b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

    [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss

    -jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

    icationFilterChain.java:329) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

    ilterChain.java:248) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV

    alve.java:275) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV

    alve.java:161) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmC

    loserValve.java:50) [jboss-as-jpa-7.1.0.Alpha2-SNAPSHOT.jar:7.1.0.Alpha2-SNAPSHO

    T]

            at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(Secu

    rityContextAssociationValve.java:151) [jboss-as-web-7.1.0.Alpha2-SNAPSHOT.jar:7.

    1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j

    ava:155) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j

    ava:102) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal

    ve.java:109) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav

    a:362) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java

    :877) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce

    ss(Http11Protocol.java:671) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:93

    0) [jbossweb-7.0.3.Final.jar:7.1.0.Alpha2-SNAPSHOT]

            at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

  • 14. Re: naming context read only while creating hibernate session
    Scott Marlow Master

    Is that with the same persistence.xml as you posted before or are you using additional properties perhaps?

1 2 3 Previous Next