spring-rabbit examples compatible with Java 1.6 - spring-rabbit

we have an requirement to write RABBIT MQ Listener code in one of our spring application which is running in JAVA 1.6 environment. I have tried the samples provided in spring.io site(https://spring.io/guides/gs/messaging-rabbitmq/). Seems that one is not supporting the java 1.6. Could some please help me to find the SPRING RABBIT JARs version compatible with JAVA 1.6.
Here is the exception with spring-rabbit-1.0.0.RELEASE.jar
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: com/rabbitmq/client/Channel
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at org.springframework.core.type.StandardAnnotationMetadata.hasAnnotatedMethods(StandardAnnotationMetadata.java:129)
at org.springframework.context.annotation.ConfigurationClassUtils.isLiteConfigurationCandidate(ConfigurationClassUtils.java:157)
at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:108)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:278)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.rabbitmq.client.Channel
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 25 more

1.0.0 is extremely old.
The current version for Java 6 is 1.7.7 see the project page for versions.
It is compatible with spring boot 1.5.x; the guides have been converted to boot 2, which requires java 8.

Related

ApplicationContext.populateSessionTrackingModes in Tomcat7

We are currently migrating from Tomcat Apache 5.5.9 to Tomcat 7.0.10 but getting a null pointer exception when the application is executed.
The exception is same as mentioned in the question
migrate embedded tomcat 5 to tomcat 7
If anybody has another suggestions please let me know. I tried in almost all the version of tomcat 7.0.x but still the same issue.
I am attaching the call stack of the dump.
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.apache.catalina.core.ApplicationContext.populateSessionTrackingModes(ApplicationContext.java:1188)
at org.apache.catalina.core.ApplicationContext.<init>(ApplicationContext.java:127)
at org.apache.catalina.core.StandardContext.getServletContext(StandardContext.java:2211)
at org.apache.catalina.core.StandardContext.postWorkDirectory(StandardContext.java:5989)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4960)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Embedded.startInternal(Embedded.java:823)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
Hi Thomas Thanks a lot for your reply .The complete call stack is as follows Caused by: java.lang.NullPointerException
at org.apache.catalina.core.ApplicationContext.populateSessionTrackingModes(ApplicationContext.java:1188)
at org.apache.catalina.core.ApplicationContext.(ApplicationContext.java:127)
at org.apache.catalina.core.StandardContext.getServletContext(StandardContext.java:2211)
at org.apache.catalina.core.StandardContext.postWorkDirectory(StandardContext.java:5989)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4960)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Embedded.startInternal(Embedded.java:823)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at com.start.las.ls.lmsembed.tomcat.TomcatEmbed.setStatus(TomcatEmbed.java:93)

Spring context initializtion failed

I am getting the below exception when I trying run the maven project
SEVERE: StandardWrapper.Throwable
java.lang.NoSuchMethodError: org.springframework.core.JdkVersion.isAtLeastJava15()Z
at org.springframework.beans.CachedIntrospectionResults.(CachedIntrospectionResults.java:249)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:798)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:63)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:128)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1230)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1174)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5370)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5668)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1700)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1690)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Jun 23, 2018 11:26:56 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [spring-mvc] in web application [/SpringMvcUser] threw load() exception
java.lang.NoSuchMethodError: org.springframework.core.JdkVersion.isAtLeastJava15()Z
at org.springframework.beans.CachedIntrospectionResults.(CachedIntrospectionResults.java:249)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:798)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:63)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:128)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1230)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1174)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5370)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5668)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1700)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1690)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
help me to solve this exception
Javadoc for class org.springframework.core.JdkVersion says:
Deprecated. as of Spring 4.2.1, in favor of direct checks for the desired JDK API variants via reflection
In Spring version 4.2.6 there is no method isAtLeastJava15() in class JdkVersion.
Some of your code seems to be written for an an older version of Spring. Are mixing up different versions or is a library you are using requiring another version? Have you checked your classpath?

Spring boot WebApplication starts twice on Tomcat 7 server

I have Spring boot WebApplication, that I can start separately in without having Tomcat installed, because it has embedded Server in itself, right?
So is starts normally when I right-click on it in Eclipse and choose: RunAs/SpringBootApp
But when I add it Tomcat 7 server.xml is starts twice. So I assuming that firstly it starts with his embedded Server and then it tries to start in Tomcat 7?
Here are the logs:
INFO: Deploying web application directory C:\tomcat7dev\webapps\enlivenweb
Apr 25, 2016 10:49:30 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/enlivenweb]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1897)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.cloud.context.environment.EnvironmentManager#57239838] with key 'environmentManager'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625)
at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550)
at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:133)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:124)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:81)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5481)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: javax.management.InstanceAlreadyExistsException: org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager
at com.sun.jmx.mbeanserver.Repository.addMBean(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown Source)
at org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:195)
at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:678)
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:615)
... 24 more
In case the management.port is configured differently from the server.port a second embedded servlet container is spun up. You can't use these two options when doing a traditional war-file deployment.

java.lang.IllegalArgumentException at org.springframework.asm.ClassReader.<init>(Unknown Source)

My Spring application on Apache Tomcat/7.0.62 throws the below exception:
java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:298)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:230)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:153)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:130)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:285)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:652)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:600)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:666)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:519)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:460)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
How is this caused and how can I solve it?
Try to upgrade to Spring 4 to support Java 8 byte code format.
Your root cause here:
java.lang.IllegalArgumentException org.springframework.asm.ClassReader.(Unknown Source)
org.springframework.asm.ClassReader.(Unknown Source)
org.springframework.asm.ClassReader.(Unknown Source)
I had the same problem, then I upgraded my maven project to spring-webmvc 4.2.5.RELEASE and it worked for me, Im using Java 8.
I recently had the same error.Changing the dependency version of springwebmvc to 4.2.5.RELEASE solves the problem. The problem arises when you are using JAVA 8 and not dependency version that is older than 4.2.5
I tried other mentioned, to update spring-webmvc to version 4, it doesn't solve my problem, I have to update spring-core to version 4.
You can also try removing code that uses Java 8 features like Lambdas

struts spring integration get following error java.lang.ClassNotFoundException: org.springframework.web.struts.ContextLoaderPlugIn

In my application i used spring-struts.jar but it is throwing this error.
java.lang.ClassNotFoundException: org.springframework.web.struts.ContextLoaderPlugIn
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:207)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:231)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1142)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5407)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
You need to add the spring-web and spring-web-struts jars. ContextLoaderPlugIn class is part of spring-web-struts jar. And make sure they are added to your classpath.

Resources