You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Manoj S <ma...@amritatech.com> on 2008/06/12 09:30:39 UTC

Openejb 3.0 with Hibernate - javax.naming.OperationNotSupportedException problem ...

Hello,
Does anybody had the following problem ?
I was trying to run my application in openejb (tomcat 5.5, openejb 3.0
war, java 1.5, hibernate 3), but it is showing an error when I call,

new Configuration().setInterceptor(new MyHibernateInterceptor())
		.configure("my-hibernate.cfg.xml").buildSessionFactory();

The error log is,

INFO - Creating subcontext: hibernate
WARN - Could not bind factory to JNDI
javax.naming.OperationNotSupportedException
	at org.apache.openejb.core.ivm.naming.IvmContext.rebind(IvmContext.java:283)
	at org.apache.openejb.core.ivm.naming.IvmContext.rebind(IvmContext.java:287)
	at org.hibernate.util.NamingHelper.bind(NamingHelper.java:74)
	at
org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:290)
	at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)

My "my-hibernate.cfg.xml" will looklike as follows.

<?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="module1/hibernate/HibernateFactory">
  <property name="show_sql">true</property>
  <property name="connection.datasource">java:comp/env/MySQLDS</property>
  <property
name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
  <property
name="transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
  <property
name="transaction.manager_lookup_class">org.apache.openejb.hibernate.TransactionManagerLookup</property>
  <property name="connection.release_mode">auto</property>
  <property name="transaction.flush_before_completion">true</property>
  <property name="transaction.auto_close_session">true</property>
        <mapping resource="..." />
        ... all my mapping resources will come here ....
</session-factory>
</hibernate-configuration>

If anyone knows the solution to this issue, please help me. Thanks in
advance.
-Manoj.


Re: Openejb 3.0 with Hibernate - javax.naming.OperationNotSupportedException problem ...

Posted by David Blevins <da...@visi.com>.
Hmm, it seems that Hibernate is trying to bind something into JNDI  
which isn't allowed.  JNDI is read-only in Java EE land.  I looked  
through the code to see if there were any hints and it seems like the  
binding of things into JNDI is optional and can be shut off.

Looks as though if you delete this line of your hibernate config:
   <session-factory name="shoppingmodule/hibernate/HibernateFactory">

that it will not try and bind the name into JNDI.  It's clearly  
caching the SessionFactory in a couple different static hashmaps so  
I'm guessing the JNDI thing isn't used internally.

Let us know if that works.

-David

On Jun 12, 2008, at 12:30 AM, Manoj S wrote:

> Hello,
> Does anybody had the following problem ?
> I was trying to run my application in openejb (tomcat 5.5, openejb 3.0
> war, java 1.5, hibernate 3), but it is showing an error when I call,
>
> new Configuration().setInterceptor(new MyHibernateInterceptor())
> 		.configure("my-hibernate.cfg.xml").buildSessionFactory();
>
> The error log is,
>
> INFO - Creating subcontext: hibernate
> WARN - Could not bind factory to JNDI
> javax.naming.OperationNotSupportedException
> 	at  
> org.apache.openejb.core.ivm.naming.IvmContext.rebind(IvmContext.java: 
> 283)
> 	at  
> org.apache.openejb.core.ivm.naming.IvmContext.rebind(IvmContext.java: 
> 287)
> 	at org.hibernate.util.NamingHelper.bind(NamingHelper.java:74)
> 	at
> org 
> .hibernate 
> .impl 
> .SessionFactoryObjectFactory 
> .addInstance(SessionFactoryObjectFactory.java:90)
> 	at  
> org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java: 
> 290)
> 	at
> org 
> .hibernate.cfg.Configuration.buildSessionFactory(Configuration.java: 
> 1154)
>
> My "my-hibernate.cfg.xml" will looklike as follows.
>
> <?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="module1/hibernate/HibernateFactory">
>  <property name="show_sql">true</property>
>  <property name="connection.datasource">java:comp/env/MySQLDS</ 
> property>
>  <property
> name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
>  <property
> name 
> = 
> "transaction 
> .factory_class">org.hibernate.transaction.CMTTransactionFactory</ 
> property>
>  <property
> name 
> = 
> "transaction 
> .manager_lookup_class 
> ">org.apache.openejb.hibernate.TransactionManagerLookup</property>
>  <property name="connection.release_mode">auto</property>
>  <property name="transaction.flush_before_completion">true</property>
>  <property name="transaction.auto_close_session">true</property>
>        <mapping resource="..." />
>        ... all my mapping resources will come here ....
> </session-factory>
> </hibernate-configuration>
>
> If anyone knows the solution to this issue, please help me. Thanks in
> advance.
> -Manoj.
>
>