-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem Binding JNDI into JBOSS
PostPosted: Tue Apr 04, 2006 12:05 pm 
Beginner
Beginner

Joined: Wed May 18, 2005 9:48 am
Posts: 31
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1
Mapping documents:

hibernate-service.xml
Code:
<server>
    <mbean code="org.jboss.hibernate.jmx.Hibernate"
           name="jboss.har:service=Hibernate">
        <attribute name="DatasourceName">java:/ClusterFNACDS</attribute>
        <attribute name="Dialect">org.hibernate.dialect.PostgreSQLDialect</attribute>
        <attribute name="SessionFactoryName">java:hibernate/SessionFactory</attribute>
        <attribute name="CacheProviderClass">
            org.hibernate.cache.HashtableCacheProvider
        </attribute>
        <!-- <attribute name="Hbm2ddlAuto">create-drop</attribute> -->
    </mbean>
</server>


jboss-web.xml
Code:
<jboss-web>
  <context-root>/intranet</context-root>
  <resource-ref>
      <res-ref-name>jdbc/HibernateFNAC</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <jndi-name>/ClusterFNACDS</jndi-name>
  </resource-ref>
</jboss-web>


web.xml
Code:
<resource-ref>
        <res-ref-name>jdbc/HibernateFNAC</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>



Code between sessionFactory.openSession() and session.close():
Code:
public void sessionCreated(HttpSessionEvent evt) {
      logListener.info("Nueva Sesión: " + evt.getSession().getId());
      TomcatConfig tomcat = new TomcatConfigHome().findById(1);
      System.out.println(tomcat.getProperty() + "-" + tomcat.getValue());
      Session hsession = null;
         try {
               InitialContext ctx = new InitialContext();
               SessionFactory factory  =  (SessionFactory)ctx.lookup("java:hibernate/SessionFactory");
               hsession = factory.openSession();
               System.out.println("SESION HIBERNATE: " + hsession );
             } catch (NamingException e1) {
                  e1.printStackTrace();
             }
   }

Full stack trace of any exception that occurs:
Code:
17:50:39,281 INFO  [SettingsFactory] Default entity-mode: pojo
17:50:39,281 INFO  [SessionFactoryImpl] building session factory
17:50:41,671 INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
17:50:41,671 INFO  [NamingHelper] JNDI InitialContext properties:{}
17:50:41,734 INFO  [Hibernate] SessionFactory successfully built and bound into JNDI [java:hibernate/SessionFactory]
17:50:41,781 INFO  [TomcatDeployer] deploy, ctxPath=/intranet, warUrl=.../tmp/deploy/tmp24901intranet.ear-contents/intranetWEB-exp.war/
17:50:42,484 INFO  [ClusterFNACSessionListener] LOG4J: Intranet ClusterFNAC context is created.
17:50:42,578 INFO  [JBossCacheManager] init(): replicationGranularity_ is 0 and invaldateSessionPolicy is 2
17:50:42,578 ERROR [JBossCacheManager] JBossCacheService to Tomcat clustering not found
17:50:42,578 ERROR [TomcatDeployer] Failed to setup clustering, clustering disabled
17:50:42,656 INFO  [EARDeployer] Started J2EE application: file:/C:/jboss/server/default/deploy/intranet.ear
17:53:21,015 INFO  [ClusterFNACSessionListener] Nueva Sesión: 8FA548D3F4818277889FE726590A74B5
17:53:21,062 WARN  [SessionFactoryObjectFactory] Not found: 9ce488ed0a654cd4010a65993b07000c
17:53:40,125 ERROR [TomcatConfigHome] get failed
java.lang.NullPointerException
   at clusterFNAC.hibernate.TomcatConfigHome.findById(TomcatConfigHome.java:100)
   at clusterFNAC.listeners.ClusterFNACSessionListener.sessionCreated(ClusterFNACSessionListener.java:21)
   at org.apache.catalina.session.StandardSession.tellNew(StandardSession.java:389)
   at org.apache.catalina.session.StandardSession.setId(StandardSession.java:361)
   at org.apache.catalina.session.ManagerBase.createSession(ManagerBase.java:825)
   at org.apache.catalina.session.StandardManager.createSession(StandardManager.java:290)
   at org.apache.catalina.connector.Request.doGetSession(Request.java:2215)
   at org.apache.catalina.connector.Request.getSession(Request.java:2024)
   at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:831)
   at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:842)
   at org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:148)
   at org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:123)
   at org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:104)
   at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:61)
   at org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:33)
   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
   at java.lang.Thread.run(Unknown Source)
17:53:42,062 ERROR [[/intranet]] Session event listener threw exception
java.lang.NullPointerException
   at clusterFNAC.hibernate.TomcatConfigHome.findById(TomcatConfigHome.java:100)
   at clusterFNAC.listeners.ClusterFNACSessionListener.sessionCreated(ClusterFNACSessionListener.java:21)
   at org.apache.catalina.session.StandardSession.tellNew(StandardSession.java:389)
   at org.apache.catalina.session.StandardSession.setId(StandardSession.java:361)
   at org.apache.catalina.session.ManagerBase.createSession(ManagerBase.java:825)
   at org.apache.catalina.session.StandardManager.createSession(StandardManager.java:290)
   at org.apache.catalina.connector.Request.doGetSession(Request.java:2215)
   at org.apache.catalina.connector.Request.getSession(Request.java:2024)
   at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:831)
   at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:842)
   at org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:148)
   at org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:123)
   at org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:104)
   at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:61)
   at org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:33)
   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
   at java.lang.Thread.run(Unknown Source)



Name and version of the database you are using:
PostgreSQL 8.0.1


Why could be the problem that make with this configuration not bingind factory into SessionFactoryObjectFactory class but then Hibernate do it some lines before, but it doens't work?.

Thanks All


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 7:04 pm 
Beginner
Beginner

Joined: Wed May 18, 2005 9:48 am
Posts: 31
I delete resource-ref from web.xml and jboss-web.xml but with same problem.

I tried to use java:comp/env/hibernate/SessionFactory and when it deploys there was an error saying me that "env" was already in use. I am using latest version of Jboss server and Hibernate 3.1.2. What could be error?

Other thing i want to know is that in Tomcat you put log4j.properties into WEB-INF/ directory. Where do I put this file into JBoss?. I am using EAR deployment and inside there is a hibernate HAR file and a xxxWEB.jar file with web contents.

Thanks all people.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.