I have a problem, when I want to deploy my application on wildfly.
This is my persistence:
<persistence-unit name="jws" transaction-type="JTA">
<class>lv.lavloz.merrill.generator.v1.model.ID</class>
<jta-data-source>java:jboss/datasources/MySQL/JWSDS</jta-data-source>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
The connection url for the jndi java:jboss/datasources/MySQL/JWSDS is jdbc:mysql://localhost:3306/db.
And this is the ejb :
#Stateless
public class GeneratorBean {
#PersistenceContext(unitName = "jws")
private EntityManager em;
...
}
When I want to deploy my application to wildfly, I get the error message
java.lang.Exception: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"jws_ear.ear\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"jws_ear.ear\".WeldStartService: Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ParamConverterFactory with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public org.glassfish.jersey.server.internal.inject.MultivaluedParameterExtractorFactory(ParamConverterFactory)
at org.glassfish.jersey.server.internal.inject.MultivaluedParameterExtractorFactory.<init>(MultivaluedParameterExtractorFactory.java:0)
WELD-001474: Class org.glassfish.jersey.server.internal.inject.ParamConverterFactory is on the classpath, but was ignored because a class it references was not found: org.glassfish.hk2.api.ServiceLocator from [Module \"deployment.jws_ear.ear:main\" from Service Module Loader].
"}}
What to do?
This does not seem to be related to JPA at all.
Your error message referring to org.glassfish.jersey.server.internal indicates that your application has a dependency on Jersey.
Are you trying to port an application from GlassFish to WildFly? If so, you should eliminate all dependencies on Jersey and only use the JAX-RS APIs, or WildFly's JAX-RS implementation RESTEasy.
Jersey is not contained in WildFly.
Related
We have a custom keyloak user storage provide to use our proprietary user database for authentication.
This works perfectly fine with the WildFly based Keycloak. Since Keycloak will drop WildFly support in june 2022 according to their release notes, I am currently trying to get it running in the new, Quarkus based Keycloak distribution.
First I had to remove all dependencies provided by Quarkus since those lead to class loader issues. But now I am stuck with this error when I try to start Keycloak with the command ./kc.sh start-dev --log-level=ERROR:
Updating the configuration and installing your custom providers, if any. Please wait.
ERROR: Unexpected error when starting the server in (development) mode
ERROR: Failed to start quarkus
ERROR: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
ERROR: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.
And 'hibernate.dialect' is set in persistence.xml and configuring a persistance unit in persistence.xml should be supported according to quarkus documentation :
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="example-pu" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.example.keycloak.provider.db.entity.Benutzer</class>
<class>com.example.keycloak.provider.db.entity.BenutzerWithSource</class>
<class>com.example.keycloak.provider.db.entity.Rolle</class>
<class>com.example.keycloak.provider.db.entity.Parameter</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
</properties>
</persistence-unit>
</persistence>
Configuring the dialect in an application.properties (according to https://quarkus.io/guides/hibernate-orm#multiple-persistence-units) file in the delivery didn't change the behavior as well:
quarkus.hibernate-orm."example-pu".hibernate-dialect=org.hibernate.dialect.OracleDialect
What am I missing?
Additional Persistence Units are not supported in Keycloak 17.0.0 with Quarkus.
This should be fixed in Keycloak 18.0.0: https://github.com/keycloak/keycloak/pull/10581.
I was trying to create a hello world with JNoSQL, Mongo and Wildfly Swarm.
The use #Inject of DocumentCollectionManager is working, but it is not working with a Repository.
This is how I'm injecting:
#Inject
private DocumentCollectionManager entityManager; // works
#Inject
#Database(DatabaseType.DOCUMENT)
private UserRepository userRepository; // do not work!
This is how I configured the producer:
#ApplicationScoped
public class MongoProducer {
private static final String DATABASE = "db";
#Inject
#ConfigurationUnit(name = "document", fileName = "jnosql.yaml")
private DocumentCollectionManagerFactory<MongoDBDocumentCollectionManager> entityManager;
#Produces
#Database(DatabaseType.DOCUMENT)
public DocumentCollectionManager getManager() {
return entityManager.get(DATABASE);
}
}
What can I do to automatic inject Repositories in my Wildfly Swarm application?
The throwed error:
2018-05-23 11:30:31,270 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."demo.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."demo.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1978)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type UserRepository with qualifiers #Database
at injection point [BackedAnnotatedField] #Inject #Database private com.example.demo.rest.HelloWorldEndpoint.userRepository
at com.example.demo.rest.HelloWorldEndpoint.userRepository(HelloWorldEndpoint.java:0)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:362)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:137)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:158)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:501)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:61)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:59)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
2018-05-23 11:30:31,278 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "demo.war")) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"demo.war\".WeldStartService" => "Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type UserRepository with qualifiers #Database
at injection point [BackedAnnotatedField] #Inject #Database private com.example.demo.rest.HelloWorldEndpoint.userRepository
at com.example.demo.rest.HelloWorldEndpoint.userRepository(HelloWorldEndpoint.java:0)
"}}
2018-05-23 11:30:31,279 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "demo.war" was rolled back with the following failure message:
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"demo.war\".WeldStartService" => "Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type UserRepository with qualifiers #Database
at injection point [BackedAnnotatedField] #Inject #Database private com.example.demo.rest.HelloWorldEndpoint.userRepository
at com.example.demo.rest.HelloWorldEndpoint.userRepository(HelloWorldEndpoint.java:0)
"}}
how is going?
There're same bugs in your code:
The interface needs to be found by CDI, so I created a bean.xml to enable a full
scan in your code. On the MongoProducer you
don't need the: #Database(DatabaseType.DOCUMENT)
I created a PR:
https://github.com/vepo/wildly-swarm-jnosql/pull/1
I have created zuul proxy application using spring boot and I am able to deploy it as a spring boot and war in Wildfly server by making some changes in pom and SpringApplication class file.
Structure of my ear :
MyEE.ear
|
|__gatewayzull.war
|_WEB-INF/lib/all jar for spring boot application
|
|__EJB.jar
|
|__XX.war
|
|lib/all jar (which also includes spring jars)
I have done some changes in pom.xml to deploy spring application war in WildFly server and It is working as expected.
When I tried to add gatewayzull.war in MyEE.ear and deploy it in Wildfly server, I am getting this exception
10:08:47,108 INFO [com.hummingbird.gateway.HbgatewayApplication] (MSC service thread 1-4) No active profile set, falling back to default profiles: default
10:08:47,119 INFO [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (MSC service thread 1-4) Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#51640e39: startup date [Thu Jun 01 10:08:47 UTC 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#50b75933
....
....
....
....
10:08:56,635 WARN [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (MSC service thread 1-4) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$TransactionManagementConfiguration]; nested exception is java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
10:08:56,711 ERROR [org.springframework.boot.SpringApplication] (MSC service thread 1-4) Application startup failed: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$TransactionManagementConfiguration]; nested exception is java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:546) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:286) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
.....
.....
.....
Caused by: java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
at org.springframework.util.Assert.isAssignable(Assert.java:376) [spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.util.Assert.isAssignable(Assert.java:359) [spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:124) [spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:511) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
... 30 more
WildFly was trying to start Gatewayapplication but failed to start it.
jar inside gatewayzull.war.WEB-INF.lib not loaded.
deployment.MyEE.ear.lib also has spring related jar. I have added exclusion tag in jboss-deplyment-structure.xml inorder to exclude while loading but this also did not helps.
Snipper of jboss.xml :
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
..
..
<sub-deployment name="gateway.war">
<exclusions>
<module name="deployment.MyEE.ear.XX.war" />
<module name="deployment.MyEE.ear.EJB.jar" />
<module name="deployment.MyEE.ear.lib" />
<module name="javax.ws.rs.api" />
</exclusions>
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
</sub-deployment>
</jboss-deployment-structure>
I am assuming that core issue would be due to application server not able to load jar inside war/web-inf/lib and in turn server not intializing SpringBootServeletIntializer.
Any idea to resolve this ?
I have spring boot application setup. Now I need to add Spring JDBC Template to it. While doing this, I am facing below exception.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXX': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.jdbc.core.JdbcTemplate com..XXX.jdbcTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "LOCAL" are currently active).
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "LOCAL" are currently active).
Below is the code.
#Service
public class XXX {
#Autowired
JdbcTemplate jdbcTemplate;
public void testDataSource() {
List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from C_MASTER");
System.out.println("list : " + list);
}
}
Java Config
#Configuration
#ComponentScan
#EnableTransactionManagement
public class DAODataServiceManagerConfiguration {
#Bean
public DataSource getDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
dataSource.setUrl("jdbc:oracle:thin:#g9u1769.houston.hpecorp.net:1525:ODSDBD");
dataSource.setUsername("Solid_batch");
dataSource.setPassword("solid_batch123");
return dataSource;
}
}
As spring boot looks for application.properties, I have added that too in the resources directory.
appliation.properties.
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:#g9u1769.houston.hpecorp.net:1525:ODSDBD
spring.datasource.username=Solid_batch
spring.datasource.password=solid_batch123
spring.datasource.initialize=true
It is unable to build the application. Correct me if I am doing anything wrong.
You are missing ojdbc jar in your project classpath, follow below steps to download, install and use it as a dependency:
Download ojdbc6.jar from here.
Install it, running command -
mvn install:install-file -Dfile={Path/to/your/ojdbc.jar} -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
For jar version, extract the jar file and check the Implementation-Version in MANIFEST.MF, for instance:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_51-b10 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle Corporation
Implementation-Title: JDBC
Implementation-Version: 11.2.0.4.0
Repository-Id: JAVAVM_11.2.0.4.0_LINUX.X64_RELEASE
Specification-Vendor: Sun Microsystems Inc.
Specification-Title: JDBC
Specification-Version: 4.0
Main-Class: oracle.jdbc.OracleDriver
sealed: true
Name: oracle/sql/converter/
Sealed: false
Name: oracle/sql/
Sealed: false
Name: oracle/sql/converter_xcharset/
Sealed: false
Name: oracle/replay/driver/
Sealed: false
Add as a dependency in the project, as follows:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
Use jdbctemplate by extends JdbcDaoSupport .
By it programmer not concern about the open and close the connection.
Use commons-dbcp2-2.1.1.jar and commons-pool2-2.4.2.jar for use dbcp2 because dbcp2 support Connection pooling.
It's a technique to allow multiple clinets to make use of a cached set of shared and reusable connection objects providing access to a database
public class XXX extends JdbcDaoSupport {
public void testDataSource() {
List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from C_MASTER");
System.out.println("list : " + list);
}
}
In spring.xml write
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:mysql://127.0.0.1:3306/database_name" />
<property name="username" value="username" />
<property name="password" value="password" />
</bean>
<bean id="xXX" class="your_package_name.XXX">
<property name="dataSource" ref="dataSource" />
</bean>
I have gone through spring boot reference document. I came to know that if we are using (H2, HSQL or Derby) databases then we don't require application.properties.
If the project is having Oracle database, then application.properties should be updated. In my case I have updated the properties file.
So I have updated only following things, then it worked properly.
pom.xml
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
configuration file
#Configuration
public class DaoConfig {
#Bean
public DataSource getDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("oracle.jdbc.OracleDriver");
dataSource.setUrl("xxx");
dataSource.setUsername("xxx");
dataSource.setPassword("xxx");
return dataSource;
}
#Bean
public JdbcTemplate getJdbcTemplate() {
return new JdbcTemplate(getDataSource());
}
I hope this might help someone.
Thanks #ChrisThompson and #Arpit
I got a stupid problem when deploying my Java Application on JBoss. Before I changed my source code using an interface class everything was fine. So here is my problem:
public interface FWInterface {
public FWResult process(FWRequest fwRequest, FWResult fwResult,
Integer commitRows) throws Exception;
}
...
#Stateless
public class FWHandlerSqrMind extends FWHandlerDefault implements FWInterface {
public FWResult process(FWRequest fwRequest, FWResult fwResult, Integer commitRows)
throws Exception {
... some JavaCode here
}
}
This ends up with the following Error at deployment on JBoss 7.1:
10:05:34,838 ERROR [org.jboss.msc.service.fail] (MSC service thread
1-6) MSC00001: Failed to start service
jboss.deployment.unit."mdk-exchange-1.1.0.war".WeldService:
org.jboss.msc.service.StartException in service
jboss.deployment.unit."mdk-exchange-1.1.0.war".WeldService:
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied
dependencies for type [FWHandlerAufTracking] with qualifiers
[#Default] at injection point [[field] #Inject
de.mdkbw.exchange.filewatcher.FWMain.fwhAufTracking] at
org.jboss.as.weld.services.WeldService.start(WeldService.java:83) at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
[jboss-msc-1.0.2.GA.jar:1.0.2.GA] at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
[jboss-msc-1.0.2.GA.jar:1.0.2.GA] at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[rt.jar:1.7.0_15] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[rt.jar:1.7.0_15] at java.lang.Thread.run(Unknown Source)
[rt.jar:1.7.0_15] Caused by:
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied
dependencies for type [FWHandlerAufTracking] with qualifiers
[#Default] at injection point [[field] #Inject
de.mdkbw.exchange.filewatcher.FWMain.fwhAufTracking] at
org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:311)
at
org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280)
at
org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143)
at
org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163)
at
org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382)
at
org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367)
at
org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83) at
org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
If I remove the implementation everything is ok. Could anybody tell me what the problem is? Am I too stupid?? Thanks in advance!
How do you inject your bean? Like that?
#Inject
private FWHandlerSqrMind handler;
If so could you try to inject it like that:
#Inject
private FWInterface handler;
Do you have META-INF/beans.xml or WEB-INF/beans.xml file in your class path?
Missing beans.xml was the problem in my case (WildFly 8.2.0).
Just placing a simple beans.xml like the following solved this problem:
<?xml version="1.0"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd" />