I m encountring with "javax.naming.NameNotFoundException: hibernate not bound" exception while trying to configure jboss and hibernate unsing oracle. i m using jboss mbean to manage hibernate for me. hibernate.har archieve is included and deployed successfully within my .ear app. But while attempting to get session factory instance this exception is occuring. Detailed mappings and code along with exception stack trace is given below. I will be very grateful to a quick response.
Hibernate version:3
Name and version of the database you are using: oracle 9.2.0.1
Mapping documents:
jboss-service.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE server> <!-- $Id: jboss-service.xml,v 1.4.6.1 2004/11/29 16:50:50 starksm Exp $ -->
<server> <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate"> <attribute name="DatasourceName">java:/XAOracleDS</attribute> <attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute> <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute> <attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute> <attribute name="ShowSqlEnabled">true</attribute> </mbean> </server>
===============================================
oracle-xa-ds.xml
<datasources> <xa-datasource> <jndi-name>XAOracleDS</jndi-name> <track-connection-by-tx>true</track-connection-by-tx> <isSameRM-override-value>false</isSameRM-override-value> <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class> <xa-datasource-property name="URL"> jdbc:oracle:thin:@10.10.10.38:1521:investal </xa-datasource-property> <xa-datasource-property name="User">scott</xa-datasource-property> <xa-datasource-property name="Password">tiger</xa-datasource-property> <exception-sorter-class-name> org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter </exception-sorter-class-name> <no-tx-separate-pools/> </xa-datasource>
<!-- <mbean code="org.jboss.resource.adapter.jdbc.xa.oracle.OracleXAExceptionFormatter" name="jboss.jca:service=OracleXAExceptionFormatter"> <depends optional-attribute-name="TransactionManagerService"> jboss:service=TransactionManager </depends> </mbean> --> </datasources>
===============================================
web.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<!-- The http-invoker.sar/invoker.war web.xml descriptor $Id: web.xml,v 1.3.6.1 2004/11/29 16:50:50 starksm Exp $ --> <web-app>
<display-name>Client360</display-name>
<filter> <filter-name>redirect</filter-name> <filter-class>org.apache.tapestry.RedirectFilter</filter-class> </filter>
<filter-mapping> <filter-name>redirect</filter-name> <url-pattern>/</url-pattern> </filter-mapping>
<servlet> <servlet-name>tapestry</servlet-name> <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
<servlet-mapping> <servlet-name>tapestry</servlet-name> <url-pattern>/app</url-pattern> </servlet-mapping>
<servlet> <servlet-name>test</servlet-name> <servlet-class>investalink.TestServlet</servlet-class> </servlet>
<servlet-mapping> <servlet-name>test</servlet-name> <url-pattern>/testServlet</url-pattern> </servlet-mapping>
<resource-ref > <res-ref-name>XAOracleDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <resource-ref > <res-ref-name>hibernate/SessionFactory</res-ref-name> <res-type>org.hibernate.SessionFactory</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app>
===============================================
jboss-web.xml
<jboss-web> <resource-ref > <res-ref-name>XAOracleDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <!-- <res-auth>Container</res-auth> --> <jndi-name>java:/XAOracleDS</jndi-name> </resource-ref> <resource-ref > <res-ref-name>hibernate/SessionFactory</res-ref-name> <res-type>org.hibernate.SessionFactory</res-type> <!-- <res-auth>Container</res-auth> --> <jndi-name>java:hibernate/SessionFactory</jndi-name> </resource-ref> </jboss-web>
Servlet Code :
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("in servlet"); try { InitialContext ctx = new InitialContext(); SessionFactory factory = (SessionFactory) ctx.lookup("java:/hibernate/SessionFactory");
Session hsession = factory.openSession(); .......... } catch (NamingException e) { e.printStackTrace(); } System.out.println("exiting servlet"); response.sendRedirect("test.jsp");
} }
Full stack trace of any exception that occurs:
in servlet javax.naming.NameNotFoundException: hibernate 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:267) 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:347) at investalink.TestServlet.doGet(TestServlet.java:31) at javax.servlet.http.HttpServlet.service(HttpServlet.java:697) 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.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175) 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:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) 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(Thread.java:536) exiting servlet
|