Tomcat - Deploying application - datasource issue - java

I have one tomcat container and two web applications (jhipster applications). First one is only for front-end part and second one is for back-end.
On tomcat I have two webapps folders - webapps and webapps2. When I tried to deploy front-end application in webapps2 folder I'm getting an error:
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [HikariDataSource (HikariPool-0)] with key 'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:149) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:129) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:85) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) [spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5623) [catalina.jar:7.0.72]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) [catalina.jar:7.0.72]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899) [catalina.jar:7.0.72]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) [catalina.jar:7.0.72]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) [catalina.jar:7.0.72]
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092) [catalina.jar:7.0.72]
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984) [catalina.jar:7.0.72]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_101]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_101]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]
I have register two services, back-end part works on 8080 port and front-end part on 7070. I know that the best option is to deploy front-end application on apache web server but in that case I will need to single out application from jhipster project but I don't have time for that.
Does anyone have an idea what happened here and how to fix this issue?
Just to notice that if I use two tomcat servers everything works fine.

I cannot comment so I do an answer.
This seems to be the problem.
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [HikariDataSource (HikariPool-0)] with key 'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
There seems to be an conflict in that both apps use the same name. Probably two beans with same name datasource.

Related

Websphere to Tomcat migration: java.lang.NoClassDefFoundError: com/ibm/wsspi/uow/UOWActionException

I am migrating my application from webshpere to tomcate and IO getting below error while running tomcat server with web WAR file. PLease help me to solve this
INFO,DefaultListableBeanFactory,localhost-startStop-1] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#48a48ed: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,frameworkpum,commonProfileEntityManager,emCommon,centralCasServerURL,centralCasServerLoginURL,applicationServiceURL,casHttpsProxyHost,casHttpsProxyPort,casHttpsNonProxyHosts,proxyConfiguration,singleLogoutFilter,dciLogoutSuccessHandler,org.springframework.security.authentication.DefaultAuthenticationEventPublisher#0,org.springframework.security.authenticationManager,casAuthenticationFilter,casProcessingFilterEntryPoint,casAuthenticationProvider,serviceProperties,userService,dciscApp,propertiesHelper,facesHelper,accessDecisionManager,roleVoter,authenticatedVoter,accessDeniedHandler,syslogPath,auditManager,commonAuditService,auditConversionService,auditDTOToEntityConverter,auditEntityToDTOConverter,auditReportEntityToDTOConverter,auditDAO,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#1,auditpum,commonAuditEntityManager,emAudit,participantSearchDAO,intesSearchDAO,userProfileDAO,currencySearchDAO,countrySearchDAO,chargeTypeSearchDAO,commonMerchantCategoryDAO,contactSearchDAO,commonSecurityQuestionsDAO,applicationMakerCheckerManager,applicationManager,applicationService,commonDTOConverterService,userProfileManager,userProfileService,userProfileConversionFactory,menuBuilder,intesSearchManager,currencySearchManager,countrySearchManager,chargeTypeSearchManager,commonMerchantCategorySearchManager,participantSearchManager,contactSearchManager,intesSearchService,currencySearchService,countrySearchService,chargeTypeSearchService,commonMerchantCategorySearchService,participantSearchService,contactSearchService,commonSecurityQuestionsService,currencyConverter,countryConverter,intesConverter,chargeTypeConverter,commonMerchantCategoryConverter,participantConverter,participantCycleRangeConverter,contactConverter,commonSecurityQuestionsConverter,parser,securityHelper,passwordEncryptor,defaultPasswordGenerator,defaultPasswordValidator,passwordHelper,passwordManager,questionsHelper,questionsManager,racfAuthenticator,secApiWrapper,dsManagerWrapper,corporateLDAPConnectionParameters,org.springframework.context.config.internalBeanConfigurerAspect,makerCheckerIdFactoryImpl,makerBeanFactory,customNamespacePrefixMapper,annotationBasedCheckerService,serviceFactoryImpl,outstandingChangesServiceImpl,makerServiceImpl,checkerServiceProxy,makerCheckerDAOJpaImpl,makerCheckerEntityManager,makercheckerpum,emMakerChecker,makerCheckerManager,com.dcisc.common.makerchecker.XmlSerializer#0,applicationDatasource,emAer,aerEntityManager,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.core.session.SessionRegistryImpl#0,org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.authentication.AnonymousAuthenticationProvider#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint#0,org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0,org.springframework.security.config.http.UserDetailsServiceInjectionBeanPostProcessor#0,org.springframework.security.filterChainProxy,aerClientDescTabDAO,aerFranchiseDescTabDAO,aerClientTabDAO,aerExceptionTabDAO,aerFranchiseTabDAO,grfSummarySearchService,grfExceptionSearchService,fileTranSearchService,grfSummarySearchManager,grfExceptionSearchManager,fileTranSearchManager]; root of factory hierarchy
[ERROR,ContextLoader,localhost-startStop-1] Context initialization failed
java.lang.NoClassDefFoundError: com/ibm/wsspi/uow/UOWActionException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getDeclaredConstructors(Class.java:2020)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:230)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:930)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:903)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1795)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.ibm.wsspi.uow.UOWActionException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
... 31 more
The error is throwed if you use the old spring TransactionManager configuration in Tomcat.
You have to replace org.springframework.transaction.jta.WebSphereUowTransactionManager with another one.
Please refer spring document for more information. Since Tomcat does not offer all Java EE features. You may need other TransactionManager solution
especially when your application access more than one database.

Multiple RabbitMQ Application

I am trying to host multiple spring boot applications on a tomcat server.
However, I catch the following exceptions as i try to start the server up.
The problem is related to having multiple rabbitmq queues with the same caching factory id.
I tried creating a ConnectionFactory bean with a different id in the ...Application.class, but the application failed to build.
Any help is welcomed.
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [CachingConnectionFactory] with key 'rabbitConnectionFactory'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.amqp.rabbit.connection:name=rabbitConnectionFactory,type=CachingConnectionFactory
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:628) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:781) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5573) [catalina.jar:7.0.68]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [catalina.jar:7.0.68]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899) [catalina.jar:7.0.68]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) [catalina.jar:7.0.68]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) [catalina.jar:7.0.68]
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1259) [catalina.jar:7.0.68]
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1998) [catalina.jar:7.0.68]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_77]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_77]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77]
If you want to keep using JMX, you can just assign it a unique default-domain in your application.properties like this:
spring.application.name=my-app
spring.jmx.default-domain=my-app-jmx
Found this solution here, worked well for me. A brief description of the properties can be found here.
In our case we weren't using JMX specifically, and weren't relying on any of Spring Boot's JMX based features. Simply disabling JMX prevented the name clashes when deploying multiple applications to the same container.
In application.properties:
spring.jmx.enabled=false
You should use a different MBean domain for each application.
However, there should be no problem creating the factory with a different bean name; you should edit your question to describe the nature of the problem there.

GWT Maps API V3 Core API

I'm trying to use the GWT Maps API V3 in a Spring Boot project.
I added it in gradle with no issue and wrote my code but when running, it crashes showing the following:
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_102]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_102]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [tomcat-embed-core-8.5.5.jar:8.5.5]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.5.jar:8.5.5]
... 6 common frames omitted
Caused by: java.lang.IllegalStateException: java.lang.NullPointerException
at org.springframework.boot.context.embedded.tomcat.TomcatResources$Tomcat7Resources.addJar(TomcatResources.java:125) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatResources.addClasspathResources(TomcatResources.java:63) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory$StoreMergedWebXmlListener.onStart(TomcatEmbeddedServletContainerFactory.java:805) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory$StoreMergedWebXmlListener.lifecycleEvent(TomcatEmbeddedServletContainerFactory.java:796) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) [tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5087) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
... 6 common frames omitted
Caused by: java.lang.NullPointerException: null
at org.springframework.boot.context.embedded.tomcat.TomcatResources$Tomcat7Resources.addJar(TomcatResources.java:122) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
... 12 common frames omitted
Any idea how to use it with spring?
From this blog, try coping commons-logging.jar file to WEB-INF/lib folder. You must also have packaged the servlet-api.jar along with the other libraries in your war file. You can verify this by opening up your war file and navigating to the WEB-INF/lib folder.
Based from this post, you should not provide the servlet-api jar. The container, in your case Tomcat, is responsible for providing it at deploy time to your application. If you try to provide it as well, then issues arise due to version mismatch etc. Best practise is to just avoid packaging it. Remove it from the WEB-INF/lib.
Also according to this thread:
Your webapp has servletcontainer specific libraries like servlet-api.jar file in its /WEB-INF/lib. This is not right. Remove them all. The /WEB-INF/lib should contain only the libraries specific to the webapp, not to the servletcontainer. The servletcontainer (like Tomcat) is the one who should already provide the servletcontainer specific libraries. If you supply libraries from an arbitrary servletcontainer of a different make/version, you'll run into this kind of problems because your webapp wouldn't be able to run on a servletcontainer of a different make/version than where those libraries are originated from.

Can't make my spring boot application work with jsp

I have problem with my spring boot web app. It uses embedded jetty (it must be jetty - not tomcat) and it uses jsp views. But seems like there is no way to make embedded jetty work with jsp views. Actually at the moment when I run mu app server starts successfully but when I try to access any url of my web app - I get error:
org.apache.jasper.JasperException: java.lang.IllegalStateException: No Java compiler available
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:591) ~[apache-jsp-8.0.27.jar:2.3]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:397) ~[apache-jsp-8.0.27.jar:2.3]
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) ~[apache-jsp-8.0.27.jar:2.3]
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) ~[apache-jsp-8.0.27.jar:2.3]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) ~[jetty-servlet-9.2.17.v20160517.jar:9.2.17.v20160517]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) ~[jetty-servlet-9.2.17.v20160517.jar:9.2.17.v20160517]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) ~[spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) ~[jetty-servlet-9.2.17.v20160517.jar:9.2.17.v20160517]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:108) ~[spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
......................
Caused by: java.lang.IllegalStateException: No Java compiler available
at org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:231) ~[apache-jsp-8.0.27.jar:2.3]
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:577) ~[apache-jsp-8.0.27.jar:2.3]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363) ~[apache-jsp-8.0.27.jar:2.3]
How can I make it work? Is there any way?
And if it is not possible with spring boot then what are alternative ways to make my app work on embedded jetty with jsp?
Here is link to my project on github. Please look at it and help me! It would be just great if you try to run it in your IDE (IntelliJ IDEA recommended) and find the reason of the problem.
UPDATE 1 (15.07.2016)
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [sample.jetty.jsp.SampleJettyJspApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:187) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
at sample.jetty.jsp.SampleJettyJspApplication.main(SampleJettyJspApplication.java:33) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163) ~[spring-core-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:300) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:237) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:204) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_65]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_65]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_65]
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) ~[spring-core-4.3.1.RELEASE.jar:4.3.1.RELEASE]
... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_65]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_65]
... 25 common frames omitted
You are using Spring Boot 1.3.6 and in the JSP limitations section of the documentation it says:
Jetty does not currently work as an embedded container with JSPs.
There's an enhancement coming in Spring Boot 1.4 that means the JSPs will work with embedded Jetty as long as you use war packaging. If you don't want to wait for 1.4.0 to be released, the enhancement is in 1.4.0.RC1 which is available from https://repo.spring.io/libs-milestone. There's also a new sample application that may be of interest.

Migration issue from spring 3.1.2 to spring 4

We are try to migrate from Spring 3.1.2 to Spring 4.1.2
After migration, when running tomcat we are facing below exception,
This issue is caused by our spring-jms dependency.
As per my knowledge, this class "MappingJacksonMessageConverter" is available only in spring 3, in spring 4 the class is MappingJackson2MessageConverter.
I'm not sure which part of spring code is loading this class MappingJacksonMessageConverter.
java.lang.NoClassDefFoundError: org/springframework/jms/support/converter/MappingJacksonMessageConverter
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3116)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1344)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1825)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1705)
at org.springframework.core.type.classreading.AnnotationReadingVisitorUtils.convertClassValues(AnnotationReadingVisitorUtils.java:73)
at org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor.getAnnotationAttributes(AnnotationMetadataReadingVisitor.java:134)
at org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor.getAnnotationAttributes(AnnotationMetadataReadingVisitor.java:49)
at org.springframework.context.annotation.AnnotationConfigUtils.attributesFor(AnnotationConfigUtils.java:280)
at org.springframework.context.annotation.AnnotationConfigUtils.attributesFor(AnnotationConfigUtils.java:276)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:263)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:231)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:509)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:277)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:231)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:190)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:674)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:519)
at com.walmart.platform.config.PlatformContextLoaderListener.configureAndRefreshWebApplicationContext(PlatformContextLoaderListener.java:64)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at com.walmart.platform.config.PlatformContextLoaderListener.contextInitialized(PlatformContextLoaderListener.java:74)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5077)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5591)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.springframework.jms.support.converter.MappingJacksonMessageConverter
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1856)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1705)
... 38 more
Maybe you have a wrong version of some dependencies, maybe they are not migrated, so you have to see the dependencies table of the Spring 4.1.2 in the maven central, this table contains the lowest version compatible with the Spring version you want.

Categories