I have a trouble deploying my sprint-boot
application (converted tp .war
) in liberty 8.5
:
Failed to instantiate [javax.persistence.EntityManager]:
Factory method 'createSharedEntityManager' threw exception;
nested exception is java.lang.LinkageError: loader constraint violation:
loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader)
previously initiated loading for a different type with name
"org/eclipse/persistence/expressions/Expression"
But when I run my spring-boot
application packaged as .jar
it works.
My persistence is
<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="authentication"
transaction-type="RESOURCE_LOCAL">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<class>
com.bank.arc.commons.entity.AuthenticationEntity
</class>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.target-server" value="WebSphere_Liberty"
/>
<property name="eclipselink.target-database"
value="org.eclipse.persistence.platform.database.DB2Platform" />
<property name="eclipselink.logging.level" value="WARNING" />
</properties>
</persistence-unit>
Class Database Config
@Configuration
@EnableTransactionManagement
@EnableConfigurationProperties(DbAuthenticationProperties.class)
@EnableJpaRepositories(basePackages = {"com.bank.arc.commons.dao.repository"},
entityManagerFactoryRef = "authenticationDbEntityManagerFactory",
transactionManagerRef = "authenticationDbTransactionManager")
public class DbAuthenticationConfig extends DbConfig {
@Autowired
private DbAuthenticationProperties properties;
@PostConstruct
public void init() {
super.setProperties(properties);
}
@Bean
@Primary
public DataSource authenticationDbDataSource() {
return super.dataSource();
}
@Bean
@Primary
public LocalContainerEntityManagerFactoryBean authenticationDbEntityManagerFactory() {
return super.entityManagerFactoryBean(authenticationDbDataSource(), authenticationDbJpaVendorAdapter(), "authentication");
}
@Bean
@Primary
protected JpaVendorAdapter authenticationDbJpaVendorAdapter() {
return super.jpaVendorAdapter(DatabasePlatform.DB2);
}
@Bean
@Primary
protected PlatformTransactionManager authenticationDbTransactionManager() {
return super.transactionManager(authenticationDbEntityManagerFactory());
}
}
And the server.xml:
<server description="new server">
<featureManager>
<feature>localConnector-1.0</feature>
<feature>jdbc-4.1</feature>
<feature>servlet-3.1</feature>
<feature>jpa-2.1</feature>
</featureManager>
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<jpa defaultPersistenceProvider="org.eclipse.persistence.jpa.PersistenceProvider" ignoreDataSourceErrors="true"/>
<applicationMonitor updateTrigger="mbean"/>
<webApplication id="authentication-endpoint" location="authentication-endpoint.war" name="authentication-endpoint"/>
</server>