openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <cmoulli...@gmail.com>
Subject openjpa - jndi issue with xbean Spring
Date Tue, 08 Feb 2011 11:47:37 GMT

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.

Mime
View raw message