Hi,
i'm getting the following exception when trying to access a datasource.
FATAL [DatasourceConnectionProvider] Could not find datasource: java:/hibernate_test
javax.naming.NameNotFoundException: hibernate_test not bound
As i'm a begginer with Hibernate, i have a lot of doubts - some of them i already posted in this forum, but every step i make, i get a new exception :-(
- Is the datasource the same as the connection url?
- I'm using hibernate2 as an mbean in jboss 3.2.3, so do i need the file hibernate.properties or just the jboss-service.xml ??? If i do, where should i pack it?
- I could run the example that comes with hibernate2 with the same database using the connection url like this: jdbc:mysql://localhost/hibernate_test. However, i also tried this on my app (instead of java:/hibernate_test) and it didn't work.
Here's jboss-service.xml
Code:
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=Hibernate">
<depends>jboss.jca:service=RARDeployer</depends>
<attribute name="MapResources">hibernate/Person.hbm.xml</attribute>
<attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
<attribute name="Datasource">java:/hibernate_test</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
</mbean>
</server>
And here's part of my java code
Code:
Context ctx = new InitialContext();
SessionFactory factory = (SessionFactory) ctx.lookup("java:/hibernate/SessionFactory");
System.out.println("Found jndi ok !!! ");
Session session = factory.openSession();
System.out.println("Opened session ok !!! ");
The last line i see printed on screen is "Found jndi ok !!!".
Thanks,
ltcmelo