Websocket JSR-356 fail with Jetty 9.4.1 - websocket
My current web server is embedded Jetty 9.1.5. It works well with JSR-356 to create websocket. These days, I am trying to upgrade to Jetty 9.4.1. Everything works nicely except websocket.
My code like below:
Embedded Jetty and Websocket libs:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.1.v20170120</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.4.1.v20170120</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
<version>9.4.1.v20170120</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.4.1.v20170120</version>
</dependency>
Server endpoint:
#ServerEndpoint(value = "/ws/communication/{officeId}/{username}/{oldWSSession}")
class WSCommunication {
// #OnOpen, #OnMessage, #OnClose methods
}
Jetty server, Webapp context, Websocket configuration:
// Jetty server
Server server = new Server();
String[] configFiles = {"./etc/jetty.xml"};
for (String configFile : configFiles) {
XmlConfiguration configuration = new XmlConfiguration(new File(configFile).toURI().toURL());
configuration.configure(server);
Connector[] connectors = server.getConnectors();
if (connectors != null && connectors.length == 2) {
ServerConnector serverConnector = (ServerConnector) connectors[1];
serverConnector.setPort(8443);
}
}
// Webapp context
WebAppContext webContext = new WebAppContext(ResourceManager.getWebappsPath(), "/myContext");
webContext.setContextPath("/myContext");
webContext.setResourceBase(ResourceManager.getWebappsPath() + contextPath);
webContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
private List<WebAppContext> listWebContext = new ArrayList<>();
listWebContext.add(webContext);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(listWebContext.toArray(new WebAppContext[listWebContext.size()]));
server.setHandler(contexts);
// Start server
server.start();
// Websocket
ServerContainer container =
WebSocketServerContainerInitializer.configureContext(webContext);
container.addEndpoint(webContext.getClassLoader().loadClass(
"com.example.WSCommunication"));
container.setDefaultMaxSessionIdleTimeout(84600);
// Dump server log
server.dumpStdErr();
Dump:
org.eclipse.jetty.server.Server#5ca13457 - STARTED
+= qtp348159759{STARTED,10<=19<=200,i=1,q=0} - STARTED
| +- 30 qtp348159759-30 RUNNABLE # sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 31 qtp348159759-31-lowPrioritySelector BLOCKED # org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:244) prio=1
| +- 89 qtp348159759-89-lowPrioritySelector BLOCKED # org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:244) prio=1
| +- 85 qtp348159759-85-lowPrioritySelector BLOCKED # org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:244) prio=1
| +- 33 qtp348159759-33-lowPrioritySelector BLOCKED # org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:244) prio=1
| +- 36 qtp348159759-36 RUNNABLE # sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 35 qtp348159759-35-lowPrioritySelector BLOCKED # org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:244) prio=1
| +- 90 qtp348159759-90-acceptor-0#6a934d20-ServerConnector#31de14e{SSL,[ssl, http/1.1]}{0.0.0.0:8443} RUNNABLE # sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method) prio=3
| +- 84 qtp348159759-84 RUNNABLE # sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 86 qtp348159759-86 RUNNABLE # sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 38 qtp348159759-38-acceptor-0#21398b5e-ServerConnector#52bab8e{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} RUNNABLE # sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method) prio=3
| +- 87 qtp348159759-87-lowPrioritySelector BLOCKED # org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:244) prio=1
| +- 92 qtp348159759-92 TIMED_WAITING # sun.misc.Unsafe.park(Native Method) IDLE
| +- 32 qtp348159759-32 RUNNABLE # sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 34 qtp348159759-34 RUNNABLE # sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 88 qtp348159759-88 RUNNABLE # sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 39 qtp348159759-39 RUNNABLE # sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 37 qtp348159759-37-lowPrioritySelector BLOCKED # org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:244) prio=1
| +- 83 qtp348159759-83-lowPrioritySelector BLOCKED # org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:244) prio=1
| +- jobs
+= org.eclipse.jetty.util.thread.ScheduledExecutorScheduler#1ca4b0fd - STARTED
| +- sun.misc.Unsafe.park(Native Method)
| +- java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
| +- java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
| +- java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
| +- java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
| +- java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
| +- java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
| +- java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
| +- java.lang.Thread.run(Thread.java:745)
+= ServerConnector#52bab8e{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} - STARTED
| +~ org.eclipse.jetty.server.Server#5ca13457 - STARTED
| +~ qtp348159759{STARTED,10<=19<=200,i=1,q=0} - STARTED
| +~ org.eclipse.jetty.util.thread.ScheduledExecutorScheduler#1ca4b0fd - STARTED
| +- org.eclipse.jetty.io.ArrayByteBufferPool#4f751fc9
| += HttpConnectionFactory#30bf9c09[HTTP/1.1] - STARTED
| | +- HttpConfiguration#248e9950{32768/8192,8192/8192,https://:8443,[]}
| += org.eclipse.jetty.server.ServerConnector$ServerConnectorManager#282048ea - STARTED
| | += org.eclipse.jetty.io.ManagedSelector#65c05e53 id=0 keys=0 selected=0 id=0
| | | +- sun.nio.ch.KQueueSelectorImpl#6724bccb keys=0
| | += org.eclipse.jetty.io.ManagedSelector#1fa04d47 id=1 keys=0 selected=0 id=1
| | | +- sun.nio.ch.KQueueSelectorImpl#5fcb5753 keys=0
| | += org.eclipse.jetty.io.ManagedSelector#7999a7f0 id=2 keys=0 selected=0 id=2
| | | +- sun.nio.ch.KQueueSelectorImpl#3abe8266 keys=0
| | += org.eclipse.jetty.io.ManagedSelector#6d2e80a1 id=3 keys=0 selected=0 id=3
| | +- sun.nio.ch.KQueueSelectorImpl#2e5f2aae keys=0
| +- sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:8080]
| +- qtp348159759-38-acceptor-0#21398b5e-ServerConnector#52bab8e{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
+= ServerConnector#31de14e{SSL,[ssl, http/1.1]}{0.0.0.0:8443} - STARTED
| +~ org.eclipse.jetty.server.Server#5ca13457 - STARTED
| +~ qtp348159759{STARTED,10<=20<=200,i=2,q=0} - STARTED
| +~ org.eclipse.jetty.util.thread.ScheduledExecutorScheduler#1ca4b0fd - STARTED
| +- org.eclipse.jetty.io.ArrayByteBufferPool#3838889e
| += SslConnectionFactory#7b040213{SSL->http/1.1} - STARTED
| | += SslContextFactory#a3ac71d(file:///workspace/myApp/myApp-server/webapps/conf/iDS.keystore,null) trustAll=false
| | +- Protocol Selections
| | | +- Enabled (size=3)
| | | | +- TLSv1
| | | | +- TLSv1.1
| | | | +- TLSv1.2
| | | +- Disabled (size=2)
| | | +- SSLv2Hello - ConfigExcluded:'SSLv2Hello'
| | | +- SSLv3 - JreDisabled:java.security, ConfigExcluded:'SSLv3'
| | +- Cipher Suite Selections
| | +- Enabled (size=43)
| | | [CIPHERS]
| | +- Disabled (size=39)
| | [CIPHERS]
| += HttpConnectionFactory#116d58cf[HTTP/1.1] - STARTED
| | +- HttpConfiguration#3ba7eaf0{32768/8192,8192/8192,https://:8443,[SecureRequestCustomizer#229efbd3]}
| += org.eclipse.jetty.server.ServerConnector$ServerConnectorManager#14690caf - STARTED
| | += org.eclipse.jetty.io.ManagedSelector#e1ecb28 id=0 keys=0 selected=0 id=0
| | | +- sun.nio.ch.KQueueSelectorImpl#2edda3f6 keys=0
| | += org.eclipse.jetty.io.ManagedSelector#aea4071 id=1 keys=0 selected=0 id=1
| | | +- sun.nio.ch.KQueueSelectorImpl#2482929a keys=0
| | += org.eclipse.jetty.io.ManagedSelector#5fff729c id=2 keys=0 selected=0 id=2
| | | +- sun.nio.ch.KQueueSelectorImpl#7f0a5bb3 keys=0
| | += org.eclipse.jetty.io.ManagedSelector#32f11b8 id=3 keys=0 selected=0 id=3
| | +- sun.nio.ch.KQueueSelectorImpl#153f56b1 keys=0
| +- sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:8443]
| +- qtp348159759-90-acceptor-0#6a934d20-ServerConnector#31de14e{SSL,[ssl, http/1.1]}{0.0.0.0:8443}
+= org.eclipse.jetty.server.handler.ContextHandlerCollection#7b10dd7e[o.e.j.w.WebAppContext#3e778e26{/myContext,file:///workspace/myApp/myApp-server/webapps/myContext/,AVAILABLE}{/workspace/myApp/myApp-server/webapps}, o.e.j.w.WebAppContext#2974d7ef{/myContext_persistent,file:///workspace/myApp/myApp-server/data/my_persistent/,AVAILABLE}{/workspace/myApp/myApp-server/data}] - STARTED
| += o.e.j.w.WebAppContext#3e778e26{/myContext,file:///workspace/myApp/myApp-server/webapps/myContext/,AVAILABLE}{/workspace/myApp/myApp-server/webapps} - STARTED
| | += org.eclipse.jetty.server.session.SessionHandler589427621==dftMaxIdleSec=1800 - STARTED
| | | += org.eclipse.jetty.security.ConstraintSecurityHandler#76e1ecf - STARTED
| | | | +- org.eclipse.jetty.security.DefaultAuthenticatorFactory#7cb77d4b
| | | | += org.eclipse.jetty.servlet.ServletHandler#1b1b48e - STARTED
| | | | | += org.eclipse.jetty.servlet.ListenerHolder#2da1d3c6 - STARTED
| | | | | += org.eclipse.jetty.servlet.ListenerHolder#5ace38db - STARTED
| | | | | += default#5c13d641==org.eclipse.jetty.servlet.DefaultServlet,jsp=null,order=0,inst=true - STARTED
| | | | | | +- aliases=false
| | | | | | +- dirAllowed=true
| | | | | | +- maxCacheSize=256000000
| | | | | | +- maxCachedFileSize=200000000
| | | | | | +- welcomeServlets=false
| | | | | | +- useFileMappedBuffer=true
| | | | | | +- acceptRanges=true
| | | | | | +- etags=false
| | | | | | +- maxCachedFiles=2048
| | | | | | +- redirectWelcome=false
| | | | | += jsp#19c47==org.eclipse.jetty.jsp.JettyJspServlet,jsp=null,order=0,inst=true - STARTED
| | | | | | +- fork=false
| | | | | | +- compilerSourceVM=1.7
| | | | | | +- logVerbosityLevel=DEBUG
| | | | | | +- compilerTargetVM=1.7
| | | | | | +- scratchdir=/private/var/folders/8p/f__1hb6j0p5bq7ljqdkjg35h0000gn/T/jetty-0.0.0.0-8080-myContext-_myContext-any-6227228818832412481.dir/jsp
| | | | | | +- xpoweredBy=false
| | | | | +- [/]=>default
| | | | | +- [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp
| | | | | += org.eclipse.jetty.servlet.ListenerHolder#1dd44bec - STARTED
| | | | | += org.eclipse.jetty.servlet.ListenerHolder#114d991c - STARTED
| | | | | += ISSSecurityFilter - STARTED
| | | | | += GzipFilter - STARTED
| | | | | | +- mimeTypes=text/plain,text/html,text/css,application/javascript,application/x-javascript,application/json
| | | | | += Dashboard#38fd0a74==com.example.web.Dashboard,jsp=null,order=1,inst=true - STARTED
| | | | | | +- parameter=value
| | | | | += idental-mvc#441f8928==org.springframework.web.servlet.DispatcherServlet,jsp=null,order=-1,inst=false - STARTED
| | | | | [SERVLET MAPPING]
| | | | | +~ Jetty_WebSocketUpgradeFilter - STARTED
| | | | | +- [/*]/[]==1=>Jetty_WebSocketUpgradeFilter
| | | | |
| | | | +> null
| | | | +> null
| | | | +> null
| | | | +> []
| | | | +> /*={*={RoleInfo[],Confidential}}
| | | | +> /={TRACE={RoleInfo,F,C[],None}, TRACE.omission={RoleInfo[],None}}
| | | +~ com.example.web.ContextListener#32d15710
| | | += org.eclipse.jetty.server.session.DefaultSessionCache#19f2b971[evict=-1,removeUnloadable=false,saveOnCreate=false,saveOnInactiveEvict=false] - STARTED
| | | | += org.eclipse.jetty.server.session.NullSessionDataStore#26c61a88[passivating=false,graceSec=3600] - STARTED
| | | +~ org.eclipse.jetty.server.session.DefaultSessionIdManager#5bbef235[worker=node0] - STARTED
| | += org.eclipse.jetty.servlet.ErrorPageErrorHandler#636f4785 - STARTED
| | +~ org.eclipse.jetty.websocket.jsr356.server.ServerContainer#6fda53a8 - STOPPED
| | |
| | +> WebAppClassLoader=myContext#27e16098
| | | [LIBS]
| | | +- sun.misc.Launcher$AppClassLoader#18b4aac2
| | +> Systemclasses o.e.j.w.WebAppContext#3e778e26{/myContext,file:///workspace/myApp/myApp-server/webapps/myContext/,AVAILABLE}{/workspace/myApp/myApp-server/webapps}
| | | +- java.
| | | +- javax.
| | | +- org.eclipse.jetty.continuation.
| | | +- org.eclipse.jetty.jaas.
| | | +- org.eclipse.jetty.jmx.
| | | +- org.eclipse.jetty.jndi.
| | | +- org.eclipse.jetty.jsp.JettyJspServlet
| | | +- org.eclipse.jetty.servlet.DefaultServlet
| | | +- org.eclipse.jetty.servlets.PushCacheFilter
| | | +- org.eclipse.jetty.servlets.PushSessionCacheFilter
| | | +- org.eclipse.jetty.util.annotation.
| | | +- org.eclipse.jetty.util.log.
| | | +- org.eclipse.jetty.websocket.
| | | +- org.w3c.
| | | +- org.xml.
| | +> Serverclasses o.e.j.w.WebAppContext#3e778e26{/myContext,file:///workspace/myApp/myApp-server/webapps/myContext/,AVAILABLE}{/workspace/myApp/myApp-server/webapps}
| | | +- -org.eclipse.jetty.alpn.
| | | +- -org.eclipse.jetty.apache.
| | | +- -org.eclipse.jetty.continuation.
| | | +- -org.eclipse.jetty.jaas.
| | | +- -org.eclipse.jetty.jmx.
| | | +- -org.eclipse.jetty.jndi.
| | | +- -org.eclipse.jetty.jsp.
| | | +- -org.eclipse.jetty.server.session.SessionData
| | | +- -org.eclipse.jetty.servlet.DefaultServlet
| | | +- -org.eclipse.jetty.servlet.NoJspServlet
| | | +- -org.eclipse.jetty.servlet.listener.
| | | +- -org.eclipse.jetty.servlets.
| | | +- -org.eclipse.jetty.util.annotation.
| | | +- -org.eclipse.jetty.util.log.
| | | +- -org.eclipse.jetty.websocket.
| | | +- org.eclipse.jdt.
| | | +- org.eclipse.jetty.
| | | +- org.objectweb.asm.
| | +> Configurations o.e.j.w.WebAppContext#3e778e26{/myContext,file:///workspace/myApp/myApp-server/webapps/myContext/,AVAILABLE}{/workspace/myApp/myApp-server/webapps}
| | | +- org.eclipse.jetty.webapp.WebInfConfiguration#795e1681
| | | +- org.eclipse.jetty.webapp.WebXmlConfiguration#55dd7cc5
| | | +- org.eclipse.jetty.webapp.MetaInfConfiguration#4c174a94
| | | +- org.eclipse.jetty.webapp.FragmentConfiguration#71ed07ad
| | | +- org.eclipse.jetty.webapp.JettyWebXmlConfiguration#780efd0f
| | +> Handler attributes o.e.j.w.WebAppContext#3e778e26{/myContext,file:///workspace/myApp/myApp-server/webapps/myContext/,AVAILABLE}{/workspace/myApp/myApp-server/webapps}
| | | +- javax.servlet.context.tempdir=/private/var/folders/8p/f__1hb6j0p5bq7ljqdkjg35h0000gn/T/jetty-0.0.0.0-8080-myContext-_myContext-any-6227228818832412481.dir
| | | +- org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.SCI=WebSocketUpgradeFilter[configuration=org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration#468b9d9f]
| | | +- org.eclipse.jetty.server.Executor=qtp348159759{STARTED,10<=20<=200,i=2,q=0}
| | | +- org.apache.catalina.jsp_classpath=[LIBS]
| | | +- javax.websocket.server.ServerContainer=org.eclipse.jetty.websocket.jsr356.server.ServerContainer#6fda53a8
| | +> Context attributes o.e.j.w.WebAppContext#3e778e26{/myContext,file:///workspace/myApp/myApp-server/webapps/myContext/,AVAILABLE}{/workspace/myApp/myApp-server/webapps}
| | | +- org.eclipse.jetty.util.DecoratedObjectFactory=org.eclipse.jetty.util.DecoratedObjectFactory[decorators=1]
| | | +- com.sun.jsp.tagFileJarUrlsCache={}
| | | +- org.springframework.web.context.support.ServletContextScope=org.springframework.web.context.support.ServletContextScope#30be2c30
| | | +- org.springframework.web.context.WebApplicationContext.ROOT=Root WebApplicationContext: startup date [Thu Mar 02 22:05:59 ICT 2017]; root of context hierarchy
| | | +- resourceCache=ResourceCache[null,org.eclipse.jetty.servlet.DefaultServlet#297785e5]#647951169
| | | +- org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration=org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration#468b9d9f
| | | +- org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter=WebSocketUpgradeFilter[configuration=org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration#468b9d9f]
| | | +- com.sun.jsp.taglibraryCache={}
| | +> Initparams o.e.j.w.WebAppContext#3e778e26{/myContext,file:///workspace/myApp/myApp-server/webapps/myContext/,AVAILABLE}{/workspace/myApp/myApp-server/webapps}
| | +- contextConfigLocation=classpath:applicationContext.xml
| | +- org.eclipse.jetty.servlet.Default.dirAllowed=false
| += o.e.j.w.WebAppContext#2974d7ef{/myContext_persistent,file:///workspace/myApp/myApp-server/data/my_persistent/,AVAILABLE}{/workspace/myApp/myApp-server/data} - STARTED
| += org.eclipse.jetty.server.session.SessionHandler1013179752==dftMaxIdleSec=1800 - STARTED
| | += org.eclipse.jetty.security.ConstraintSecurityHandler#7dfd9178 - STARTED
| | | +- org.eclipse.jetty.security.DefaultAuthenticatorFactory#68b06b8f
| | | += org.eclipse.jetty.servlet.ServletHandler#39e59923 - STARTED
| | | | += org.eclipse.jetty.servlet.ListenerHolder#1a8e73d2 - STARTED
| | | | += org.eclipse.jetty.servlet.ListenerHolder#b6957aa - STARTED
| | | | += default#5c13d641==org.eclipse.jetty.servlet.DefaultServlet,jsp=null,order=0,inst=true - STARTED
| | | | | +- aliases=false
| | | | | +- dirAllowed=true
| | | | | +- maxCacheSize=256000000
| | | | | +- maxCachedFileSize=200000000
| | | | | +- welcomeServlets=false
| | | | | +- useFileMappedBuffer=true
| | | | | +- acceptRanges=true
| | | | | +- etags=false
| | | | | +- maxCachedFiles=2048
| | | | | +- redirectWelcome=false
| | | | += jsp#19c47==org.eclipse.jetty.jsp.JettyJspServlet,jsp=null,order=0,inst=true - STARTED
| | | | | +- fork=false
| | | | | +- compilerSourceVM=1.7
| | | | | +- logVerbosityLevel=DEBUG
| | | | | +- compilerTargetVM=1.7
| | | | | +- scratchdir=/private/var/folders/8p/f__1hb6j0p5bq7ljqdkjg35h0000gn/T/jetty-0.0.0.0-8080-my_persistent-_myContext_persistent-any-707911495794918084.dir/jsp
| | | | | +- xpoweredBy=false
| | | | +- [/]=>default
| | | | +- [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp
| | | |
| | | +> null
| | | +> null
| | | +> null
| | | +> []
| | | +> /={TRACE={RoleInfo,F,C[],None}, TRACE.omission={RoleInfo[],None}}
| | += org.eclipse.jetty.server.session.DefaultSessionCache#606eb95b[evict=-1,removeUnloadable=false,saveOnCreate=false,saveOnInactiveEvict=false] - STARTED
| | | += org.eclipse.jetty.server.session.NullSessionDataStore#755718f4[passivating=false,graceSec=3600] - STARTED
| | +~ org.eclipse.jetty.server.session.DefaultSessionIdManager#5bbef235[worker=node0] - STARTED
| += org.eclipse.jetty.servlet.ErrorPageErrorHandler#1c2ee56f - STARTED
| |
| +> WebAppClassLoader=1053927516#3ed1a85c
| | +- sun.misc.Launcher$AppClassLoader#18b4aac2
| +> Systemclasses o.e.j.w.WebAppContext#2974d7ef{/myContext_persistent,file:///workspace/myApp/myApp-server/data/my_persistent/,AVAILABLE}{/workspace/myApp/myApp-server/data}
| | +- java.
| | +- javax.
| | +- org.eclipse.jetty.continuation.
| | +- org.eclipse.jetty.jaas.
| | +- org.eclipse.jetty.jmx.
| | +- org.eclipse.jetty.jndi.
| | +- org.eclipse.jetty.jsp.JettyJspServlet
| | +- org.eclipse.jetty.servlet.DefaultServlet
| | +- org.eclipse.jetty.servlets.PushCacheFilter
| | +- org.eclipse.jetty.servlets.PushSessionCacheFilter
| | +- org.eclipse.jetty.util.annotation.
| | +- org.eclipse.jetty.util.log.
| | +- org.eclipse.jetty.websocket.
| | +- org.w3c.
| | +- org.xml.
| +> Serverclasses o.e.j.w.WebAppContext#2974d7ef{/myContext_persistent,file:///workspace/myApp/myApp-server/data/my_persistent/,AVAILABLE}{/workspace/myApp/myApp-server/data}
| | +- -org.eclipse.jetty.alpn.
| | +- -org.eclipse.jetty.apache.
| | +- -org.eclipse.jetty.continuation.
| | +- -org.eclipse.jetty.jaas.
| | +- -org.eclipse.jetty.jmx.
| | +- -org.eclipse.jetty.jndi.
| | +- -org.eclipse.jetty.jsp.
| | +- -org.eclipse.jetty.server.session.SessionData
| | +- -org.eclipse.jetty.servlet.DefaultServlet
| | +- -org.eclipse.jetty.servlet.NoJspServlet
| | +- -org.eclipse.jetty.servlet.listener.
| | +- -org.eclipse.jetty.servlets.
| | +- -org.eclipse.jetty.util.annotation.
| | +- -org.eclipse.jetty.util.log.
| | +- -org.eclipse.jetty.websocket.
| | +- org.eclipse.jdt.
| | +- org.eclipse.jetty.
| | +- org.objectweb.asm.
| +> Configurations o.e.j.w.WebAppContext#2974d7ef{/myContext_persistent,file:///workspace/myApp/myApp-server/data/my_persistent/,AVAILABLE}{/workspace/myApp/myApp-server/data}
| | +- org.eclipse.jetty.webapp.WebInfConfiguration#5d3b3547
| | +- org.eclipse.jetty.webapp.WebXmlConfiguration#488aebda
| | +- org.eclipse.jetty.webapp.MetaInfConfiguration#5d7da87
| | +- org.eclipse.jetty.webapp.FragmentConfiguration#6eb942cf
| | +- org.eclipse.jetty.webapp.JettyWebXmlConfiguration#6a2cd352
| +> Handler attributes o.e.j.w.WebAppContext#2974d7ef{/myContext_persistent,file:///workspace/myApp/myApp-server/data/my_persistent/,AVAILABLE}{/workspace/myApp/myApp-server/data}
| | +- javax.servlet.context.tempdir=/private/var/folders/8p/f__1hb6j0p5bq7ljqdkjg35h0000gn/T/jetty-0.0.0.0-8080-my_persistent-_myContext_persistent-any-707911495794918084.dir
| | +- org.eclipse.jetty.server.Executor=qtp348159759{STARTED,10<=20<=200,i=2,q=0}
| +> Context attributes o.e.j.w.WebAppContext#2974d7ef{/myContext_persistent,file:///workspace/myApp/myApp-server/data/my_persistent/,AVAILABLE}{/workspace/myApp/myApp-server/data}
| | +- org.eclipse.jetty.util.DecoratedObjectFactory=org.eclipse.jetty.util.DecoratedObjectFactory[decorators=1]
| | +- com.sun.jsp.tagFileJarUrlsCache={}
| | +- resourceCache=ResourceCache[null,org.eclipse.jetty.servlet.DefaultServlet#756731f6]#1323290175
| | +- com.sun.jsp.taglibraryCache={}
| +> Initparams o.e.j.w.WebAppContext#2974d7ef{/myContext_persistent,file:///workspace/myApp/myApp-server/data/my_persistent/,AVAILABLE}{/workspace/myApp/myApp-server/data}
| +- org.eclipse.jetty.servlet.Default.dirAllowed=false
+= org.eclipse.jetty.server.handler.ErrorHandler#6ad45211 - STARTED
+- {}
+- {}
+- {}
+= org.eclipse.jetty.server.session.DefaultSessionIdManager#5bbef235[worker=node0] - STARTED
| += org.eclipse.jetty.server.session.HouseKeeper#666eba5a[interval=600000, ownscheduler=false] - STARTED
|
+> sun.misc.Launcher$AppClassLoader#18b4aac2
[LIBS]
+- sun.misc.Launcher$ExtClassLoader#fae8daf
The above code works fine with Jetty 9.1.5.v20140505 and Java 7 but when fail when I upgrade to Jetty 9.4.1.v20170120 and Java 8.
Browser console report an 404 error.
WebSocket connection to 'wss://localhost:8443/myContext/ws/communication/5/kbui/None' failed: Unexpected response code: 404
Did I miss something when upgrade Jetty?
Thanks in advance.
Judging from your setup, you'll wind up with ...
wss://localhost:8443/myContext/ws/communication/5/kbui/None
Your contextPath isn't /context, its actually /myContext in your setup.
You trimmed out the Servlet Mappings section on the dump (that was the important part. heh)
But attempting to manually add the WSCommunication Endpoint contained in WebAppContext from outside of the WebAppClassloader or the WebApp's ServletContext is probably going to be a problem as well.
You have 3 options:
The JSR356 Automatic Way
Setup bytecode scanning and annotation discovery for your WebAppContext and let the startup discover and auto-load the WSCommunication endpoint.
Add the following to your webContext ...
webContext.setAttribute("org.eclipse.jetty.websocket.jsr356",Boolean.TRUE);
webContext.setConfigurations(new Configuration[] {
new AnnotationConfiguration(),
new WebXmlConfiguration(),
new WebInfConfiguration(),
new PlusConfiguration(),
new MetaInfConfiguration(),
new FragmentConfiguration(),
new EnvConfiguration()});
And add the jetty-annotations dependency to your project.
The JSR356 Manual Way
Use the javax.websocket.server.ServerApplicationConfig to report the WSCommunication as being available to be added from within the webapp's startup.
The Servlet Spec Manual Way
This is the easiest approach.
Create a javax.servlet.ServletContextListener that adds the WSCommunication endpoint to the ServerContainer
public class MyContextListener implements ServletContextListener
{
#Override
public void contextDestroyed(ServletContextEvent sce)
{
}
#Override
public void contextInitialized(ServletContextEvent sce)
{
ServerContainer container = (ServerContainer)sce.getServletContext()
.getAttribute(ServerContainer.class.getName());
try
{
container.addEndpoint(WSCommunication.class);
}
catch (DeploymentException e)
{
throw new RuntimeException("Unable to add endpoint",e);
}
}
}
Related
Using Spring #Value annotation results in field not initialized error in Eclipse
I am currently developing a Spring Boot application in the Eclipse IDE with a Connection class which needs to know which data source to connect to. I decided to let it know this property from Spring's application.properties, through the #Value annotation: #Value("${project.datasource}") private final DataSource DATA_SOURCE; where DataSource is an enum representing the possible data sources. However, in this method, I get a "Blank final field DATA_SOURCE may not have been initialized" error: private DBConnection() throws SQLException { ConnectionConfig config = new ConnectionConfig(DATA_SOURCE); connection = DriverManager.getConnection(config.getUrl(), config.getUSERNAME(), config.getPASSWORD()); } Inserting a default value doesn't work, either: #Value("${project.datasource:POSTGRE_LOCAL}") still gives the same error. I tried to install the Spring Tools 4 plugin for Eclipse to check if this was just Eclipse not understanding the #Value annotation's implications, but it seems like this isn't the case. How do I solve this problem? Am I misunderstanding the implications myself? application.properties: project.datasource = POSTGRE_LOCAL Project tree: | .classpath | .gitignore | .project | HELP.md | mvnw | mvnw.cmd | pom.xml | +---.mvn | \---wrapper | maven-wrapper.jar | maven-wrapper.properties | +---.settings | org.eclipse.core.resources.prefs | org.eclipse.jdt.core.prefs | org.eclipse.m2e.core.prefs | org.springframework.ide.eclipse.prefs | +---src | +---main | | +---java | | | \---org | | | \---ingsw21 | | | \---backend | | | +---connection | | | | DBConnection.java | | | | | | | +---controllers | | | | UserController.java | | | | | | | +---DAOs | | | | DAOUtente.java | | | | | | | +---DAOSQL | | | | DAOSQLUtente.java | | | | | | | +---entities | | | | Utente.java | | | | | | | +---enums | | | | DataSource.java | | | | | | | \---exceptions | | | BadRequestWebException.java | | | DataAccessException.java | | | | | \---resources | | application.properties | | | \---test | \---java | \---org | \---ingsw21 | \---backend | \---BackEnd | BackEndApplicationTests.java | \---target +---classes | | application.properties | | | \---org | \---ingsw21 | \---backend | +---connection | | DBConnection$ConnectionConfig.class | | DBConnection.class | | | +---controllers | | UserController.class | | | +---DAOs | | DAOUtente.class | | | +---DAOSQL | | DAOSQLUtente.class | | | +---entities | | Utente.class | | | +---enums | | DataSource.class | | | \---exceptions | BadRequestWebException.class | DataAccessException.class | \---test-classes \---org
You cannot add #Value to a final field. #Value("${project.datasource}") private DataSource DATA_SOURCE; should work just fine.
Reverse the "$" and "{". The expression syntax is "${...}".
Spring Boot 2, LiquiGraph and 503 error with Actuator health endpoint - org.springframework.jdbc.UncategorizedSQLException
In my Spring Boot 2.0.0.M6 application, I have installed LiquiGraph by using the following Maven dependencies: dependency> <groupId>org.liquigraph</groupId> <artifactId>liquigraph-spring-boot-starter</artifactId> <version>3.0.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-jdbc-bolt</artifactId> <version>3.1.0</version> </dependency> I also use Spring Data Neo4j 5 and this is my Neo4j config: #Configuration #EnableNeo4jRepositories(basePackages = "com.example.domain.repository.neo4j") #EnableTransactionManagement public class Neo4jConfig { #Value("${neo4j.bolt.server.database.uri}") private String boltServerDatabaseUri; #Value("${neo4j.jdbc.server.database.uri}") private String jdbcServerDatabaseUri; #Value("${neo4j.username}") private String username; #Value("${neo4j.password}") private String password; #Bean public Neo4jTransactionManager transactionManager() { return new Neo4jTransactionManager(sessionFactory()); } #Bean public SessionFactory sessionFactory() { return new SessionFactory(configuration(), "com.example.domain.model.neo4j"); } #Bean #DependsOn("liquigraph") public org.neo4j.ogm.config.Configuration configuration() { // #formatter:off return new org.neo4j.ogm.config.Configuration.Builder() .autoIndex("validate") .credentials(username, password) .uri(boltServerDatabaseUri) .build(); // #formatter:on } #Bean public DataSource dataSource() { final HikariConfig config = new HikariConfig(); config.setJdbcUrl(jdbcServerDatabaseUri); config.setUsername(username); config.setPassword(password); return new HikariDataSource(config); } } Right now my Spring Boot Actuator health endpoint responds with the 503 Status code and the following error inside JSON: org.springframework.jdbc.UncategorizedSQLException { "status": "DOWN", "details": { "elasticsearch": { "status": "UP", "details": { "clusterName": "elasticsearch", "numberOfNodes": 1, "numberOfDataNodes": 1, "activePrimaryShards": 15, "activeShards": 15, "relocatingShards": 0, "initializingShards": 0, "unassignedShards": 15 } }, "diskSpace": { "status": "UP", "details": { "total": 120031539200, "free": 78051127296, "threshold": 10485760 } }, "mongo": { "status": "UP", "details": { "version": "3.4.6" } }, "db": { "status": "DOWN", "details": { "database": "Neo4j", "error": "org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [SELECT 1]; SQL state [null]; error code [0]; Some errors occurred : \n[Neo.ClientError.Statement.SyntaxError]:Invalid input 'L': expected 't/T' (line 1, column 3 (offset: 2))\n\"SELECT 1\"\n ^\n; nested exception is java.sql.SQLException: Some errors occurred : \n[Neo.ClientError.Statement.SyntaxError]:Invalid input 'L': expected 't/T' (line 1, column 3 (offset: 2))\n\"SELECT 1\"\n ^\n" } }, "neo4j": { "status": "UP", "details": { "nodes": 194 } } } } What may be a reason for this and how to fix it? UPDATED This is my project Maven dependencies tree: com.example:api:war:0.0.1 +- com.example:domain:jar:0.0.1:compile | +- org.neo4j:neo4j-ogm-bolt-driver:jar:3.0.1:compile | | +- org.neo4j:neo4j-ogm-api:jar:3.0.1:compile | | \- org.neo4j.driver:neo4j-java-driver:jar:1.4.4:compile | +- org.springframework.social:spring-social-security:jar:2.0.0.M4:compile | | \- org.springframework.security:spring-security-web:jar:5.0.0.RC1:compile | +- org.springframework.security.oauth:spring-security-oauth2:jar:2.2.0.RELEASE:compile | | +- org.springframework.security:spring-security-core:jar:5.0.0.RC1:compile | | +- org.springframework.security:spring-security-config:jar:5.0.0.RC1:compile | | \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile | | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile | +- org.springframework:spring-context-support:jar:5.0.1.RELEASE:compile | +- org.springframework.boot:spring-boot-starter-data-neo4j:jar:2.0.0.M6:compile | | \- org.springframework.data:spring-data-neo4j:jar:5.0.1.RELEASE:compile | | +- org.springframework.data:spring-data-commons:jar:2.0.1.RELEASE:compile | | \- org.neo4j:neo4j-ogm-core:jar:3.0.1:compile | | \- io.github.lukehutch:fast-classpath-scanner:jar:2.7.4:compile | +- org.liquigraph:liquigraph-spring-boot-starter:jar:3.0.2:compile | | \- org.liquigraph:liquigraph-core:jar:3.0.2:compile | | \- org.neo4j:neo4j-jdbc-driver:jar:3.1.0:compile | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.0.M6:compile | | +- com.zaxxer:HikariCP:jar:2.7.2:compile | | \- org.springframework:spring-jdbc:jar:5.0.1.RELEASE:compile | +- org.neo4j:neo4j-jdbc-bolt:jar:3.1.0:compile | | \- org.neo4j:neo4j-jdbc:jar:3.1.0:compile | +- org.springframework.boot:spring-boot-starter-data-mongodb:jar:2.0.0.M6:compile | | +- org.mongodb:mongodb-driver:jar:3.5.0:compile | | | +- org.mongodb:bson:jar:3.5.0:compile | | | \- org.mongodb:mongodb-driver-core:jar:3.5.0:compile | | \- org.springframework.data:spring-data-mongodb:jar:2.0.1.RELEASE:compile | +- org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:2.0.0.M6:compile | | \- org.springframework.data:spring-data-elasticsearch:jar:3.0.1.RELEASE:compile | | +- commons-lang:commons-lang:jar:2.6:compile | | +- joda-time:joda-time:jar:2.9.9:compile | | +- org.elasticsearch:elasticsearch:jar:5.5.3:compile | | | +- org.apache.lucene:lucene-core:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-analyzers-common:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-backward-codecs:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-grouping:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-highlighter:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-join:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-memory:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-misc:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-queries:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-queryparser:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-sandbox:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-spatial:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-spatial-extras:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-spatial3d:jar:6.6.0:compile | | | +- org.apache.lucene:lucene-suggest:jar:6.6.0:compile | | | +- org.elasticsearch:securesm:jar:1.1:compile | | | +- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile | | | +- com.carrotsearch:hppc:jar:0.7.1:compile | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.9.2:compile | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.9.2:compile | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.9.2:compile | | | +- com.tdunning:t-digest:jar:3.0:compile | | | \- org.elasticsearch:jna:jar:4.4.0:compile | | +- org.elasticsearch.client:transport:jar:5.5.3:compile | | | +- org.elasticsearch.plugin:transport-netty3-client:jar:5.5.3:compile | | | | \- io.netty:netty:jar:3.10.6.Final:compile | | | +- org.elasticsearch.plugin:reindex-client:jar:5.5.3:compile | | | | \- org.elasticsearch.client:rest:jar:5.5.3:compile | | | | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.3:compile | | | | \- org.apache.httpcomponents:httpcore-nio:jar:4.4.8:compile | | | +- org.elasticsearch.plugin:lang-mustache-client:jar:5.5.3:compile | | | | \- com.github.spullara.mustache.java:compiler:jar:0.9.3:compile | | | +- org.elasticsearch.plugin:percolator-client:jar:5.5.3:compile | | | \- org.elasticsearch.plugin:parent-join-client:jar:5.5.3:compile | | \- org.elasticsearch.plugin:transport-netty4-client:jar:5.5.3:compile | | +- io.netty:netty-buffer:jar:4.1.16.Final:compile | | +- io.netty:netty-codec:jar:4.1.16.Final:compile | | +- io.netty:netty-codec-http:jar:4.1.16.Final:compile | | +- io.netty:netty-common:jar:4.1.16.Final:compile | | +- io.netty:netty-handler:jar:4.1.16.Final:compile | | +- io.netty:netty-resolver:jar:4.1.16.Final:compile | | \- io.netty:netty-transport:jar:4.1.16.Final:compile | +- org.springframework.boot:spring-boot-starter-security:jar:2.0.0.M6:compile | +- org.springframework.boot:spring-boot-starter-validation:jar:2.0.0.M6:compile | +- org.springframework.boot:spring-boot-starter-social-twitter:jar:2.0.0.M6:compile | | \- org.springframework.social:spring-social-twitter:jar:2.0.0.M4:compile | | \- org.springframework.security:spring-security-crypto:jar:5.0.0.RC1:compile | +- org.springframework.kafka:spring-kafka:jar:2.0.0.RELEASE:compile | | +- org.springframework:spring-messaging:jar:5.0.1.RELEASE:compile | | +- org.springframework.retry:spring-retry:jar:1.2.1.RELEASE:compile | | \- org.apache.kafka:kafka-clients:jar:0.11.0.0:compile | | +- net.jpountz.lz4:lz4:jar:1.3.0:compile | | \- org.xerial.snappy:snappy-java:jar:1.1.2.6:compile | +- com.google.guava:guava:jar:19.0-rc1:compile | +- com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:jar:20160924.1:compile | +- eu.bitwalker:UserAgentUtils:jar:1.20:compile | +- org.quartz-scheduler:quartz:jar:2.3.0:compile | | +- com.mchange:c3p0:jar:0.9.5.2:compile | | +- com.mchange:mchange-commons-java:jar:0.2.11:compile | | \- com.zaxxer:HikariCP-java6:jar:2.3.13:compile | \- com.novemberain:quartz-mongodb:jar:2.0.0:compile | +- org.mongodb:mongo-java-driver:jar:3.5.0:runtime | \- org.clojure:clojure:jar:1.7.0:runtime +- com.example:coinmarketcap:jar:0.0.1:compile +- org.springframework.boot:spring-boot-starter-web:jar:2.0.0.M6:compile | +- org.springframework.boot:spring-boot-starter-json:jar:2.0.0.M6:compile | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.2:compile | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.2:compile | | +- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.2:compile | | \- com.fasterxml.jackson.module:jackson-module-kotlin:jar:2.9.2:compile | +- org.hibernate.validator:hibernate-validator:jar:6.0.4.Final:compile | | +- javax.validation:validation-api:jar:2.0.0.Final:compile | | \- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile | +- org.springframework:spring-web:jar:5.0.1.RELEASE:compile | \- org.springframework:spring-webmvc:jar:5.0.1.RELEASE:compile +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:2.0.0.M6:compile | +- org.thymeleaf:thymeleaf-spring5:jar:3.0.8.RELEASE:compile | | \- org.thymeleaf:thymeleaf:jar:3.0.8.RELEASE:compile | | +- org.attoparser:attoparser:jar:2.0.4.RELEASE:compile | | \- org.unbescape:unbescape:jar:1.1.5.RELEASE:compile | \- org.thymeleaf.extras:thymeleaf-extras-java8time:jar:3.0.1.RELEASE:compile +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.0.M6:compile | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile | | \- org.apache.tomcat:tomcat-annotations-api:jar:8.5.23:compile | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.23:compile +- org.springframework.boot:spring-boot-starter-actuator:jar:2.0.0.M6:compile | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.0.0.M6:compile | | \- org.springframework.boot:spring-boot-actuator:jar:2.0.0.M6:compile | \- io.micrometer:micrometer-core:jar:1.0.0-rc.3:compile | +- org.hdrhistogram:HdrHistogram:jar:2.1.10:compile | \- org.latencyutils:LatencyUtils:jar:2.0.3:compile +- org.springframework.boot:spring-boot-starter-social-facebook:jar:2.0.0.M6:compile | +- org.springframework.social:spring-social-config:jar:2.0.0.M4:compile | +- org.springframework.social:spring-social-core:jar:2.0.0.M4:compile | +- org.springframework.social:spring-social-web:jar:2.0.0.M4:compile | \- org.springframework.social:spring-social-facebook:jar:3.0.0.M3:compile +- org.springframework.boot:spring-boot-starter-social-linkedin:jar:2.0.0.M6:compile | \- org.springframework.social:spring-social-linkedin:jar:2.0.0.M3:compile +- org.springframework.security:spring-security-jwt:jar:1.0.8.RELEASE:compile | \- org.bouncycastle:bcpkix-jdk15on:jar:1.56:compile | \- org.bouncycastle:bcprov-jdk15on:jar:1.56:compile +- org.springframework.social:spring-social-google:jar:1.0.0.RELEASE:compile +- org.springframework.social:spring-social-github:jar:1.0.0.M4:compile +- com.jayway.jsonpath:json-path:jar:2.4.0:test | +- net.minidev:json-smart:jar:2.3:test | | \- net.minidev:accessors-smart:jar:1.2:test | | \- org.ow2.asm:asm:jar:5.0.4:test | \- org.slf4j:slf4j-api:jar:1.7.25:compile +- com.jayway.jsonpath:json-path-assert:jar:2.4.0:test | +- org.hamcrest:hamcrest-core:jar:1.3:test | \- org.hamcrest:hamcrest-library:jar:1.3:test +- javax.servlet:javax.servlet-api:jar:3.1.0:provided +- javax:javaee-web-api:jar:7.0:provided +- org.apache.httpcomponents:httpclient:jar:4.5.3:compile | +- org.apache.httpcomponents:httpcore:jar:4.4.8:compile | \- commons-codec:commons-codec:jar:1.11:compile +- io.springfox:springfox-swagger2:jar:2.6.0:compile | +- io.swagger:swagger-annotations:jar:1.5.10:compile | +- io.swagger:swagger-models:jar:1.5.10:compile | +- io.springfox:springfox-spi:jar:2.6.0:compile | | \- io.springfox:springfox-core:jar:2.6.0:compile | +- io.springfox:springfox-schema:jar:2.6.0:compile | +- io.springfox:springfox-swagger-common:jar:2.6.0:compile | +- io.springfox:springfox-spring-web:jar:2.6.0:compile | +- com.fasterxml:classmate:jar:1.3.4:compile | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile | \- org.mapstruct:mapstruct:jar:1.0.0.Final:compile +- io.springfox:springfox-swagger-ui:jar:2.6.0:compile +- com.github.dfabulich:sitemapgen4j:jar:1.0.6:compile +- com.jayway.restassured:rest-assured:jar:2.9.0:test | +- org.codehaus.groovy:groovy:jar:2.5.0-beta-1:test | +- org.codehaus.groovy:groovy-xml:jar:2.5.0-beta-1:test | +- org.apache.httpcomponents:httpmime:jar:4.5.3:test | +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:test | +- com.jayway.restassured:json-path:jar:2.9.0:test | | +- org.codehaus.groovy:groovy-json:jar:2.5.0-beta-1:test | | \- com.jayway.restassured:rest-assured-common:jar:2.9.0:test | \- com.jayway.restassured:xml-path:jar:2.9.0:test +- com.google.code.gson:gson:jar:2.8.2:compile +- javax.xml.bind:jaxb-api:jar:2.2.12:compile +- com.fasterxml.jackson.core:jackson-core:jar:2.9.2:compile +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.2:compile +- org.springframework:spring-core:jar:5.0.1.RELEASE:compile | \- org.springframework:spring-jcl:jar:5.0.1.RELEASE:compile +- org.springframework:spring-beans:jar:5.0.1.RELEASE:compile +- org.springframework:spring-aop:jar:5.0.1.RELEASE:compile +- org.springframework:spring-aspects:jar:5.0.1.RELEASE:compile | \- org.aspectj:aspectjweaver:jar:1.8.12:compile +- org.springframework:spring-context:jar:5.0.1.RELEASE:compile +- org.springframework:spring-expression:jar:5.0.1.RELEASE:compile +- org.springframework:spring-tx:jar:5.0.1.RELEASE:compile +- org.springframework.boot:spring-boot-starter:jar:2.0.0.M6:compile | +- javax.annotation:javax.annotation-api:jar:1.3.1:compile | \- org.yaml:snakeyaml:jar:1.19:compile +- org.springframework.boot:spring-boot:jar:2.0.0.M6:compile +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.0.M6:compile +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.M6:compile | +- ch.qos.logback:logback-classic:jar:1.2.3:compile | | \- ch.qos.logback:logback-core:jar:1.2.3:compile | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.9.1:compile | | \- org.apache.logging.log4j:log4j-api:jar:2.9.1:compile | +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile | \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile +- org.springframework.boot:spring-boot-starter-test:jar:2.0.0.M6:test | +- org.springframework.boot:spring-boot-test:jar:2.0.0.M6:test | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.0.M6:test | +- org.assertj:assertj-core:jar:3.8.0:test | +- org.mockito:mockito-core:jar:2.11.0:test | | +- net.bytebuddy:byte-buddy:jar:1.7.8:test | | +- net.bytebuddy:byte-buddy-agent:jar:1.7.8:test | | \- org.objenesis:objenesis:jar:2.6:test | +- org.skyscreamer:jsonassert:jar:1.5.0:test | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test | +- org.springframework:spring-test:jar:5.0.1.RELEASE:test | \- org.xmlunit:xmlunit-core:jar:2.5.0:test +- javax.enterprise:cdi-api:jar:2.0-EDR1:compile | +- javax.el:javax.el-api:jar:3.0.0:compile | +- javax.interceptor:javax.interceptor-api:jar:1.2:compile | \- javax.inject:javax.inject:jar:1:compile +- javax.transaction:jta:jar:1.1:compile +- org.apache.commons:commons-lang3:jar:3.4:compile +- commons-validator:commons-validator:jar:1.5.0:compile | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile | +- commons-digester:commons-digester:jar:2.1:compile | +- commons-logging:commons-logging:jar:1.2:compile | \- commons-collections:commons-collections:jar:3.2.2:compile +- commons-io:commons-io:jar:2.4:compile +- org.apache.commons:commons-compress:jar:1.14:compile \- junit:junit:jar:4.12:test
tl;dr; Add management.health.db.enabled=false to your config. Details Because you are also registering a JDBC DataSource in your config to work with liquigraph, the auto configuration of SpringBoot kicks in and registers an additional HealthIndicator for this db. You can deactivate this indicator by setting management.health.db.enabled=false. Just some more information for you if you plan to upgrade to SpringBoot 2.0.0.M7: The configuration for health check has changed to: management.endpoint.health.enabled=true management.endpoint.health.show-details=ALWAYS management.health.db.enabled=false
As an alternative workaround, you can still get the health check for your datasource in the following way, effectively shadowing the auto-configured DataSourceHealthIndicator bean: #Bean public DataSourceHealthIndicator dataSourceHealthIndicator(DataSource datasource) { return new DataSourceHealthIndicator(datasource, "match (n) return count(n) as nodes"); }
Spring Boot application slow memory leak
I recently deployed a Spring Boot application that is scheduled to run every day in order to parse new data from a Cassandra cluster. After around 20 hours of work (some million read/write accesses to Cassandra) some memory issues arise and at each iteration (the exception is caught within the loop) I have this error: java.lang.RuntimeException: java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.createAccessorClass(ClassGeneratingPropertyAccessorFactory.java:170) at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.potentiallyCreateAndRegisterPersistentPropertyAccessorClass(ClassGeneratingPropertyAccessorFactory.java:154) at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.getPropertyAccessor(ClassGeneratingPropertyAccessorFactory.java:80) at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:425) at org.springframework.data.cassandra.convert.MappingCassandraConverter.getConvertingAccessor(MappingCassandraConverter.java:611) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readEntityFromRow(MappingCassandraConverter.java:172) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readRow(MappingCassandraConverter.java:149) at com.myapp.utils.CassandraIterable$1.next(CassandraIterable.java:35) at com.myapp.service.packer.PositionParsingService.parse(PositionParsingService.java:60) at com.myapp.service.packer.PositionLoadService.update(PositionLoadService.java:202) at com.myapp.service.packer.PositionLoadService.updateVehicle(PositionLoadService.java:129) at com.myapp.service.packer.PositionLoadService.updateAllVehicles(PositionLoadService.java:99) at com.myapp.service.packer.PositionLoadService.updateAllVehicles(PositionLoadService.java:84) at com.myapp.service.packer.PositionLoadService$$FastClassBySpringCGLIB$$2605bc6c.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115) 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.IllegalStateException: java.lang.reflect.InvocationTargetException at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory$Evil.defineClass(ClassGeneratingPropertyAccessorFactory.java:1480) at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory$PropertyAccessorClassGenerator.generateCustomAccessorClass(ClassGeneratingPropertyAccessorFactory.java:282) at org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.createAccessorClass(ClassGeneratingPropertyAccessorFactory.java:168) ... 21 common frames omitted Caused by: java.lang.reflect.InvocationTargetException: null 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.data.mapping.model.ClassGeneratingPropertyAccessorFactory$Evil.defineClass(ClassGeneratingPropertyAccessorFactory.java:1476) ... 23 common frames omitted Caused by: java.lang.OutOfMemoryError: Compressed class space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ... 28 common frames omitted By analysing the memory dumps produced after the issue occurred I had this report: From Java mission control, after I run a garbage collection, I get: I don't think my code is directly responsible for the leak, even though there could be something it isn't releasing when it should or there could be some config issue I overlooked. I tried to upgrade java from JDK SE 8u60 to 8u121 and to upgrade Spring boot to version 1.5.2.RELEASE. Here's the complete list of dependencies: com.myapp:jar:0.0.1-SNAPSHOT +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.2.RELEASE:compile | +- org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile | | +- (org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:compile - omitted for duplicate) | | +- (org.springframework.boot:spring-boot-autoconfigure:jar:1.5.2.RELEASE:compile - omitted for duplicate) | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.2.RELEASE:compile | | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile | | | | +- ch.qos.logback:logback-core:jar:1.1.11:compile | | | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) | | | +- org.slf4j:jcl-over-slf4j:jar:1.7.24:compile | | | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) | | | +- org.slf4j:jul-to-slf4j:jar:1.7.24:compile | | | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) | | | \- org.slf4j:log4j-over-slf4j:jar:1.7.24:compile | | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) | | +- org.springframework:spring-core:jar:4.3.7.RELEASE:compile | | \- org.yaml:snakeyaml:jar:1.17:runtime | +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.2.RELEASE:compile | | +- (org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile - omitted for duplicate) | | +- org.springframework:spring-aop:jar:4.3.7.RELEASE:compile | | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | \- org.aspectj:aspectjweaver:jar:1.8.9:compile | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.2.RELEASE:compile | | +- (org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile - omitted for duplicate) | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.11:compile | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.11:compile | | \- org.springframework:spring-jdbc:jar:4.3.7.RELEASE:compile | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | \- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate) | +- org.hibernate:hibernate-core:jar:5.0.12.Final:compile | | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile | | +- org.javassist:javassist:jar:3.21.0-GA:compile (version managed from 3.18.1-GA) | | +- antlr:antlr:jar:2.7.7:compile | | +- org.jboss:jandex:jar:2.0.0.Final:compile | | +- dom4j:dom4j:jar:1.6.1:compile | | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile | | \- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate) | +- org.hibernate:hibernate-entitymanager:jar:5.0.12.Final:compile | | +- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate) | | +- (org.hibernate:hibernate-core:jar:5.0.12.Final:compile - omitted for duplicate) | | +- (dom4j:dom4j:jar:1.6.1:compile - omitted for duplicate) | | +- (org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile - omitted for duplicate) | | +- (org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile - omitted for duplicate) | | \- (org.javassist:javassist:jar:3.21.0-GA:compile - version managed from 3.18.1-GA; omitted for duplicate) | +- javax.transaction:javax.transaction-api:jar:1.2:compile | +- org.springframework.data:spring-data-jpa:jar:1.11.1.RELEASE:compile | | +- org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile | | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | +- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.22; omitted for duplicate) | | | \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:runtime - omitted for duplicate) | | +- org.springframework:spring-orm:jar:4.3.7.RELEASE:compile | | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | +- (org.springframework:spring-jdbc:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | \- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- org.springframework:spring-context:jar:4.3.7.RELEASE:compile | | | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | | \- (org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- org.springframework:spring-beans:jar:4.3.7.RELEASE:compile | | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- org.slf4j:slf4j-api:jar:1.7.24:compile | | \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:compile - scope updated from runtime; omitted for duplicate) | \- org.springframework:spring-aspects:jar:4.3.7.RELEASE:compile | \- (org.aspectj:aspectjweaver:jar:1.8.9:compile - omitted for duplicate) +- org.springframework.boot:spring-boot-starter-web:jar:1.5.2.RELEASE:compile | +- (org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile - omitted for duplicate) | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.2.RELEASE:compile | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile | | \- (org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile - omitted for duplicate) | +- org.hibernate:hibernate-validator:jar:5.3.4.Final:compile | | +- javax.validation:validation-api:jar:1.1.0.Final:compile | | +- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate) | | \- com.fasterxml:classmate:jar:1.3.3:compile (version managed from 1.3.1) | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile | | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - omitted for duplicate) | | \- (com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile - omitted for duplicate) | +- org.springframework:spring-web:jar:4.3.7.RELEASE:compile | | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | \- org.springframework:spring-webmvc:jar:4.3.7.RELEASE:compile | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate) | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | +- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate) | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | +- org.springframework:spring-expression:jar:4.3.7.RELEASE:compile | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | \- (org.springframework:spring-web:jar:4.3.7.RELEASE:compile - omitted for duplicate) +- org.springframework.boot:spring-boot-starter-data-cassandra:jar:1.5.2.RELEASE:compile | +- (org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile - omitted for duplicate) | +- org.springframework:spring-tx:jar:4.3.7.RELEASE:compile | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | \- org.springframework.data:spring-data-cassandra:jar:1.5.1.RELEASE:compile | +- org.springframework.data:spring-cql:jar:1.5.1.RELEASE:compile | | +- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | +- (org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile - omitted for duplicate) | | +- (com.datastax.cassandra:cassandra-driver-core:jar:3.1.4:compile - version managed from 3.1.3; omitted for duplicate) | | +- (com.google.guava:guava:jar:19.0:compile - omitted for conflict with 16.0.1) | | +- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.7; omitted for duplicate) | | \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:runtime - omitted for duplicate) | +- (org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - omitted for duplicate) | +- (org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile - omitted for duplicate) | +- (com.datastax.cassandra:cassandra-driver-core:jar:3.1.4:compile - version managed from 3.1.3; omitted for duplicate) | +- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.7; omitted for duplicate) | \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:compile - scope updated from runtime; omitted for duplicate) +- org.springframework.boot:spring-boot-devtools:jar:1.5.2.RELEASE:compile | +- org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:compile | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate) | | \- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate) | \- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.2.RELEASE:compile | \- (org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:compile - omitted for duplicate) +- com.datastax.cassandra:cassandra-driver-mapping:jar:3.1.4:compile | \- com.datastax.cassandra:cassandra-driver-core:jar:3.1.4:compile | +- io.netty:netty-handler:jar:4.0.37.Final:compile | | +- io.netty:netty-buffer:jar:4.0.37.Final:compile | | | \- io.netty:netty-common:jar:4.0.37.Final:compile | | +- io.netty:netty-transport:jar:4.0.37.Final:compile | | | \- (io.netty:netty-buffer:jar:4.0.37.Final:compile - omitted for duplicate) | | \- io.netty:netty-codec:jar:4.0.37.Final:compile | | \- (io.netty:netty-transport:jar:4.0.37.Final:compile - omitted for duplicate) | +- com.google.guava:guava:jar:16.0.1:compile | +- io.dropwizard.metrics:metrics-core:jar:3.1.3:compile (version managed from 3.1.2) | | \- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.7; omitted for duplicate) | +- com.github.jnr:jnr-ffi:jar:2.0.7:compile | | +- com.github.jnr:jffi:jar:1.2.10:compile | | +- com.github.jnr:jffi:jar:native:1.2.10:runtime | | +- org.ow2.asm:asm:jar:5.0.3:compile | | +- org.ow2.asm:asm-commons:jar:5.0.3:compile | | | \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate) | | +- org.ow2.asm:asm-analysis:jar:5.0.3:compile | | | \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate) | | +- org.ow2.asm:asm-tree:jar:5.0.3:compile | | | \- (org.ow2.asm:asm:jar:5.0.3:compile - omitted for duplicate) | | +- org.ow2.asm:asm-util:jar:5.0.3:compile | | | \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate) | | \- com.github.jnr:jnr-x86asm:jar:1.0.2:compile | \- com.github.jnr:jnr-posix:jar:3.0.27:compile | +- (com.github.jnr:jnr-ffi:jar:2.0.7:compile - omitted for duplicate) | \- com.github.jnr:jnr-constants:jar:0.9.0:compile +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.8.7:compile | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile | +- com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile | \- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - omitted for duplicate) +- com.oracle.jdbc:ojdbc7:jar:12.1.0.2:compile | +- com.oracle.jdbc:xdb6:jar:12.1.0.2:compile | +- com.oracle.jdbc:orai18n:jar:12.1.0.2:compile | +- com.oracle.jdbc:xmlparserv2:jar:12.1.0.2:compile | +- com.oracle.jdbc:oraclepki:jar:12.1.0.2:compile | +- com.oracle.jdbc:osdt_cert:jar:12.1.0.2:compile | \- com.oracle.jdbc:osdt_core:jar:12.1.0.2:compile +- com.mycompany:Pandora-json:jar:2.1.0-SNAPSHOT:compile | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - version managed from 2.5.4; omitted for duplicate) | +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - version managed from 2.5.4; omitted for duplicate) | +- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.8.7:compile (version managed from 2.5.4) | | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - version managed from 2.5.4; omitted for duplicate) | | +- (com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile - omitted for duplicate) | | +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - version managed from 2.5.4; omitted for duplicate) | | \- (joda-time:joda-time:jar:2.9.7:compile - version managed from 2.7; omitted for duplicate) | \- com.fasterxml.jackson.datatype:jackson-datatype-guava:jar:2.8.7:compile (version managed from 2.4.0) | +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - version managed from 2.5.4; omitted for duplicate) | +- (com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile - omitted for duplicate) | \- (com.google.guava:guava:jar:16.0:compile - omitted for conflict with 16.0.1) +- javax.inject:javax.inject:jar:1:compile +- joda-time:joda-time:jar:2.9.7:compile +- org.projectlombok:lombok:jar:1.16.14:compile +- org.springframework.boot:spring-boot-starter-test:jar:1.5.2.RELEASE:test | +- org.springframework.boot:spring-boot-test:jar:1.5.2.RELEASE:test | | \- (org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:test - omitted for duplicate) | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.2.RELEASE:test | | +- (org.springframework.boot:spring-boot-test:jar:1.5.2.RELEASE:test - omitted for duplicate) | | \- (org.springframework.boot:spring-boot-autoconfigure:jar:1.5.2.RELEASE:test - omitted for duplicate) | +- com.jayway.jsonpath:json-path:jar:2.2.0:test | | +- net.minidev:json-smart:jar:2.2.1:test | | | \- net.minidev:accessors-smart:jar:1.1:test | | | \- (org.ow2.asm:asm:jar:5.0.3:test - omitted for duplicate) | | \- (org.slf4j:slf4j-api:jar:1.7.24:test - version managed from 1.7.16; omitted for duplicate) | +- junit:junit:jar:4.12:test | | \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplicate) | +- (org.assertj:assertj-core:jar:2.6.0:test - omitted for conflict with 3.6.2) | +- org.mockito:mockito-core:jar:1.10.19:test | | +- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplicate) | | \- org.objenesis:objenesis:jar:2.1:test | +- org.hamcrest:hamcrest-core:jar:1.3:test | +- org.hamcrest:hamcrest-library:jar:1.3:test | | \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplicate) | +- org.skyscreamer:jsonassert:jar:1.4.0:test | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - scope updated from test; omitted for duplicate) | \- org.springframework:spring-test:jar:4.3.7.RELEASE:test | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:test - omitted for duplicate) +- commons-lang:commons-lang:jar:2.2:compile +- org.assertj:assertj-core:jar:3.6.2:compile +- org.mockito:mockito-all:jar:1.10.19:test +- net.sourceforge.dynamicreports:dynamicreports-core:jar:4.1.1:compile | +- net.sf.jasperreports:jasperreports:jar:6.2.2:compile | | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile (version managed from 1.9.0) | | | \- (commons-collections:commons-collections:jar:3.2.2:compile - omitted for duplicate) | | +- commons-collections:commons-collections:jar:3.2.2:compile | | +- commons-digester:commons-digester:jar:2.1:compile | | | \- (commons-beanutils:commons-beanutils:jar:1.9.3:compile - version managed from 1.8.3; omitted for duplicate) | | +- commons-logging:commons-logging:jar:1.1.1:compile | | +- com.lowagie:itext:jar:2.1.7.js5:compile | | | \- bouncycastle:bcprov-jdk14:jar:138:compile | | +- org.jfree:jcommon:jar:1.0.23:compile | | +- org.jfree:jfreechart:jar:1.0.19:compile | | | \- (org.jfree:jcommon:jar:1.0.23:compile - omitted for duplicate) | | +- org.eclipse.jdt.core.compiler:ecj:jar:4.3.1:compile | | +- (com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile - version managed from 2.1.4; omitted for duplicate) | | +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile - version managed from 2.1.4; omitted for duplicate) | | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - version managed from 2.1.4; omitted for duplicate) | | \- com.google.zxing:core:jar:2.3.0:compile | +- org.apache.commons:commons-lang3:jar:3.1:compile | +- net.sf.barcode4j:barcode4j:jar:2.0:compile | | +- avalon-framework:avalon-framework-impl:jar:4.2.0:compile | | \- xml-apis:xml-apis:jar:1.4.01:compile (version managed from 1.3.04) | \- org.apache.xmlgraphics:batik-bridge:jar:1.8:compile | +- org.apache.xmlgraphics:batik-anim:jar:1.8:compile | | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-css:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-dom:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-ext:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-parser:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-svg-dom:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) | | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) | +- org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile | | \- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | +- org.apache.xmlgraphics:batik-css:jar:1.8:compile | | +- (org.apache.xmlgraphics:batik-ext:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) | | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) | +- org.apache.xmlgraphics:batik-dom:jar:1.8:compile | | +- (org.apache.xmlgraphics:batik-css:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-ext:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-xml:jar:1.8:compile - omitted for duplicate) | | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) | | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) | +- org.apache.xmlgraphics:batik-ext:jar:1.8:compile | | \- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) | +- org.apache.xmlgraphics:batik-gvt:jar:1.8:compile | | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile - omitted for duplicate) | | \- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | +- org.apache.xmlgraphics:batik-parser:jar:1.8:compile | | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-xml:jar:1.8:compile - omitted for duplicate) | | \- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) | +- org.apache.xmlgraphics:batik-script:jar:1.8:compile | | +- (org.apache.xmlgraphics:batik-anim:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | | \- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) | +- org.apache.xmlgraphics:batik-svg-dom:jar:1.8:compile | | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-css:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-dom:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-ext:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-parser:jar:1.8:compile - omitted for duplicate) | | +- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) | | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) | +- org.apache.xmlgraphics:batik-util:jar:1.8:compile | +- org.apache.xmlgraphics:batik-xml:jar:1.8:compile | | \- (org.apache.xmlgraphics:batik-util:jar:1.8:compile - omitted for duplicate) | +- (xml-apis:xml-apis:jar:1.4.01:compile - version managed from 1.3.04; omitted for duplicate) | \- xml-apis:xml-apis-ext:jar:1.3.04:compile +- org.apache.poi:poi:jar:3.14:compile | \- commons-codec:commons-codec:jar:1.10:compile \- org.apache.poi:poi-ooxml:jar:3.14:compile +- (org.apache.poi:poi:jar:3.14:compile - omitted for duplicate) +- org.apache.poi:poi-ooxml-schemas:jar:3.14:compile | \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile | \- stax:stax-api:jar:1.0.1:compile \- com.github.virtuald:curvesapi:jar:1.03:compile
I finally managed to fix the issue. What was causing it was the fact that I was re-instantiating MappingCassandraConverter for each instance of CassandraIterable. public class CassandraIterable<T> implements Iterable<T> { private final Iterator<Row> iterator; private final Class<T> entityType; private final MappingCassandraConverter converter = new MappingCassandraConverter (); ... } while I should have created it once and passed it to the Iterable: public class CassandraIterable<T> implements Iterable<T> { private final Iterator<Row> iterator; private final Class<T> entityType; private final MappingCassandraConverter converter; public CassandraIterable(Iterator<Row> iterator, Class<T> entityType, MappingCassandraConverter converter) { this.iterator = iterator; this.entityType = entityType; this.converter = converter; } #Override public Iterator<T> iterator() { return new Iterator<T>() { #Override public boolean hasNext() { return iterator.hasNext(); } #Override public T next() { return converter.readRow(entityType, iterator.next()); } }; } } MappingCassandraConverter wasn't garbage collected (I presume that the Cassandra session was pointing to it) and the accessor to my class was probably pointed by the the converter. The reason why I couldn't find the leak is that there wasn't a specific Type involved in the leak: I was expecting to see one of my types repeated million of times in memory because of the leak instead. The reason why this wasn't happening is the fact that the issue in my code was creating a lot of accessors to Cassandra entities even though there was just one class type to be generated. For this reason the classes that were involved in the leak were something like: and they were not at the top of the list that was grouped by type sorted by the total size.
Executable JAR unable to find Liquibase db/changelog.xml
The project runs as expected with spring-boot:run. However, the executable JAR fails to run because it cannot find db/changelog.xml. The following steps can be used to reproduce the problem: run mvn package from project root go to target folder run java -jar executable-jar-with-liquibase-1.0.0-SNAPSHOT.jar The log will now show an error because the table domain has not been created. Note that the application.yml is found, since if liquibase.enabled is set to false, it will refuse to run entirely (as it should). application.yml server: context-path: /api spring: datasource: platform: h2 url: jdbc:h2:mem:testdb;MODE=PostgreSQL;DB_CLOSE_ON_EXIT=FALSE jackson: date-format: yyyy-MM-dd jpa: database-platform: org.hibernate.dialect.PostgreSQLDialect hibernate: ddl-auto: none liquibase: enabled: false change-log: classpath:db/changelog.xml The generated JAR has the following contents: . |____BOOT-INF | |____classes | | |____application.yml | | |____db | | | |____changelog.xml | | | |____changelogs | | | | |____changelog_000.xml | | |____nl | | | |_____42 | | | | |____app | | | | | |____ApplicationConfig.class | | | | | |____domain | | | | | | |____Domain.class | | | | | | |____DomainController.class | | | | | | |____DomainRepository.class | | | | | | |____DomainService.class | | | | | |____shared | | | | | | |____AbstractEntity.class | | | | | |____WebAppConfig.class | | | | | |____WebApplication.class | |____lib | | |____accessors-smart-1.1.jar | | |____antlr-2.7.7.jar | | |____asm-5.0.3.jar | | |____aspectjweaver-1.8.9.jar | | |____assertj-core-2.5.0.jar | | |____classmate-1.3.1.jar | | |____dom4j-1.6.1.jar | | |____h2-1.4.192.jar | | |____hamcrest-core-1.3.jar | | |____hamcrest-library-1.3.jar | | |____hibernate-commons-annotations-5.0.1.Final.jar | | |____hibernate-core-5.0.11.Final.jar | | |____hibernate-entitymanager-5.0.11.Final.jar | | |____hibernate-jpa-2.1-api-1.0.0.Final.jar | | |____hibernate-validator-5.2.4.Final.jar | | |____jackson-annotations-2.8.3.jar | | |____jackson-core-2.8.3.jar | | |____jackson-databind-2.8.3.jar | | |____jackson-datatype-jsr310-2.8.3.jar | | |____jandex-2.0.0.Final.jar | | |____javassist-3.20.0-GA.jar | | |____javax.transaction-api-1.2.jar | | |____jboss-logging-3.3.0.Final.jar | | |____jcl-over-slf4j-1.7.21.jar | | |____json-20140107.jar | | |____json-path-2.2.0.jar | | |____json-smart-2.2.1.jar | | |____jsonassert-1.3.0.jar | | |____jul-to-slf4j-1.7.21.jar | | |____liquibase-core-3.5.1.jar | | |____log4j-over-slf4j-1.7.21.jar | | |____logback-classic-1.1.7.jar | | |____logback-core-1.1.7.jar | | |____mockito-core-1.10.19.jar | | |____objenesis-2.1.jar | | |____slf4j-api-1.7.21.jar | | |____snakeyaml-1.17.jar | | |____spring-aop-4.3.3.RELEASE.jar | | |____spring-aspects-4.3.3.RELEASE.jar | | |____spring-beans-4.3.3.RELEASE.jar | | |____spring-boot-1.4.1.RELEASE.jar | | |____spring-boot-autoconfigure-1.4.1.RELEASE.jar | | |____spring-boot-configuration-processor-1.4.1.RELEASE.jar | | |____spring-boot-devtools-1.4.1.RELEASE.jar | | |____spring-boot-starter-1.4.1.RELEASE.jar | | |____spring-boot-starter-aop-1.4.1.RELEASE.jar | | |____spring-boot-starter-data-jpa-1.4.1.RELEASE.jar | | |____spring-boot-starter-jdbc-1.4.1.RELEASE.jar | | |____spring-boot-starter-logging-1.4.1.RELEASE.jar | | |____spring-boot-starter-test-1.4.1.RELEASE.jar | | |____spring-boot-starter-tomcat-1.4.1.RELEASE.jar | | |____spring-boot-starter-web-1.4.1.RELEASE.jar | | |____spring-boot-test-1.4.1.RELEASE.jar | | |____spring-boot-test-autoconfigure-1.4.1.RELEASE.jar | | |____spring-context-4.3.3.RELEASE.jar | | |____spring-core-4.3.3.RELEASE.jar | | |____spring-data-commons-1.12.3.RELEASE.jar | | |____spring-data-jpa-1.10.3.RELEASE.jar | | |____spring-expression-4.3.3.RELEASE.jar | | |____spring-jdbc-4.3.3.RELEASE.jar | | |____spring-orm-4.3.3.RELEASE.jar | | |____spring-tx-4.3.3.RELEASE.jar | | |____spring-web-4.3.3.RELEASE.jar | | |____spring-webmvc-4.3.3.RELEASE.jar | | |____tomcat-embed-core-8.5.5.jar | | |____tomcat-embed-el-8.5.5.jar | | |____tomcat-embed-websocket-8.5.5.jar | | |____tomcat-jdbc-8.5.5.jar | | |____tomcat-juli-8.5.5.jar | | |____validation-api-1.1.0.Final.jar | | |____xml-apis-1.4.01.jar |____META-INF | |____MANIFEST.MF | |____maven | | |____nl.mad | | | |____executable-jar-with-liquibase | | | | |____pom.properties | | | | |____pom.xml |____org | |____springframework | | |____boot | | | |____loader | | | | |____archive | | | | | |____Archive$Entry.class | | | | | |____Archive$EntryFilter.class | | | | | |____Archive.class | | | | | |____ExplodedArchive$1.class | | | | | |____ExplodedArchive$FileEntry.class | | | | | |____ExplodedArchive$FileEntryIterator$EntryComparator.class | | | | | |____ExplodedArchive$FileEntryIterator.class | | | | | |____ExplodedArchive.class | | | | | |____JarFileArchive$EntryIterator.class | | | | | |____JarFileArchive$JarFileEntry.class | | | | | |____JarFileArchive.class | | | | |____data | | | | | |____ByteArrayRandomAccessData.class | | | | | |____RandomAccessData$ResourceAccess.class | | | | | |____RandomAccessData.class | | | | | |____RandomAccessDataFile$DataInputStream.class | | | | | |____RandomAccessDataFile$FilePool.class | | | | | |____RandomAccessDataFile.class | | | | |____ExecutableArchiveLauncher$1.class | | | | |____ExecutableArchiveLauncher.class | | | | |____jar | | | | | |____AsciiBytes.class | | | | | |____Bytes.class | | | | | |____CentralDirectoryEndRecord.class | | | | | |____CentralDirectoryFileHeader.class | | | | | |____CentralDirectoryParser.class | | | | | |____CentralDirectoryVisitor.class | | | | | |____FileHeader.class | | | | | |____Handler.class | | | | | |____JarEntry.class | | | | | |____JarEntryFilter.class | | | | | |____JarFile$1.class | | | | | |____JarFile$2.class | | | | | |____JarFile$3.class | | | | | |____JarFile$JarFileType.class | | | | | |____JarFile.class | | | | | |____JarFileEntries$1.class | | | | | |____JarFileEntries$EntryIterator.class | | | | | |____JarFileEntries.class | | | | | |____JarURLConnection$1.class | | | | | |____JarURLConnection$JarEntryName.class | | | | | |____JarURLConnection.class | | | | | |____ZipInflaterInputStream.class | | | | |____JarLauncher.class | | | | |____LaunchedURLClassLoader$1.class | | | | |____LaunchedURLClassLoader.class | | | | |____Launcher.class | | | | |____MainMethodRunner.class | | | | |____PropertiesLauncher$1.class | | | | |____PropertiesLauncher$ArchiveEntryFilter.class | | | | |____PropertiesLauncher$FilteredArchive$1.class | | | | |____PropertiesLauncher$FilteredArchive.class | | | | |____PropertiesLauncher$PrefixMatchingArchiveFilter.class | | | | |____PropertiesLauncher.class | | | | |____util | | | | | |____SystemPropertyUtils.class | | | | |____WarLauncher.class The entire project can be found here: https://github.com/robert-bor/executable-jar-with-liquibase What am I doing wrong here?
there used to be a problem with the includeAll tag in liquibase, see this issue. It should be fix meanwhile, but at the moment I could not make it run with the includeAll tag. As a solution for your problem use: <include file="classpath:db/changelogs/changelog_000.xml" relativeToChangelogFile="false"/>
Jersey 2.6 REST Service upgraded to Java 8 tomcat 8 exception:java.lang.NoSuchMethodError: javax.validation.Configuration.getBootstrapConfiguration
We have a war that expose rest service over jersey 2.6 with validation based on hibernate-4.2.7 validation (implements validation-api-1.0.0.GA). Everything worked fine before we upgraded to java 8 and tc-server 3.1.X. After upgrading to java 8 it looks like something was broken in the validation api. We get java.lang.NoSuchMethodError: javax.validation.Configuration.getBootstrapConfiguration()Ljavax/validation/BootstrapConfiguration; When we sent a rest request form the client. The weirdest thing is that this behavior is not consist When I add or remove jars from the dependencies it sometimes work and sometimes not. And we get the following exception SEVERE [tomcat-http--1] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [jerseyServlet] in context with path [/Analyzer] threw exception [A MultiException has 1 exceptions. They are: 1. java.lang.NoSuchMethodError: javax.validation.Configuration.getBootstrapConfiguration()Ljavax/validation/BootstrapConfiguration; ] with root cause java.lang.NoSuchMethodError: javax.validation.Configuration.getBootstrapConfiguration()Ljavax/validation/BootstrapConfiguration; at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.getTraversableResolver(ValidationBinder.java:287) at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.getDefaultValidatorContext(ValidationBinder.java:268) at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.getDefaultValidator(ValidationBinder.java:248) at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.provide(ValidationBinder.java:199) at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.provide(ValidationBinder.java:173) at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:96) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:621) at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:107) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:135) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:136) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104) at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:406) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:350) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:106) at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:259) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:267) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:319) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028) at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:219) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at SourceResolverFilter.doFilter(SourceResolverFilter.java:71) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:277) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Looking at the stack trace you can see that jersey is calling Configuration.getBootstrapConfiguration which is provided in validation-api-1.1.0.Final but not in validation-api-1.0.0.GA. Our dependencies tree (excluding product specific jars) looks like --- maven-dependency-plugin:2.10:tree (default-cli) --- excluded war-SNAPSHOT +- excluded jar | +- excluded jar | | \- org.hibernate:hibernate-validator:jar:4.2.0.Final:compile | +- org.springframework:spring-context:jar:4.0.2.RELEASE:compile | | +- org.springframework:spring-aop:jar:4.0.2.RELEASE:compile | | | \- aopalliance:aopalliance:jar:1.0:compile | | +- org.springframework:spring-beans:jar:4.0.2.RELEASE:compile | | +- org.springframework:spring-core:jar:4.0.2.RELEASE:compile | | \- org.springframework:spring-expression:jar:4.0.2.RELEASE:compile | +- org.glassfish.jersey.core:jersey-server:jar:2.6:compile | | +- org.glassfish.jersey.core:jersey-common:jar:2.6:compile | | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.6:compile | | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile | | +- org.glassfish.jersey.core:jersey-client:jar:2.6:compile | | +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile | | +- javax.annotation:javax.annotation-api:jar:1.2:compile | | +- org.glassfish.hk2:hk2-api:jar:2.2.0:compile | | | +- org.glassfish.hk2:hk2-utils:jar:2.2.0:compile | | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.2.0:compile | | +- org.glassfish.hk2.external:javax.inject:jar:2.2.0:compile | | +- org.glassfish.hk2:hk2-locator:jar:2.2.0:compile | | \- javax.validation:validation-api:jar:1.0.0.GA:compile | +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.6:compile | | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile | | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.13:compile | | \- org.codehaus.jackson:jackson-xc:jar:1.9.13:compile | +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.6:compile | | \- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.6:compile | +- org.glassfish.jersey.ext:jersey-spring3:jar:2.6:compile | | +- org.glassfish.hk2:hk2:jar:2.2.0:compile | | | +- org.glassfish.hk2:config-types:jar:2.2.0:compile | | | +- org.glassfish.hk2:core:jar:2.2.0:compile | | | +- org.glassfish.hk2:hk2-config:jar:2.2.0:compile | | | | \- org.jvnet:tiger-types:jar:1.4:compile | | | +- org.glassfish.hk2:hk2-runlevel:jar:2.2.0:compile | | | \- org.glassfish.hk2:class-model:jar:2.2.0:compile | | +- org.glassfish.hk2:spring-bridge:jar:2.2.0:compile | | \- org.springframework:spring-web:jar:4.0.2.RELEASE:compile | \- org.glassfish.jersey.ext:jersey-bean-validation:jar:2.6:compile +- log4j:log4j:jar:1.2.17:compile +- commons-logging:commons-logging:jar:1.1.1:compile +- org.jasypt:jasypt-spring31:jar:1.9.0:compile | \- org.jasypt:jasypt:jar:1.9.0:compile +- excluded jar | +- excluded jar | | +- commons-configuration:commons-configuration:jar:1.5:compile | | | +- commons-collections:commons-collections:jar:3.2.1:compile | | | +- commons-lang:commons-lang:jar:2.4:compile | | | +- commons-digester:commons-digester:jar:1.8:compile | | | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile | | | \- commons-beanutils:commons-beanutils-core:jar:1.7.0:compile | | +- commons-codec:commons-codec:jar:1.6:compile | | \- org.apache.commons:commons-lang3:jar:3.3.2:compile | +- excluded jar | +- excluded jar | | \- net.sf.ehcache:ehcache-core:jar:2.4.7:compile | +- org.hibernate:hibernate-core:jar:4.2.7.Final:compile | | +- antlr:antlr:jar:2.7.7:compile | | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile | | +- dom4j:dom4j:jar:1.6.1:compile | | +- org.javassist:javassist:jar:3.18.0-GA:compile | | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:compile | | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile | | \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.2.Final:compile | +- org.springframework:spring-orm:jar:4.0.2.RELEASE:compile | | +- org.springframework:spring-jdbc:jar:4.0.2.RELEASE:compile | | \- org.springframework:spring-tx:jar:4.0.2.RELEASE:compile | +- javax.servlet:servlet-api:jar:3.0:provided | +- excluded jar | | \- excluded jar | +- excluded jar | \- com.zaxxer:HikariCP-java6:jar:2.3.7:compile | \- org.slf4j:slf4j-api:jar:1.7.6:compile +- excluded jar-SNAPSHOT:compile | \- excluded jar +- excluded jar-SNAPSHOT:compile | \- excluded jar +- excluded jar-SNAPSHOT:compile | \- excluded jar | +- excluded jar | | +- org.springframework.security:spring-security-core:jar:3.2.5.RELEASE:compile | | \- excluded jar | | +- excluded jar | | \- excluded jar | | \- excluded jar | | \- com.springsource.insight:insight-annotation:jar:1.8.3.RELEASE:compile | +- com.thoughtworks.xstream:xstream:jar:1.4.8:compile | | +- xmlpull:xmlpull:jar:1.1.3.1:compile | | \- xpp3:xpp3_min:jar:1.1.4c:compile | +- com.thoughtworks.xstream:xstream-hibernate:jar:1.4.8:compile | +- org.objectweb.asm.util:asm-util:jar:4.0:compile | +- net.sf.cglib:cglib:jar:3.0:compile | +- com.esotericsoftware.kryo:kryo:jar:2.19:compile | | +- com.esotericsoftware.reflectasm:reflectasm:jar:shaded:1.07:compile | | | \- org.ow2.asm:asm:jar:4.0:compile | | \- com.esotericsoftware.minlog:minlog:jar:1.2:compile | +- org.springframework.integration:spring-integration-core:jar:4.1.0.RELEASE:compile | | +- org.projectreactor:reactor-core:jar:1.1.4.RELEASE:compile | | | +- com.goldmansachs:gs-collections:jar:5.1.0:compile | | | | \- com.goldmansachs:gs-collections-api:jar:5.1.0:compile | | | +- com.lmax:disruptor:jar:3.2.1:compile | | | \- io.gatling:jsr166e:jar:1.0:compile | | +- org.springframework:spring-messaging:jar:4.1.2.RELEASE:compile | | \- org.springframework.retry:spring-retry:jar:1.1.1.RELEASE:compile | +- org.springframework.amqp:spring-rabbit:jar:1.4.5.RELEASE:compile | +- org.springframework.amqp:spring-amqp:jar:1.4.5.RELEASE:compile | +- org.springframework.security:spring-security-remoting:jar:3.2.5.RELEASE:compile | +- com.rabbitmq:amqp-client:jar:3.5.3:compile | \- org.springframework.integration:spring-integration-amqp:jar:4.1.0.RELEASE:compile +- junit:junit:jar:4.11:test | \- org.hamcrest:hamcrest-core:jar:1.3:test +- org.mockito:mockito-core:jar:1.9.5:test | \- org.objenesis:objenesis:jar:1.2:compile \- excluded jar +- excluded jar \- org.springframework:spring-context-support:jar:4.0.2.RELEASE:compile Any idea why sometimes jersey via hk2 insist on calling validation-api-1.1.0-Final method and sometime 1.0.0.GA as expected. I know that validation is Auto-discovered in jersey is there a way to force it to use validation-api-1.0.0.GA implementation? P.S. - I noticed that bean-validation-2.2.0 has a copy of the javax.validation.* packages from validation-api-1.1.0.Final (why???) but as you see from the dependency tree We specifically excluded it. UPDATE: Digging deeper into the code it looks like jersey-bean-validation:2.6 is actually compiled against validation-api-1.1.0.Final and statically calling the getBootstrapConfiguration() method. Actually in the mvnrepository.com dependency it goes back to jersey-bean-validation:2.0 version deepening on validation-api-1.1.0.Final Looking at the org.glassfish.jersey.server.validation.internal.ValidationBinder class You can see that private ConfiguredValidator getDefaultValidator() method calls getBootstrapConfiguration(); upon calling the private method getTraversableResolver(). So it looks like the only options that somehow in the provide method I have a ContextResolver that cause the code to branch on a different path a voiding the call to getBootstrapConfiguration public ConfiguredValidator provide() { ContextResolver contextResolver = this.providers.getContextResolver(ValidationConfig.class, MediaType.WILDCARD_TYPE); if(contextResolver == null) { return this.getDefaultValidator(); } else { //not calling the getBootstrapConfiguration() method } I debugged two cases one that works and one that does not. When the service works I noticed that ValidationBinder is injecting org.hibernate.validator.internal.engine.ConfigurationImpl.class to configuration field This implementation comes from the bean-validation-2.2.0 jar and implements the getBootstrapConfiguration() method When the service does not works I ValidationBinder is injecting org.hibernate.validator.engine.ConfigurationImpl to configuration field Which comes from the hibernate-validation-4.2.0 jar. I tried to force the setting by binding the Configuration to org.hibernate.validator.internal.engine.ConfigurationImpl.class e.g. public class JerseyConfig extends ResourceConfig { public JerseyConfig() { register(new AbstractBinder() { #Override protected void configure() { bind(org.hibernate.validator.internal.engine.ConfigurationImpl.class).to(Configuration.class); } }); } but this did not resolved my issue.
Following my investigations and the fact that I did not get any answer here (although I suggested a bounty) and not in the jersey forum. One can assume that I was merely lucky that this functionally worked in java 7 (all the time) and in java 8 (part time) probably to some bugs/magical classpath order. What worked for me was to upgrade to hibernate-validator 5.0.0 and validator-api-1.1.0.Final.
according to this thread, jersey 2.6 seems to be the last version of jersey that supported java 6. updating the jersey version should work too. i updated my jersey version to 2.26, (the latest version at the time) and added the following dependencies to maven...then everything was good... <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>org.glassfish.jersey.inject</groupId> <artifactId>jersey-hk2</artifactId> <version>2.27</version> </dependency>