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 <http://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 <http://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
