Hi Robert, I think Tom was offering to help if you can provide logs, but in their absence....
Have you tried putting the data source definition in a separate bundle from the bean using jpa:context? You may have some kind of cycle in your dependencies given the jpa:context requires the datasource that you're providing in the same blueprint. If this then works but fails intermittently then there may be a life-cycle issue (in the Aries code) between data source registration and jpa:context/unit injection. You should be able to use a service dependency to resolve that (having a service ref from jpa:context bundle to a service provided by the data source bundle). I hope this helps. Regards, Graham. On 24 July 2013 02:37, Tom Leung <[email protected]> wrote: > A lot of reason causes null pointer exception, **** > > post the detail error log, so let us know what the problem you encounter.* > *** > > ** ** > > Best Rgds,**** > > ** ** > > Tom**** > > ** ** > > ** ** > > *From:* Robert Wheeler [mailto:[email protected]] > *Sent:* Wednesday, July 24, 2013 1:39 AM > *To:* [email protected] > *Subject:* EntityManager is null**** > > ** ** > > I have a very basic sample I am trying to insert a record into a database. > I keep getting a NullPointer when I try to persist my record and when I > debug I see that the EntityManager is null. I am including my > persistence.xml and blueprint.xml files and any help would be appreciated. > **** > > ** ** > > ** ** > > <?xml version="1.0" encoding="UTF-8"?>**** > > <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"**** > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"**** > > xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"**** > > xmlns:camel="http://camel.apache.org/schema/blueprint"**** > > xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.1.0"**** > > xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">**** > > ** ** > > <bean id="personDAO"**** > > class="com.novatus.simpletransaction.dao.PersonDAO">**** > > <tx:transaction method="*" value="Required" />**** > > <jpa:context property="entityManager" unitname="simpleTrans" />**** > > </bean>**** > > <bean id="personRoute" > class="com.novatus.simpletransaction.route.PersonRoute" />**** > > **** > > <camelContext xmlns="http://camel.apache.org/schema/blueprint">**** > > <routeBuilder ref="personRoute" />**** > > </camelContext>**** > > **** > > <bean id="dataSource" class="org.postgresql.ds.PGPoolingDataSource" > destroy-method="close">**** > > <property name="serverName" value="localhost/database"/>**** > > <property name="user" value="username"/>**** > > <property name="password" value="password"/>**** > > <property name="dataSourceName" value="myConnectionPool"/>**** > > <property name="initialConnections" value="2"/>**** > > <property name="maxConnections" value="4" />**** > > </bean>**** > > **** > > <service interface="javax.sql.DataSource" ref="dataSource">**** > > <service-properties>**** > > <entry key="osgi.jndi.service.name" value="jdbc/postgresds"/>* > *** > > </service-properties>**** > > </service>**** > > ** ** > > </blueprint>**** > > ** ** > > <?xml version="1.0" encoding="UTF-8" ?>**** > > <persistence xmlns="http://java.sun.com/xml/ns/persistence"**** > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"**** > > xsi:schemaLocation="http://java.sun.com/xml/ns/persistence > http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"**** > > version="2.0">**** > > ** ** > > <persistence-unit name="simpleTrans" transaction-type="JTA">**** > > <description>Persistence unit for the example blogging > application</description>**** > > ** ** > > > <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> > **** > > <jta-data-source>osgi:service/javax.sql.DataSource/( > osgi.jndi.service.name=jdbc/postgresds)</jta-data-source>**** > > <class>com.novatus.simpletransaction.entity.Person</class>**** > > <exclude-unlisted-classes>true</exclude-unlisted-classes>**** > > <properties>**** > > <property name="openjpa.Log" value="DefaultLevel=TRACE,Runtime=TRACE,**** > > Tool=TRACE,SQL=TRACE,Enhance=TRACE" />**** > > </properties>**** > > **** > > </persistence-unit>**** > > </persistence>**** > > ** ** > > ** ** > > ** ** > > Thanks Robert**** >
