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.  [ 5 posts ] 
Author Message
 Post subject: JNDI name problems. Hibernate with JBOSS
PostPosted: Wed Sep 14, 2005 1:37 am 
Newbie

Joined: Wed Sep 14, 2005 1:31 am
Posts: 6
Hi,
I have an web application which is packaged as a war file. The applications uses Hibernate, and PostgreSQL as the database. Everything works fine when i deploy it in tomcat.
Now when trying to deploy the same application in JBOSS, it fails during the lookup of the DataSource. Iam getting, javax.naming.NameNotFoundException

Following is the code snippets

hibernate.cfg.xml:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">myDB</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

<mapping resource="User.hbm.xml"/>

</session-factory>

</hibernate-configuration>



code snippet from the web.xml:

<resource-ref>
<description>DB Connection</description>
<res-ref-name>myDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


code from jboss-web.xml:

<jboss-web>
<resource-ref>
<res-ref-name>myDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:comp/env/myhDB</jndi-name>
</resource-ref>
</jboss-web>


Iam getting the following exception, when accessing the application:
javax.naming.NameNotFoundException: myDB not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
at org.jnp.server.NamingServer.lookup(NamingServer.java:278)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:313)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:112)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1509)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
at com.tridhama.webclient.application.persist.PersistenceUtil.<clinit>(Unknown Source)
at com.tridhama.webclient.application.dao.UserDAO.authenticate(Unknown Source)
at com.tridhama.webclient.web.action.LoginAction.performRequest(Unknown Source)
at com.tridhama.webclient.web.action.AbstractAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
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 com.tridhama.webclient.web.filter.CheckLoginFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
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:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
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:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
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:595)


I searched the jboss forums and did a lot of changes to the descriptors, but all resulting with the same exception.

Can someone please advise what is going wrong?

Thanks in advance,
Chandru ram


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 6:23 am 
Newbie

Joined: Fri Jun 17, 2005 2:51 am
Posts: 11
Hi Chandru,

in your forum post you wrote that the jboss-web.xml contains the following line:

Quote:
<jndi-name>java:comp/env/myhDB</jndi-name>


Is the "h" in myhDB just a typo in the post or may this be the reason why this is not working?

A workaround is that you configure the myDB directly in the deploy directory by a file myDB.xml that looks like this (example is for Oracle DB):

Code:
<datasources>
  <local-tx-datasource>
    <jndi-name>myDB</jndi-name>
    <connection-url>jdbc:oracle:thin:@servername:1521:DBName</connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name>xxx</user-name>
    <password>xxx</password>
    <min-pool-size>5</min-pool-size>
    <max-pool-size>20</max-pool-size>
    <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>

    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
      <metadata>
         <type-mapping>Oracle9i</type-mapping>
      </metadata>
  </local-tx-datasource>
</datasources>


Hope this helps,
Joern


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 2:16 am 
Newbie

Joined: Wed Sep 14, 2005 1:31 am
Posts: 6
Thanks for the reply Joern. The myhBD is just a typo. This is not in the original code. Also i have configured the datasource already as you have explained. Still i have the problem with the JNDI lookup.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 10:12 am 
Regular
Regular

Joined: Wed Jul 27, 2005 2:33 am
Posts: 118
Is the lookup of datasource happening from a different JVM than the application server's? Reason, i am asking this is in Jboss-3.2.x versions the datasource is NOT available outside the JVM. Have a look at the following link:

http://wiki.jboss.org/wiki/Wiki.jsp?page=HowCanIAccessADataSourceFromAClient


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 10:18 am 
Newbie

Joined: Wed Sep 14, 2005 1:31 am
Posts: 6
Thanks for the reply. Iam using Jboss 4.0.2 only.
Also the datasource is being looked up by the hibernate, which is a part of my web application and deployed to the app server.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.