Injecting JOOQ Context using CDI and JNDI - java

I try to use jooq on an PostgreSQL Database. The Web-App is built on the JSF Framework using CDI for dependency injection. The server is WildFly 11.
I use the jooq codegen to generate pojos and daos.
Following the instructions on http://awolski.com/integrating-jooq-easy/
I should be able to inject the DSLContext into any class. When I try to inject it into a controller bean which looks like
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
#Named
#RequestScoped
public class FooView implements Serializable {
private #Inject DSLContext jooq;
...
it simply doesn't work. The framework just doesn't instantiate the Foo.
What am I missing?
The server.log reads as follows:
WARN [org.jboss.modules] (Weld Thread Pool -- 4) Failed to define class model.tables.FooDao in Module "deployment.project.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link model/tables/Foo (Module "deployment.project.war" from Service Module Loader): org/jooq/impl/TableImpl
...
INFO [org.jboss.as.server] (management-handler-thread - 2) WFLYSRV0010: Deployed "project.war" (runtime-name : "project.war")
...
WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-22) /project/Foo.xhtml #9,91 value="#{FooView.attr}": Target Unreachable, identifier 'FooView' resolved to null: javax.el.PropertyNotFoundException: /project/Foo.xhtml #9,91 value="#{FooView.attr}": Target Unreachable, identifier 'FooView' resolved to null
...
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'FooView' resolved to null
...
ERROR [io.undertow.request] (default task-22) UT005023: Exception handling request to /project/project/Foo.xhtml: javax.servlet.ServletException: /project/Foo.xhtml #9,91 value="#{FooView.attr}": Target Unreachable, identifier 'FooView' resolved to null
...
Caused by: javax.el.PropertyNotFoundException: /project/Foo.xhtml #9,91 value="#{FooView.attr}": Target Unreachable, identifier 'FooView' resolved to null
...
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'FooView' resolved to null
As soon as I remove the injected attribute from FooView, no errors show up, despite that warning.

Related

Kie Business Central Installation Failed

I try to install Business Workbench downloaded from drools site here
into latest WildFly server but always failed with below error:
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"business-central.war\".WeldStartService" => "Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 2 exceptions:
Exception 0 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type KeyCloakUserManager with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public org.uberfire.ext.security.management.keycloak.KCCredentialsUserManagementService(KeyCloakUserManager, KeyCloakGroupManager, CredentialsClientFactory, #Named UberfireRoleManager)
at org.uberfire.ext.security.management.keycloak.KCCredentialsUserManagementService.<init>(KCCredentialsUserManagementService.java:0)
WELD-001474: Class org.uberfire.ext.security.management.keycloak.KeyCloakUserManager is on the classpath, but was ignored because a class it references was not found: org.jboss.resteasy.client.ClientResponseFailure from [Module \"deployment.business-central.war\" from Service Module Loader].
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:378)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:290)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:143)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:164)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:526)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:64)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:62)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1589)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Exception 1 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type KeyCloakGroupManager with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedConstructor] #Inject public org.uberfire.ext.security.management.keycloak.KCAdapterUserManagementService(KeyCloakUserManager, KeyCloakGroupManager, KCAdapterClientFactory, HttpServletRequest, #Named UberfireRoleManager)
at org.uberfire.ext.security.management.keycloak.KCAdapterUserManagementService.<init>(KCAdapterUserManagementService.java:0)
WELD-001474: Class org.uberfire.ext.security.management.keycloak.KeyCloakGroupManager is on the classpath, but was ignored because a class it references was not found: org.jboss.resteasy.client.ClientResponseFailure from [Module \"deployment.business-central.war\" from Service Module Loader].
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:378)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:290)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:143)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:164)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:526)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:64)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:62)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
at org.jboss.weld.core#3.1.9.Final//org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1589)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Please I need some help on how to deploy this. Thanks.

Infinispan 13.0.6 - Error putting custom java classes (POJO) in cache via WildFly 26.0.1.Final

I'm using WildFly26.0.1.Final to connect to Infinispan 13.0.6 and when I try to put an POJO object in a Infinispan cache I got this error:
Caused by: org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=15 returned server error (status=0x85): org.infinispan.commons.CacheException: ISPN000936: Class 'pt.pe.sipe.storefrontmanager.api.artigo.SampleDTO' blocked by deserialization allow list. Adjust the configuration serialization allow list regular expression to include this class."}}
My configuration is:
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer().host("server")
.port(11222)
.security()
.authentication()
.username("admin")
.password("password")
.addJavaSerialWhiteList("pt.pe.sipe.*") //you can set the class name or use regex
.marshaller(JavaSerializationMarshaller.class);
RemoteCacheManager rim = new RemoteCacheManager(builder.build());
cache = rim.getCache("teste15Fev22");
SampleDTO fd = new SampleDTO();
fd.setDescTipo("Franqueira");
System.out.println("A adicionar à cache A");
cache.put("A", fd);
System.out.println("Em cache: "+cache.get("A").getClass());
The full stack trace is:
2022-02-16 17:41:51,825 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 215) MSC000001: Failed to start service jboss.deployment.subunit."emporium-ear.ear"."emporium-ejb.jar".component.CacheManager.START: org.jboss.msc.service.StartException in service jboss.deployment.subunit."emporium-ear.ear"."emporium-ejb.jar".component.CacheManager.START: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
at org.jboss.as.ee#26.0.1.Final//org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:57)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
at org.jboss.as.ee#26.0.1.Final//org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:170)
at org.jboss.as.ee#26.0.1.Final//org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:141)
at org.jboss.as.ee#26.0.1.Final//org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)
at org.jboss.as.ejb3#26.0.1.Final//org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:127)
at org.jboss.as.ejb3#26.0.1.Final//org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:141)
at org.jboss.as.ee#26.0.1.Final//org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)
... 8 more
Caused by: javax.ejb.EJBException: org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=15 returned server error (status=0x85): org.infinispan.commons.CacheException: ISPN000936: Class 'pt.pe.sipe.storefrontmanager.api.artigo.SampleDTO' blocked by deserialization allow list. Adjust the configuration serialization allow list regular expression to include this class.
at org.jboss.as.ejb3#26.0.1.Final//org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInNoTx(CMTTxInterceptor.java:239)
at org.jboss.as.ejb3#26.0.1.Final//org.jboss.as.ejb3.tx.CMTTxInterceptor.supports(CMTTxInterceptor.java:446)
at org.jboss.as.ejb3#26.0.1.Final//org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:70)
at org.jboss.invocation#1.7.0.Final//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld#26.0.1.Final//org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)
at org.jboss.invocation#1.7.0.Final//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ejb3#26.0.1.Final//org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
at org.jboss.invocation#1.7.0.Final//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ee#26.0.1.Final//org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
at org.jboss.invocation#1.7.0.Final//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation#1.7.0.Final//org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)
at org.jboss.invocation#1.7.0.Final//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ejb3#26.0.1.Final//org.jboss.as.ejb3.component.singleton.StartupCountDownInterceptor.processInvocation(StartupCountDownInterceptor.java:25)
at org.jboss.invocation#1.7.0.Final//org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation#1.7.0.Final//org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
at org.jboss.as.ee#26.0.1.Final//org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:168)
... 13 more
Caused by: org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=15 returned server error (status=0x85): org.infinispan.commons.CacheException: ISPN000936: Class 'pt.pe.sipe.storefrontmanager.api.artigo.SampleDTO' blocked by deserialization allow list. Adjust the configuration serialization allow list regular expression to include this class.
at deployment.emporium-ear.ear.org.infinispan-infinispan-client-hotrod-13.0.6.Final.jar//org.infinispan.client.hotrod.impl.protocol.Codec20.checkForErrorsInResponseStatus(Codec20.java:323)
at deployment.emporium-ear.ear.org.infinispan-infinispan-client-hotrod-13.0.6.Final.jar//org.infinispan.client.hotrod.impl.protocol.Codec20.readHeader(Codec20.java:168)
at deployment.emporium-ear.ear.org.infinispan-infinispan-client-hotrod-13.0.6.Final.jar//org.infinispan.client.hotrod.impl.transport.netty.HeaderDecoder.decode(HeaderDecoder.java:139)
at deployment.emporium-ear.ear.org.infinispan-infinispan-client-hotrod-13.0.6.Final.jar//org.infinispan.client.hotrod.impl.transport.netty.HintedReplayingDecoder.callDecode(HintedReplayingDecoder.java:94)
at deployment.emporium-ear.ear.io.netty-netty-codec-4.1.72.Final.jar//io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at deployment.emporium-ear.ear.io.netty-netty-handler-4.1.72.Final.jar//io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
at deployment.emporium-ear.ear.io.netty-netty-transport-4.1.72.Final.jar//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
at deployment.emporium-ear.ear.io.netty-netty-common-4.1.72.Final.jar//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at deployment.emporium-ear.ear.io.netty-netty-common-4.1.72.Final.jar//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
2022-02-16 17:41:51,826 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit."emporium-ear.ear"."emporium-ejb.jar".component.CacheManager.START" => "java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
Caused by: javax.ejb.EJBException: org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=15 returned server error (status=0x85): org.infinispan.commons.CacheException: ISPN000936: Class 'pt.pe.sipe.storefrontmanager.api.artigo.SampleDTO' blocked by deserialization allow list. Adjust the configuration serialization allow list regular expression to include this class.
Caused by: org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=15 returned server error (status=0x85): org.infinispan.commons.CacheException: ISPN000936: Class 'pt.pe.sipe.storefrontmanager.api.artigo.SampleDTO' blocked by deserialization allow list. Adjust the configuration serialization allow list regular expression to include this class."}}
2022-02-16 17:41:51,826 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit."emporium-ear.ear"."emporium-ejb.jar".component.CacheManager.START" => "java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
Caused by: javax.ejb.EJBException: org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=15 returned server error (status=0x85): org.infinispan.commons.CacheException: ISPN000936: Class 'pt.pe.sipe.storefrontmanager.api.artigo.SampleDTO' blocked by deserialization allow list. Adjust the configuration serialization allow list regular expression to include this class.
Caused by: org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=15 returned server error (status=0x85): org.infinispan.commons.CacheException: ISPN000936: Class 'pt.pe.sipe.storefrontmanager.api.artigo.SampleDTO' blocked by deserialization allow list. Adjust the configuration serialization allow list regular expression to include this class."}}
Thanks, Manuel
The answer is in the cache configuration. In earlier versions of Infinispan we need to define/create a cache. In older versions I use default cache and have no problem.
My working cache configuration:
{
"distributed-cache": {
"mode": "SYNC",
"statistics": true,
"encoding": {
"key": {
"media-type": "application/x-java-serialized-object"
},
"value": {
"media-type": "application/x-java-serialized-object"
}
}
}
}
Permissions problem I had in past (blocked by deserialization allow list. Adjust the configuration serialization allow list regular expression to include this class.) accessing classes manifested itself when I had the following configuration media-type "application/x-java-object". This configuration does not work!
Thanks for your help!

HstSiteConfigurer: ComponentManager initialization failed

I'm working on One Hippo CMS, when I run the Tomcat server I'm getting this error
5.02.2019 18:23:45 ERROR main [DefaultHstSiteConfigurer.initializeComponentManager:264] HstSiteConfigurer: ComponentManager initialization failed.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.hippoecm.hst.content.beans.manager.ObjectConverter' defined in class path resource [org/hippoecm/hst/site/container/SpringComponentManager-content-beans.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Annotated class 'org.example.myproject.beans.Urldemo' for primarytype 'myproject:urldemo' is a duplicate of already registered class 'org.example.myproject.beans.Simple'. You might have configured a bean that does not have a annotation for the jcrType and inherits the jcrType from the bean it extends, resulting in 2 beans with the same jcrType. Correct your beans.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745) ~[spring-beans-5.1.1.RELEASE.jar:5.1.1.RELEASE]
Check the annotations on:
org.example.myproject.beans.Urldemo
org.example.myproject.beans.Simple
They should each have an annotation similar to:
#Node(jcrType = "project:doctype")
Each needs a unique jcrType value.

Playframework [2.6.6] to [2.7.0] causes CreationException

I try to migrate my play 2.6.6 application to 2.7.0. I am using Hibernate 4.2.3-Final. Does anybody know the cause of those Exceptions?
GeneralDao.java:71 is:
#Inject
public GeneralDao(JPAApi jpaApi) {}
OnStartup.java:66 is similar to above.
CreationException: Unable to create injector, see the following errors
1) Error injecting constructor, javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
at play.db.jpa.DefaultJPAApi$JPAApiProvider.<init>(DefaultJPAApi.java:59)
at play.db.jpa.DefaultJPAApi$JPAApiProvider.class(DefaultJPAApi.java:50)
while locating play.db.jpa.JPAApi
for the 1st parameter of dao.GeneralDao.<init>(GeneralDao.java:71)
for the 2nd parameter of modules.OnStartup.<init>(OnStartup.java:66)
at modules.OnStartupModule.configure(OnStartupModule.java:10) (via modules: com.google.inject.util.Modules$OverrideModule -> modules.OnStartupModule)
while locating modules.OnStartup
Caused by: javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
[cut]
Caused by: java.lang.RuntimeException: Error while reading file:/R:/appDir/target/scala-2.12/classes/
at org.hibernate.ejb.packaging.NativeScanner.getClassesInJar(NativeScanner.java:131)
[cut]
Caused by: java.io.IOException: invalid constant type: 18
[cut]
Full Stacktrace: https://pastebin.com/nEt1iavu
Updating to Hibernate 4.2.8-Final resolved the errors.
Thank you Stephen C for the hint.

How to deploy play framework 2.4 application on glassfish and read application.conf

I tried to deploy play framework 2.4 application on glassfish.
I used maven play2 plugin and made war file with the following instruction.
https://play2-maven-plugin.github.io/play2-maven-plugin/1.0.0-beta4/war-packaging.html
After that, I tried to deploy my war from glassfish console, but it returned the following error.
Error occurred during deployment: Exception while loading the app :
CDI deployment failure:Exception List with 3 exceptions:
Exception 0 : org.jboss.weld.exceptions.DeploymentException:
WELD-001408: Unsatisfied dependencies for type Environment with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public play.api.db.BoneConnectionPool(Environment)
at play.api.db.BoneConnectionPool.<init>(BoneConnectionPool.java:0)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:370)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:291)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:165)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:529)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:515)
at org.jboss.weld.bootst .... msg.seeServerLog
Error occurred during deployment: Exception while loading the app :
CDI deployment failure:
WELD-001408: Unsatisfied dependencies for type Database with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public modules.MyBatisModule$PlayDataSourceProvider(Database)
at modules.MyBatisModule$PlayDataSourceProvider.<init>(PlayDataSourceProvider.java:0) .
Please see server.log for more details.
And MyBatisModule is like this.
public class MyBatisModule extends org.mybatis.guice.MyBatisModule {
#Override
protected void initialize() {
environmentId("development");
bindConstant().annotatedWith(Names.named("mybatis.configuration.failFast")).to(true);
bindDataSourceProviderType(PlayDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
addMapperClasses();
}
#Singleton
public static class PlayDataSourceProvider implements Provider<DataSource> {
final Database db;
#Inject
public PlayDataSourceProvider(final Database db) {
this.db = db;
}
public DataSource get() {
return db.getDataSource();
}
}
I think the application can't read application.conf that containts DB setting. But I'm not sure.
Could you give me any advices?
Update 2015/01/13
I disabled "Implicit CDI" option on glassfish console when I deployed application.
I don't get the first error now, but I get another error...
Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.google.inject.CreationException:
Unable to create injector, see the following errors:
1) Error in custom provider, Configuration error: Configuration error
[Cannot connect to database [default]] while locating play.api.db.DBApiProvider while locating play.api.db.DBApi for parameter 0
at play.db.DefaultDBApi.<init>(DefaultDBApi.java:28)
at play.db.DefaultDBApi.class(DefaultDBApi.java:28) while locating play.db.DefaultDBApi while locating play.db.DBApi for field
at play.db.DBModule$NamedDatabaseProvider.dbApi(DBModule.java:61) while locating play.db.DBModule$NamedDatabaseProvider
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149)
at play.db.DBModule.bindings(DBModule.java:40): Binding(interface play.db.Database qualified with QualifierInstanc .... msg.seeServerLog
My conf/application.conf is here:
db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:#url..."
db.default.username=username
db.default.password=password
And it works on local environment.
I think glassfish can't read application.conf in war file.
I'm sorry. Could you give me the advice again?
Update 2015/01/14
The following is the part of full log.
Caused by: Configuration error: Configuration error[Exception during pool initialization]
at play.api.Configuration$.configError(Configuration.scala:178)
at play.api.PlayConfig.reportError(Configuration.scala:1048)
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:69)
at play.api.db.PooledDatabase.createDataSource(Databases.scala:199)
at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:124)
at play.api.db.DefaultDatabase.dataSource(Databases.scala:122)
at play.api.db.DefaultDatabase.getConnection(Databases.scala:143)
at play.api.db.DefaultDatabase.getConnection(Databases.scala:139)
at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:44)
... 130 more
Caused by: com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:542)
at com.zaxxer.hikari.pool.BaseHikariPool.<init>(BaseHikariPool.java:171)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:60)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:48)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:80)
at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:58)
at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:54)
at scala.util.Try$.apply(Try.scala:191)
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54)
... 136 more
Caused by: java.sql.SQLException: JDBC4 Connection.isValid() method not supported, connection test query must be configured
at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:441)
at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:540)
... 144 more
3) Error in custom provider, java.lang.NullPointerException
at play.db.DBModule.bindings(DBModule.java:40):
Binding(interface play.db.Database qualified with QualifierInstance(#play.db.NamedDatabase(value=default)) to ProviderTarget(play.db.DBModule$NamedDatabaseProvider#34850279)) (vi
a modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
while locating play.db.Database annotated with #play.db.NamedDatabase(value=default)
Some thoughts (it should be comment, but I cannot write comments on SO yet).
If your application.conf file is inside WEB-INF/classes directory, it should be found (more info - https://www.playframework.com/documentation/2.4.x/ProductionConfiguration#Specifying-an-alternate-configuration-file).
Does war file contain JDBC driver?
Maybe you should configure JNDI - https://www.playframework.com/documentation/2.4.x/ScalaDatabaseOthers#Exposing-the-datasource-through-JNDI
My problem cause is that:
Caused by: java.sql.SQLException: JDBC4 Connection.isValid() method not supported, connection test query must be configured
https://www.playframework.com/documentation/2.4.x/Migration24#JDBC-connection-pool
After I add the following setting on application.conf, it works.
(This sql is for Oracle DB.)
db.default.hikaricp.connectionTestQuery="SELECT 1 FROM DUAL"
Thank you for your help!

Categories