I have the Spring Maven project using Java 11. Jboss WIldfly 15.0.1 Final is my deployment server.
To import data (objects using Hibernate) from one data source to another data source (MySQL)- I have added one primary entityManagerFactory
with JpaTransactionManager
and I have 2 other entity manager factories separate perisistenceUnits
and a chainedTransactionManager
being used(for 1 Phase commit-1PC commnit).
When deploying the war, sometimes, I get the below exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'someDAO': Injection of persistence dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'onetimeConfig': Injection of persistence dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'entityMgrFactory2' defined in class path resource [com/path/ImportConfig.class]: Bean
instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[javax.persistence.EntityManagerFactory]: Factory method 'entityMgrFactory2' threw exception;
nested exception is java.lang.IllegalStateException: 'url' not set
someDAO class header is:
@Transactional(rollbackFor = {Exception.class})
@Repository("someDAO")
public class SomeDAOImpl extends ParentDAOImpl implements SomeDAO {
The someDAO
class extends the ParentDAOImpl
class in which the primary entityManagerFactory
is used and is also mentioned using @DependsOn
. So, why does on deploy the creation of someDAO
is trying to trigger the creation of entityMgrFactory2
when entityManagerFactory
is mentioned in?!
@Repository("parentDAOImpl")
@DependsOn({"entityManagerFactory"})
public class ParentDAOImpl implements ParentDAO, Serializable {
@PersistenceContext
private transient EntityManager entityManager;
...
The problem never replicates on my local machine. It does occurs only while deploying on other servers and deployment fails due to this. And also the exception sometimes mentions someDAO
and other times a different DAOclass
that extends ParentDAOImpl
.
Please help me, I am a novice.