-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate won't build SessionFactory under Eclipse Tomcat
PostPosted: Tue Sep 01, 2009 1:44 pm 
Newbie

Joined: Tue Sep 01, 2009 11:15 am
Posts: 4
I'm using Hibernate 3.3, Tomcat 6, and Eclipse Galileo and I get the following exception from Configuration.configure().buildSessionFactory():

13:00:35,843 INFO SessionFactoryObjectFactory:109 - Factory name: java:comp/env/jdbc/bmf
13:00:35,843 INFO NamingHelper:49 - JNDI InitialContext properties:{}
13:00:35,843 WARN SessionFactoryObjectFactory:121 - Could not bind factory to JNDI
javax.naming.NamingException: Context is read only
at org.apache.naming.NamingContext.checkWritable(NamingContext.java:903)
at org.apache.naming.NamingContext.bind(NamingContext.java:831)
at org.apache.naming.NamingContext.rebind(NamingContext.java:208)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:97)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:113)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:348)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
...

The contents of hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="java:comp/env/jdbc/bmf">
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<mapping class="com.bmf.db.BMFUser" resource="com/bmf/db/BMFUser.hbm.xml"/>
<mapping class="com.bmf.db.BMFWager" resource="com/bmf/db/BMFWager.hbm.xml"/>
<mapping class="com.bmf.db.WagerParty" resource="com/bmf/db/WagerParty.hbm.xml"/>
</session-factory>
</hibernate-configuration>

I put the data source in the Tomcat server context.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Context privileged="true" reloadable="true">
....
<Resource name="jdbc/bmf" auth="Container"
type="javax.sql.DataSource"
username="root" password="admin"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/bmf"/>
</Context>

I read somewhere else that Tomcat creates read-only JNDI entries, but don't have clue how to get around it. I'd like to be able to do this without coding a JNDI context with a javax.sql.DataSource in it, and even then I'm not sure that it'll work.

I think I must be missing something really obvious, so apologies if that's the case.


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

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.