ehcache giving error after migrating spring boot from 1.5.12 to 1.5.13 - spring-boot

I have configured spring boot 1.5.12 + ehcache and everything was working fine until I upgraded spring boot to 1.5.13
application.yml has the below entry
spring:
cache:
jcache:
provider: org.ehcache.jsr107.EhcacheCachingProvider
config: ehcache.xml
my ehcache.xml is located under resources directory
The error I am receiving is:
Caused by: java.lang.IllegalArgumentException: Cache configuration does not exist 'ServletContext resource [/ehcache.xml]'
at org.springframework.util.Assert.isTrue(Assert.java:92)
at org.springframework.boot.autoconfigure.cache.CacheProperties.resolveConfigLocation(CacheProperties.java:117)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.createCacheManager(JCacheCacheConfiguration.java:113)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.jCacheCacheManager(JCacheCacheConfiguration.java:97)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047.CGLIB$jCacheCacheManager$1(<generated>)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047$$FastClassBySpringCGLIB$$a6ae7187.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047.jCacheCacheManager(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 47 common frames omitted
It looks like spring boot has started searching for ehcache.xml using servletContext resolver.
p.s. I had made no change in any of source code except the spring boot upgrade to 1.5.13
Am I missing some required configuration here?

I had figured out the fix for this problem. We need to specify the prefix classpath: with the file name to make it work.
My application.yml would look like this now
spring:
cache:
jcache:
provider: org.ehcache.jsr107.EhcacheCachingProvider
config: classpath:ehcache.xml
Hope that helps.

Related

java.lang.IllegalStateException: Unable to load config data from 'http://localhost:8888'

I am facing an issue with Spring cloud. The used versions are,
Spring boot version: 2.4.4
Spring cloud version: 2020.0.2
Your input will help me to resolve the microservice startup issue.
I have a spring cloud config server which pick the data from repository and the endpoint
http://localhost:8888/xyz-service/default returning data.
I am trying to read the configuration from microservice which fails to connect to the config server, please refer below error
13:25:09.887 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
*java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:http://localhost:8888*'
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:125)
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:112)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.lambda$resolve$1(ConfigDataLocationResolvers.java:114)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:125)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:114)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:106)
at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:101)
at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:93)
at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:81)
at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:119)
at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:230)
at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:217)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:88)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:80)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:100)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:86)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1510)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
at com.microservice.limitmicroservice.LimitMicroserviceApplication.main(LimitMicroserviceApplication.java:10)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/'
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferencesForFile(StandardConfigDataLocationResolver.java:200)
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:122)
... 35 common frames omitted
Process finished with exit code 0
I see the person did not answer, I have two different applications. They have the same config and the same POM but one gives me this error.
This is the config for both applications, both uses spring boot version 2.4.4, uses java 11, spring cloud 2020.0.2
spring.cloud.config.enabled=false
spring.jmx.enabled=true
management.endpoints.web.exposure.include=*
but the second one fails with similar the error than above
java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:'
Make sure you have the following dependency in your pom.xml:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
The main reason for this problem is that spring boot does not know how to read the configuration from (for example) repository on github. To solve this problem, you should check whether the following dependency exists in the corresponding module (versions can be different) :
implementation 'org.springframework.cloud:spring-cloud-starter-config:3.1.5'
Connecting this starter should solve your problem

Creating Kafka Custom Authorizer with Spring?

I have setup a customer authorizer by setting below properties in server.properties
authorizer.class.name= {package_name}.myAuthorizer
And myAuthorizer.java implements from kafka.security.auth.Authorizer
And included the myAuthorizer.jar in the libs directory.
It is working as expected but I am wondering if I can include the application properties using Dependency Injection.
I have tried to migrate the current working myAuthorizer to Spring project and running on the IDE is successful, but in the broker I am getting this exception:
java.lang.ClassNotFoundException: {package_name}.myAuthorizer
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at org.apache.kafka.common.utils.Utils.loadClass(Utils.java:374)
at org.apache.kafka.common.utils.Utils.newInstance(Utils.java:363)
at kafka.security.authorizer.AuthorizerUtils$.createAuthorizer(AuthorizerUtils.scala:38)
at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1417)
at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1273)
at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:34)
at kafka.Kafka$.main(Kafka.scala:68)
at kafka.Kafka.main(Kafka.scala)
For the custom Authorizer, can I build as Spring Java project? Or should I leave it as Java project?

Liferay upgrade 7.2 to register spring beans with osgi

While I am trying to configure a spring mvc portlet with beans and bring up the deployed war on my server I get following errors
I tried all the stuff related to spring inorder to solve NameSpaceHandler issue, but I still get error related to portlet.xml, registration of beans with container
I am using spring 4.2.5-RELEASE and XML schema all I using 3.0 version for XSD inorder for it to be compliant with webapp 3.0 XSD just to be safe.
Logs are as mentioned below
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]_Offending resource: ServletContext resource [/WEB-INF/spring-context/portlet-application-context.xml]_ [Sanitized]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:118)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:110)
2020-05-18 08:16:53.947 ERROR [fileinstall-/project_war_Path/][HotDeployImpl:232] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering servlet context listeners for project-spring-portlet-1.0.0
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering servlet context listeners for project-spring-portlet-1.0.0
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:38)
at com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener.invokeDeploy(ServletContextListenerHotDeployListener.java:40)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:229)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener.doInvokeDeploy(ServletContextListenerHotDeployListener.java:73)
at com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener.invokeDeploy(ServletContextListenerHotDeployListener.java:37)
... 63 more
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]_Offending resource: ServletContext resource [/WEB-INF/spring-context/portlet-application-context.xml]_ [Sanitized]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:118)
2020-05-18 08:16:53.957 WARN [fileinstall-/project_war_Path/][PortletLocalServiceImpl:881] Portlet with the name apiusersspring_WAR_apiusersspringportlet100 is described in portlet.xml but does not have a matching entry in liferay-portlet.xml
2020-05-18 08:16:53.958 WARN [fileinstall-/project_war_Path/][PortletLocalServiceImpl:893] Portlet with the name apiusersspringportlet_WAR_apiusersspringportlet100 is described in liferay-portlet.xml but does not have a matching entry in portlet.xml
2020-05-18 08:16:53.958 ERROR [fileinstall-/project_war_Path/][PortletBagFactory:288] java.lang.ClassNotFoundException: org.springframework.web.portlet.DispatcherPortlet cannot be found by project-spring-portlet-1.0.0_1.0.0
java.lang.ClassNotFoundException: org.springframework.web.portlet.DispatcherPortlet cannot be found by project-spring-portlet-1.0.0_1.0.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:508)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:419)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:411)
2020-05-18 08:16:53.963 ERROR [fileinstall-/project_war_Path/][PortletBagFactory:214] javax.portlet.PortletException: java.lang.NullPointerException
javax.portlet.PortletException: java.lang.NullPointerException
at com.liferay.portlet.internal.InvokerPortletFactoryImpl.create(InvokerPortletFactoryImpl.java:111)
at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortletFactoryImpl.create(MonitoringInvokerPortletFactoryImpl.java:115)
at com.liferay.portlet.internal.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:275)
at com.liferay.portlet.internal.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:181)
Caused by: java.lang.NullPointerException
at com.liferay.portlet.internal.InvokerPortletImpl.<init>(InvokerPortletImpl.java:122)
at com.liferay.portlet.internal.InvokerPortletFactoryImpl.create(InvokerPortletFactoryImpl.java:107)
... 80 more
2020-05-18 08:16:53.966 ERROR [fileinstall-/project_war_Path/][HotDeployImpl:232] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for project-spring-portlet-1.0.0
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for project-spring-portlet-1.0.0
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:38)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:99)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:229)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:189)

Spring boot remote Websphere EJB call

I have Websphere thin client jars in my classpath and a sample spring boot application. I am unable to make remote ejb call because it is throwing corab exception. I am using oracle jdk1.8 to make websphere ejb call
09:50:28.505 com.ibm.rmi.corba.PluginRegistry instantiatePlugins:119 P=428317:O=0:CT ORBRas[default] java.lang.ClassNotFoundException: com.ibm.ws.wlm.client.WLMClient (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:396)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:186)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:637)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:219)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:152)
at com.sun.corba.se.impl.util.JDKBridge.loadClassM(JDKBridge.java:189)
at com.sun.corba.se.impl.util.JDKBridge.loadClass(JDKBridge.java:86)
at com.sun.corba.se.impl.javax.rmi.CORBA.Util.loadClass(Util.java:602)
at javax.rmi.CORBA.Util.loadClass(Util.java:265)
at com.ibm.rmi.corba.PluginRegistry.instantiatePlugins(PluginRegistry.java:116)
at com.ibm.rmi.corba.ORB.instantiatePlugins(ORB.java:1518)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1423)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1349)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1697)
at org.omg.CORBA.ORB.init(ORB.java:353)
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:92)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:169)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:64)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:44)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:505)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:466)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:128)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:765)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:164)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
at org.springframework.jndi.JndiLocatorDelegate.lookup(JndiLoc
The above log shows the corba errors generated by ibm jar files.
java.lang.ClassNotFoundException: com.ibm.ws.wlm.client.WLMClient
Looks like this is the class you're missing.
You'll need to add the com.ibm.ws.wlm.jar to your class path.

Spring Boot 1.4 to 1.5, unable to deploy

I have a very large and working Spring Boot project that is running OK with Boot 1.4.2. When I try to upgrade to 1.5.3 it works from my IDE (Intellij Idea) but it does not work on deployment. It's a Maven project, so I use the "package" directive to generate a WAR file and I get the error bellow on deployment. From what I can see, it says something is missing on the WAR but I even inspected it and the files are there... Any ideas?
Caused by: java.io.FileNotFoundException: file:(...)/target/ultraip-intranet-2.0-RELEASE.war*/WEB-INF/classes/com/ultraip/intranet/entities (No such file or directory)
at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_131]
at java.util.zip.ZipFile.<init>(ZipFile.java:219) ~[na:1.8.0_131]
at java.util.zip.ZipFile.<init>(ZipFile.java:149) ~[na:1.8.0_131]
at java.util.jar.JarFile.<init>(JarFile.java:166) ~[na:1.8.0_131]
at java.util.jar.JarFile.<init>(JarFile.java:103) ~[na:1.8.0_131]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingJarResources(PathMatchingResourcePatternResolver.java:593) ~[spring-core-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:475) ~[spring-core-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:279) ~[spring-core-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.buildDefaultPersistenceUnitInfo(DefaultPersistenceUnitManager.java:525) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
... 105 common frames omitted
Screenshot of the generated WAR file
http://imgur.com/a/5aORQ
A change was made in Tomcat such that it now uses a * as the separator in war:file: URLs. This broke Spring Framework's resource resolution where the * was incorrectly interpreted as a wildcard.
The problem should have been been fixed in Spring Framework 4.3.8 which is used in Spring Boot 1.5.3 but it appears that you have found a case that wasn't considered. Can you please open a Spring Boot issue with a small sample that reproduces the problem?
You don't see the problem when you package your application as a jar file as that stops Tomcat from producing war:file: URLs for resources.

Resources