[JBoss JIRA] (ISPN-8975) RemoteCacheImpl instantiation fails in Spring
by Katia Aresti (Jira)
[ https://issues.redhat.com/browse/ISPN-8975?page=com.atlassian.jira.plugin... ]
Katia Aresti closed ISPN-8975.
------------------------------
Released prev 12
> RemoteCacheImpl instantiation fails in Spring
> ---------------------------------------------
>
> Key: ISPN-8975
> URL: https://issues.redhat.com/browse/ISPN-8975
> Project: Infinispan
> Issue Type: Bug
> Components: Spring Integration
> Affects Versions: 9.2.0.Final
> Reporter: Sebastian Laskawiec
> Assignee: Katia Aresti
> Priority: Major
> Attachments: build.zip
>
>
> {{RemoteCacheImpl}} contains reference to {{org.infinispan.query.dsl.Query}}, which is not always present on the classpath (it is an optional dependency). This prevents users from obtaining {{RemteCache}} by creating a bean:
> {code}
> @Bean
> public RemoteCache defaultCache(RemoteCacheManager remoteCacheManager) {
> return remoteCacheManager.getCache();
> }
> {code}
> In such a use case, Spring treats {{RemoteCache}} as its own bean and introspects it (scans all methods and fields and checks whether there are injection points or not). Once it hits {{Query}} it generates an exception:
> {code}
> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCache' defined in class path resource [hello/ApplicationConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.infinispan.client.hotrod.impl.RemoteCacheImpl] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@ba8a1dc]
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
> at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
> at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
> at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
> at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
> at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
> at hello.Application.main(Application.java:32) [main/:na]
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
> at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
> at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.0.RELEASE.jar:2.0.0.RELEASE]
> Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.infinispan.client.hotrod.impl.RemoteCacheImpl] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@ba8a1dc]
> at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:519) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:207) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:188) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(InitDestroyAnnotationBeanPostProcessor.java:127) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:297) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1016) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> ... 20 common frames omitted
> Caused by: java.lang.NoClassDefFoundError: org/infinispan/query/dsl/Query
> at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
> at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3139) ~[na:na]
> at java.base/java.lang.Class.getDeclaredMethods(Class.java:2266) ~[na:na]
> at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
> ... 27 common frames omitted
> Caused by: java.lang.ClassNotFoundException: org.infinispan.query.dsl.Query
> at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[na:na]
> at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) ~[na:na]
> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na]
> ... 31 common frames omitted
> {code}
> In my opinion the best to improve the situation is to refactor {{RemoteCacheImpl}} code so that it doesn't contain {{optional}} dependencies.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
3 years, 10 months
[JBoss JIRA] (ISPN-10122) Unable to start application using Infinispan on Client/Server mode with JMX enabled
by Katia Aresti (Jira)
[ https://issues.redhat.com/browse/ISPN-10122?page=com.atlassian.jira.plugi... ]
Katia Aresti closed ISPN-10122.
-------------------------------
Released prev 12
> Unable to start application using Infinispan on Client/Server mode with JMX enabled
> -----------------------------------------------------------------------------------
>
> Key: ISPN-10122
> URL: https://issues.redhat.com/browse/ISPN-10122
> Project: Infinispan
> Issue Type: Bug
> Components: Spring Integration
> Reporter: Katia Aresti
> Assignee: Katia Aresti
> Priority: Major
>
> A Spring-Boot application using Infinispan Client/Server with JMX enabled for the Infinispan Client won't start, unless you disable jmx spring.jmx.enabled=false.
> Infinispan already registers a bean that is registered by Spring, so we get the following exception on start:
> {code}
> org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.infinispan.client.hotrod.RemoteCacheManager@1d67f4e9] with key 'remoteCacheManager'; nested exception is javax.management.InstanceAlreadyExistsException: MXBean already registered with name org.infinispan:type=HotRodClient,name=Default
> at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
> at org.springframework.jmx.export.MBeanExporter.lambda$registerBeans$2(MBeanExporter.java:551) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
> at java.base/java.util.HashMap.forEach(HashMap.java:1336) ~[na:na]
> at org.
> {code}
> https://github.com/spring-projects/spring-boot/issues/16482
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
3 years, 10 months