java - Websphere 8.0.0.10 - EntityManager not injected (NullPointerException) -


in our application using 2 databases in 2 modules each own persistence.xml:

persistence.xml first :

<persistence-unit name="first-databasepu">  <mapping-file>meta-inf/dynamic_orm.xml</mapping-file>  <class>some.class.using.first.asdf</class> .... <properties>   <property name="hibernate.dialect" value="org.hibernate.dialect.sqlserverdialect" />   <property name="hibernate.max_fetch_depth" value="3" />   <property name="hibernate.show_sql" value="false" />   <property name="hibernate.default_batch_fetch_size" value="100" />   <property name="hibernate.cache.provider_class" value="org.hibernate.cache.nocacheprovider" /> </properties> 

and similar second :

<persistence-unit name="second-databasepu">  <mapping-file>meta-inf/dynamic_orm.xml</mapping-file>  <class>some.class.using.second.asdf</class> .... <properties>   <property name="hibernate.dialect" value="org.hibernate.dialect.sqlserverdialect" />   <property name="hibernate.max_fetch_depth" value="3" />   <property name="hibernate.show_sql" value="false" />   <property name="hibernate.default_batch_fetch_size" value="100" />   <property name="hibernate.cache.provider_class" value="org.hibernate.cache.nocacheprovider" /> </properties> 

example class of daobean :

@transactionattribute(transactionattributetype.required) public class asdf {     entitymanager entitymanager;      @persistencecontext(unitname="first-databasepu")     public void setentitymanager(entitymanager em) {         entitymanager = em;     }      public void somefunction() {         entitymanager.something();     } } 

normally our entitymanagers initialized correctly. set upped on websphere calling method somefunction() giving nullpointerexception.

did digging , found this

but after adding our web.xml :

<persistence-context-ref>     <persistence-context-ref-name>some/name/first</persistence-context-ref-name>     <persistence-unit-name>first-databasepu</persistence-unit-name> </persistence-context-ref>  <persistence-context-ref>     <persistence-context-ref-name>some/name/second</persistence-context-ref-name>     <persistence-unit-name>second-databasepu</persistence-unit-name> </persistence-context-ref> 

nothing has changed, next tried pull entitymanager directly jndi in this, failed.

so right searching idea why not work.

additional info: our websphere configured docker image using jthon scripts , wsadmin.sh. both datasources set upped. , application config can see them.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -