The JNDIManagedRuntime creates a new InitialContext, and does a lookup of the TransactionManagerName you provided. It assumes that the environment for the IC is ready to use with no modification on our part.
So if the naming space has been initialized prior to the call to getTransactionManager() it should work. Maybe that's a bad assumption for OSGi environments. We've done some work to integrate with Aries: OPENJPA-1524<https://issues.apache.org/jira/browse/OPENJPA-1524>. There's also some work underway to make this support more generic: OPENJPA-1593 <https://issues.apache.org/jira/browse/OPENJPA-1593> (which I need to get back to). Let me know if 1593 will help you. I'll take another look at the patch and see if we can get that into a release. -mike On Tue, Feb 8, 2011 at 5:47 AM, Charles Moulliard <cmoulli...@gmail.com>wrote: > > Hi, > > I get the following error > > Caused by: javax.naming.NoInitialContextException: Need to specify class > name in environment or system property, or as an applet parameter, or in an > application resource file: java.naming.factory.initial > at > javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) > at > javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) > at > javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) > at javax.naming.InitialContext.lookup(InitialContext.java:392) > at > > org.apache.openjpa.ee.JNDIManagedRuntime.getTransactionManager(JNDIManagedRuntime.java:60) > > when running openjpa on Apache Karaf (OSGI server) where the jndi context > has been created using the following spring xbean definition and exported > as > a osgi service > > <bean id="jndi" > > class="org.apache.xbean.spring.jndi.SpringInitialContextFactory" > factory-method="makeInitialContext"> > <entry key="java:/TransactionManager" value-ref="txManager" > /> > </map> > </property> > </bean> > > <osgi:service ref="jndi" interface="javax.naming.Context"/> > > Question : is there a trick which allow openjpa to find the transaction > manager ? > > <properties> > <property name="openjpa.jdbc.SynchronizeMappings" > value="buildSchema(SchemaAction='add,deleteTableContents')"/> > <!-- <property name="openjpa.Log" value="log4j"/> --> > <property name="openjpa.Log" value="log4j" /> > <property name="openjpa.TransactionMode" value="managed"/> > <property name="openjpa.ManagedRuntime" > value="jndi(TransactionManagerName=java:/TransactionManager)"/> > </properties> > > Here is my spring config : > > <!-- Setup Local Container for JPA and EntityManager --> > <bean id="entityManagerFactory" > class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> > <property name="persistenceUnitName" value="reportIncident"/> > <property name="jpaVendorAdapter" ref="jpaAdapter"/> > <property name="dataSource"> > <osgi:reference interface="javax.sql.DataSource"/> > </property> > </bean> > > > <!-- Open JPA dapter --> > <bean id="jpaAdapter" > class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"> > <property name="databasePlatform" value="${databasePlatform}"/> > <property name="showSql" value="${showSql}"/> > <property name="database" value="${database}"/> > </bean> > > <!-- JTA TransactionManager --> > <bean id="txManager" > class="org.springframework.transaction.jta.JtaTransactionManager"> > <property name="transactionManager"> > <osgi:reference > interface="javax.transaction.TransactionManager"/> > </property> > </bean> > > Regards, > > Charles Moulliard > Apache committer Karaf, Camel & ServiceMix > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/openjpa-jndi-issue-with-xbean-Spring-tp6003669p6003669.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. >