Which version of Spring are you using?
How did you use PersistenceContext?
Maybe the class that you want to inject the EntityManager is not managed by 
Spring.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem




On Tuesday, July 2, 2013 at 5:31 PM, abhi wrote:

> Hi All,
> I am facing issue with EntityManager being null when I access it from my
> Java Code.
>  
> Below is my camel-context in which I am defining Entity MAnager.
>  
> <bean id="entityManagerFactory"
> class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
> <property name="persistenceUnitName" value="com.baselogic.jpa" />
> <property name="jpaVendorAdapter" ref="jpaAdapter" />
> <property name="jpaProperties">
> <props>
> <prop
> key="openjpa.ConnectionURL">jdbc:sqlserver://10.10.10.11:1433;databaseName=XYZ;instanceName=SQLEXPRESS;</prop>
> <prop
> key="openjpa.jdbc.DBDictionary">org.apache.openjpa.jdbc.sql.SQLServerDictionary</prop>
> <prop
> key="openjpa.ConnectionDriverName">com.microsoft.sqlserver.jdbc.SQLServerDriver</prop>
> <prop key="openjpa.ConnectionUserName">user1</prop>
> <prop key="openjpa.ConnectionPassword">pass123</prop>
> <prop key="openjpa.Log">Enhance=TRACE,SQL=TRACE</prop>
> <prop key="openjpa.jdbc.SynchronizeMappings">true</prop>
> </props>
> </property>
> </bean>
>  
>  
> When I am persisting data using camel route its working perfectly fine, but
> when I am trying to access Entity manager through code its null.
>  
> @PersistenceContext(unitName = "com.baselogic.jpa")
> private EntityManager entityManager;
>  
> Can anybody tell me if I am missing anything ?
>  
> Thanks,
> Abhi
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Entity-Manager-is-null-tp5735076.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).



Reply via email to