This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate config on JBOSS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate config on JBOSS" Watch "Hibernate config on JBOSS" New topic
Author

Hibernate config on JBOSS

M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 388
I am using JBOSS 5 and Hibernate 3. I keep getting an error when I try to access the Session factory, "javax.naming.NameNotFoundException: DSDB not bound"

I assume my config is wrong somehow. Would you take a look?

Java Call:
SessionFactory sf = (SessionFactory) new InitialContext().lookup("java:/DSDB");

Hibernate.cfg.xml:

<session-factory name="java:/DSDB">
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<property name="connection.datasource">java:/DSDB</property>
<property name="connection.username">stuff</property>
<property name="jndi.class"></property>
<property name="connection.password">stuff</property>
<property name="jndi.url">
jdbc:sqlserver://localhost:1433;databaseName=DS
</property>



server/default/deploy/DS-ds.xml

<?xml version="1.0" encoding="UTF-8"?>

<datasources>

<!-- JBOSS 5.1 Install in \server\default\deploy-->
<local-tx-datasource>
<jndi-name>DSDB</jndi-name>
<connection-url>jdbc:sqlserver://localhost:1433;databaseName=DS</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<user-name>stuff</user-name>
<password>stuff</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<use-java-context>false</use-java-context>
<track-statements/>
<new-connection-sql>SELECT 1</new-connection-sql>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</local-tx-datasource>

</datasources>


Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

It's typically java:xxx/name or java:env/xxx/name.
Can you please verify the jndi name in console after starting your jboss: http://localhost:8080/?
you can refer this thread for jndi naming conventions in jboss.


If you are not laughing at yourself, then you just didn't get the joke.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate config on JBOSS