Hot questions for Using Ubuntu in spring

Question:

I have a Java backend which uses Spring Boot Actuator but it won't start on Digitalocean Ubuntu VPS. The same application runs well on my Mac and on an other Ubuntu PC.

szabolcs@SmartUpProd:~/smartup$ java -Xmx1536m -jar build/libs/smartup-backend-0.1.0.jar 

It starts the initialisation but it stops at the same point every time (no exception, just hangs). If I try to stop it at this point with ^C it won't bring the shell back.

This is the outoput:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.1.5.RELEASE)

2014-09-04 04:19:27.697  INFO 1724 --- [           main] com.smartup.SmartUpConfiguration         : Starting SmartUpConfiguration on SmartUpProd with PID 1724 (/home/szabolcs/smartup/build/libs/smartup-backend-0.1.0.jar started by szabolcs in /home/szabolcs/smartup)
2014-09-04 04:19:27.783  INFO 1724 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@464e53bb: startup date [Thu Sep 04 04:19:27 EDT 2014]; root of context hierarchy
2014-09-04 04:19:28.911  INFO 1724 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2014-09-04 04:19:30.225  INFO 1724 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'smartUpConfiguration' of type [class com.smartup.SmartUpConfiguration$$EnhancerBySpringCGLIB$$ec37524d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-04 04:19:30.254  INFO 1724 --- [           main] o.s.j.d.DriverManagerDataSource          : Loaded JDBC driver: com.mysql.jdbc.Driver
2014-09-04 04:19:30.266  INFO 1724 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'dataSource' of type [class org.springframework.jdbc.datasource.DriverManagerDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-04 04:19:30.293  INFO 1724 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2014-09-04 04:19:30.440  INFO 1724 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2014-09-04 04:19:30.452  INFO 1724 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {4.0.1.Final}
2014-09-04 04:19:30.457  INFO 1724 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2014-09-04 04:19:30.459  INFO 1724 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2014-09-04 04:19:30.486  INFO 1724 --- [           main] org.hibernate.ejb.Ejb3Configuration      : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2014-09-04 04:19:30.826  INFO 1724 --- [           main] o.h.s.j.c.i.ConnectionProviderInitiator  : HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
2014-09-04 04:19:31.175  INFO 1724 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2014-09-04 04:19:31.188  INFO 1724 --- [           main] o.h.e.jdbc.internal.LobCreatorBuilder    : HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
2014-09-04 04:19:31.208  INFO 1724 --- [           main] o.h.e.t.i.TransactionFactoryInitiator    : HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
2014-09-04 04:19:31.218  INFO 1724 --- [           main] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory
2014-09-04 04:19:31.657  INFO 1724 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000228: Running hbm2ddl schema update

[...]
2014-09-04 04:19:31.768  INFO 1724 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000232: Schema update complete
2014-09-04 04:19:31.947  INFO 1724 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'entityManagerFactory' of type [class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-04 04:19:32.092  INFO 1724 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$7460673f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-04 04:19:32.119  INFO 1724 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-04 04:19:32.148  INFO 1724 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-04 04:19:32.167  INFO 1724 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-04 04:19:32.574  INFO 1724 --- [           main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080
2014-09-04 04:19:32.803  INFO 1724 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2014-09-04 04:19:32.805  INFO 1724 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/7.0.54
2014-09-04 04:19:32.956  INFO 1724 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2014-09-04 04:19:32.957  INFO 1724 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 5178 ms
2014-09-04 04:19:35.202  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/css/**'], []
2014-09-04 04:19:35.203  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/js/**'], []
2014-09-04 04:19:35.203  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/images/**'], []
2014-09-04 04:19:35.203  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/**/favicon.ico'], []
2014-09-04 04:19:35.203  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/info'], []
2014-09-04 04:19:35.203  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/health'], []
2014-09-04 04:19:35.203  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/error'], []
2014-09-04 04:19:35.252  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5c4b8904, org.springframework.security.web.context.SecurityContextPersistenceFilter@36b59af2, org.springframework.security.web.header.HeaderWriterFilter@71880af1, org.springframework.security.web.authentication.logout.LogoutFilter@1cd26cc7, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@10e5d335, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6c2a1c3a, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5c58c840, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@166e5d45, org.springframework.security.web.session.SessionManagementFilter@49040d09, org.springframework.security.web.access.ExceptionTranslationFilter@2d18c028, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@5dc9dca8]
2014-09-04 04:19:35.257  INFO 1724 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/dump'], Ant [pattern='/dump/'], Ant [pattern='/dump.*'], Ant [pattern='/env'], Ant [pattern='/env/'], Ant [pattern='/env.*'], Ant [pattern='/configprops'], Ant [pattern='/configprops/'], Ant [pattern='/configprops.*'], Ant [pattern='/autoconfig'], Ant [pattern='/autoconfig/'], Ant [pattern='/autoconfig.*'], Ant [pattern='/mappings'], Ant [pattern='/mappings/'], Ant [pattern='/mappings.*'], Ant [pattern='/trace'], Ant [pattern='/trace/'], Ant [pattern='/trace.*'], Ant [pattern='/metrics'], Ant [pattern='/metrics/'], Ant [pattern='/metrics.*'], Ant [pattern='/beans'], Ant [pattern='/beans/'], Ant [pattern='/beans.*']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@73762e60, org.springframework.security.web.context.SecurityContextPersistenceFilter@3d8b310e, org.springframework.security.web.header.HeaderWriterFilter@5ef9f4c9, org.springframework.security.web.authentication.logout.LogoutFilter@2fa7040e, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@3ae20f72, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1bd98f6, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@10736bb4, org.springframework.security.web.session.SessionManagementFilter@4bde96b2, org.springframework.security.web.access.ExceptionTranslationFilter@56ed5cfd, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@2df2e9b6]
2014-09-04 04:19:35.391  INFO 1724 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2014-09-04 04:19:35.395  INFO 1724 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'metricFilter' to: [/*]
2014-09-04 04:19:35.396  INFO 1724 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'springSecurityFilterChain' to: [/*]
2014-09-04 04:19:35.396  INFO 1724 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-09-04 04:19:35.396  INFO 1724 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'applicationContextIdFilter' to: [/*]
2014-09-04 04:19:35.396  INFO 1724 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'webRequestLoggingFilter' to: [/*]

And this is the output after the ^C:

^C2014-09-04 04:34:46.560  INFO 1724 --- [       Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@464e53bb: startup date [Thu Sep 04 04:19:27 EDT 2014]; root of context hierarchy
2014-09-04 04:34:46.573  WARN 1724 --- [       Thread-2] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@464e53bb: startup date [Thu Sep 04 04:19:27 EDT 2014]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:359)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:888)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:152)
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:809)

2014-09-04 04:34:46.601  INFO 1724 --- [       Thread-2] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

Has someone faced the same problem? Can you guys please help me?

Here you have the thread dump (when it's hanging):

szabolcs@SmartUpProd:~$ jstack 2616
2014-09-04 07:33:30
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.20-b23 mixed mode):

"Attach Listener" #14 daemon prio=9 os_prio=0 tid=0x00007fb678001000 nid=0xaae waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"localhost-startStop-1" #13 daemon prio=5 os_prio=0 tid=0x00007fb65000d000 nid=0xa46 runnable [0x00007fb662fec000]
   java.lang.Thread.State: RUNNABLE
    at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(FileInputStream.java:246)
    at sun.security.provider.SeedGenerator$URLSeedGenerator.getSeedBytes(SeedGenerator.java:539)
    at sun.security.provider.SeedGenerator.generateSeed(SeedGenerator.java:144)
    at sun.security.provider.SecureRandom$SeederHolder.<clinit>(SecureRandom.java:192)
    at sun.security.provider.SecureRandom.engineNextBytes(SecureRandom.java:210)
    - locked <0x00000000f15173a0> (a sun.security.provider.SecureRandom)
    at java.security.SecureRandom.nextBytes(SecureRandom.java:457)
    - locked <0x00000000f15176c0> (a java.security.SecureRandom)
    at java.security.SecureRandom.next(SecureRandom.java:480)
    at java.util.Random.nextInt(Random.java:329)
    at org.apache.catalina.util.SessionIdGenerator.createSecureRandom(SessionIdGenerator.java:246)
    at org.apache.catalina.util.SessionIdGenerator.getRandomBytes(SessionIdGenerator.java:183)
    at org.apache.catalina.util.SessionIdGenerator.generateSessionId(SessionIdGenerator.java:153)
    at org.apache.catalina.session.ManagerBase.startInternal(ManagerBase.java:573)
    at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:485)
    - locked <0x00000000f1395fc0> (a org.apache.catalina.session.StandardManager)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    - locked <0x00000000f1395fc0> (a org.apache.catalina.session.StandardManager)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5476)
    - locked <0x00000000f675e1a8> (a org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    - locked <0x00000000f675e1a8> (a org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.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)

"Tomcat-startStop-1" #12 daemon prio=5 os_prio=0 tid=0x00007fb65f35b000 nid=0xa45 waiting on condition [0x00007fb6801d8000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000f675e178> (a java.util.concurrent.FutureTask)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:429)
    at java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    - locked <0x00000000f6705460> (a org.apache.catalina.core.StandardHost)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799)
    - locked <0x00000000f6705460> (a org.apache.catalina.core.StandardHost)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    - locked <0x00000000f6705460> (a org.apache.catalina.core.StandardHost)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.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)

"DestroyJavaVM" #10 prio=5 os_prio=0 tid=0x00007fb6a0009800 nid=0xa39 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"main" #9 prio=5 os_prio=0 tid=0x00007fb6a01cf800 nid=0xa44 waiting on condition [0x00007fb6808ef000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000f6705430> (a java.util.concurrent.FutureTask)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:429)
    at java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    - locked <0x00000000f675c598> (a org.apache.catalina.core.StandardEngine)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
    - locked <0x00000000f675c598> (a org.apache.catalina.core.StandardEngine)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    - locked <0x00000000f675c598> (a org.apache.catalina.core.StandardEngine)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
    - locked <0x00000000f675c598> (a org.apache.catalina.core.StandardEngine)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    - locked <0x00000000f675bc98> (a org.apache.catalina.core.StandardService)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)
    - locked <0x00000000f675c340> (a [Lorg.apache.catalina.Service;)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    - locked <0x00000000f675bd68> (a org.apache.catalina.core.StandardServer)
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:85)
    - locked <0x00000000f6bbad18> (a org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:74)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:289)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:146)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
    - locked <0x00000000a0d8f098> (a org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
    - locked <0x00000000a0d8f2c8> (a java.lang.Object)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
    at com.smartup.SmartUpConfiguration.main(SmartUpConfiguration.java:78)
    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:483)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
    at java.lang.Thread.run(Thread.java:745)

"Service Thread" #7 daemon prio=9 os_prio=0 tid=0x00007fb6a0152000 nid=0xa42 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007fb6a0132800 nid=0xa41 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007fb6a012f800 nid=0xa40 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007fb6a012d800 nid=0xa3f runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007fb6a00ff000 nid=0xa3e in Object.wait() [0x00007fb69041e000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000a0487660> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)
    - locked <0x00000000a0487660> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:158)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007fb6a00fd000 nid=0xa3d in Object.wait() [0x00007fb69051f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000a04876a0> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:157)
    - locked <0x00000000a04876a0> (a java.lang.ref.Reference$Lock)

"VM Thread" os_prio=0 tid=0x00007fb6a00f6000 nid=0xa3c runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007fb6a001f000 nid=0xa3a runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007fb6a0020800 nid=0xa3b runnable 

"VM Periodic Task Thread" os_prio=0 tid=0x00007fb6a0154000 nid=0xa43 waiting on condition 

JNI global references: 48

Answer:

localhost-startStop-1 is trying to create a new instance of SecureRandom and it's stuck trying to read data from an entropy source. This typically occurs because the source has been depleted. The default entropy source is /dev/random. It's known as a blocking source as it will block when an attempt is made to read random data and none is available. Another source on Linux is /dev/urandom. Its main benefit over /dev/random is that it's non-blocking. There's some debate over whether or not using /dev/urandom will make things less secure. This article may be of interest.

In summary, using /dev/urandom will avoid the problem you're seeing, at the possible cost of decreased security. You can configure Spring Boot's embedded Tomcat instance to use /dev/urandom via a system property:

-Djava.security.egd=file:/dev/./urandom

Question:

I'm having some trouble receiving large subprotocol messages using Spring Boot, Spring WebSocket and Undertow. The messages are cut off after 16kB. After doing some digging I found the following configuration property which seems to do what I want:

server.undertow.buffer-size=32768

This configuration property seems to be properly picked up when checking the /configprops actuator endpoint. Unfortunately, this doesn't seem to help in receiving messages larger than 16kB.

I also stumbled upon this ominous line from the Undertow documentation (emphasis mine):

For servers the ideal size is generally 16k, as this is usually the maximum amount of data that can be written out via a write() operation (depending on the network setting of the operating system).

This confirms what I've been experiencing that setting the server.undertow.buffer-size has no effect as it's capped by an OS level setting. As I'm using Ubuntu Linux I have been fiddling around with net.core.rmem_* and net.core.wmem_* settings but these don't seem to have any effect either. It's not possible to reproduce this issue on macOS.

Does anyone know how to configure Undertow, Spring Boot, and/or Spring WebSocket to support these messages?


Answer:

I directly answered the question above myself. The settings I proposed in Spring Boot do work! The problem we had was that the load balancer, in our case haproxy, in front of it was cutting of the messages after 16kB. Tuning haproxy to allow larger messages solved the issue. In the meanwhile, we tweaked the protocol we were using to be more efficient so we don't require these large messages anymore so our haproxy solution wasn't tested in production (YMMV).

Because the developers were all working on macOS and Windows and the issue only occurred on the acceptance and production environments which ran Ubuntu we incorrectly assumed this was the cause.

Lessons learned (these are all really dumb and basic but we made these mistakes anyway):

  • Be sure to validate all your assumptions! If we thought Ubuntu was the issue we should've singled out Ubuntu in tests earlier. For example, by using a VM with Ubuntu on which to validate our assumptions in quarantaine.
  • Make sure your development environment matches your production environment! In our development environments we weren't running haproxy. As "high level" developers we tend to put aside load balancers and web servers as commodity infrastructure but this example once again shows that these "commodities" can very directly impact the working of your application.

Question:

We are working on spring boot application. In our application we have to share folder from remote machine from any OS. We are sharing folders to get the list of objects exist in shared folder. We are using SMB and NTLMAuthentication for it.

For authentication :

  NtlmPasswordAuthentication credential = new NtlmPasswordAuthentication(
                    informationStoreDefinition.getProperties().get(DOMAIN),
                    informationStoreDefinition.getProperties().get(USER),
                    informationStoreDefinition.getProperties().get(PASSWORD)
            );

Later we are trying to get list of shared folder using the code :

 SmbFile file = ((CifsContainerObject) simpleObject).smbFile;
 SmbFile[] list = file.listFiles();

We have tried these combinations to access/share the folder :

  • Windows OS to Ubuntu - WORKING!!
  • Windows OS to Windows OS - WORKING!!
  • Ubuntu to Windows - FAILED
  • Ubuntu to Ubuntu - FAILED

We are getting this error for above two case : jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.

Code throw error at line : SmbFile[] list = file.listFiles();. Our user name, password and domain all are correct. We have accessed folder of Linux on Windows our network, we are successfully able to access the share folder as well as we are getting response on our Windows machine for Linux shared folder. Then why this error thrown?


Answer:

For sharing folder I am using the steps are -

  • Right click on folder which you want to share

  • Click on the properties

  • Go to Local Network Share tab

  • Check other boxes

Then follow these link - https://askubuntu.com/questions/19361/cant-access-ubuntus-shared-folders-from-windows-7

http://ubuntuhandbook.org/index.php/2014/05/ubuntu1404-file-sharing-samba/

Question:

Full error is in this image as I am running on virtual machine in cloud which is access via video feed so I cannot copy and paste.This is a fresh install of ubuntu where I have only installed JDK and nothing else so unaware if other setup needs to be done https://imgur.com/a/egJ3d

It is a spring boot application. My build.gradle

group 'com.haughon.daniel'
version '1.0-SNAPSHOT'



buildscript {
repositories{
    mavenCentral()
}
dependencies {
    classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE'
}
}

// Apply the Spring Boot plugin
apply plugin: 'spring-boot'

 // Apply the Java plugin (expects src/main/java to be source folder)
 apply plugin: 'java'
apply plugin: 'idea'

 // Specify the location where our dependencies will be found
repositories {
mavenCentral()
}
jar {
   manifest {
    attributes 'Main-Class': 'haughton.dvdstore.Application'
    attributes 'addClasspath': 'true'

}
}

 // Specify dependencies
  dependencies {

compile 'org.hashids:hashids:1.0.1'
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile 'org.springframework:spring-orm:4.3.7.RELEASE'
compile 'org.hibernate:hibernate-core:5.2.9.Final'
compile 'org.hibernate:hibernate-entitymanager:5.0.6.Final'
compile 'org.apache.tomcat:tomcat-dbcp:8.0.30'
compile 'org.springframework.boot:spring-boot-starter-security'
compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4')
//compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity:3.0.2.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.11.1.RELEASE'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'

runtime 'com.h2database:h2'
runtime 'javax.transaction:jta:1.1'
runtime 'org.aspectj:aspectjweaver:1.8.7'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}  

Answer:

This is because your dependencies are not included in one jar file.

use ./gradlew clean build

please see this post:

java.lang.NoClassDefFoundError: when trying to run jar

Question:

I recently moved from windows 10 to Ubuntu 16.04, I'm a java developer, when I was on windows I installed Vs Code with the java Extension pack. On windows I never Had problem to make my daily work, but on ubuntu, every java file is marked as error, with the message "The import cannot be resolved", searching a litle bit, i found that you can execute the command java:clean the java language server workspace, but this does not fix the problem. I also remove the tmp files from the workspace located on:

~/.config/Code/User/workspaceStorage

  • the current Version of Vs code is 1.41.1

  • the current version of Java Extension Pack is 0.8.1

Any ideas?.

Regards!.

Edit: all my java files are marked as error

inside of every java file

this is the result of the maven-install


Answer:

well, after a while of searching, I found that the "maven for java" pligun was trying to download the maven plugin "maven-metadata.xml" wich wasn't available on my repo. this caused a conflict with the initial build that maven for java was doing. to avoid to update everytime I opened vs code. I removed the option "update snapshots" update snapshots

And the initial build was done.

Question:

I'm working on a Spring boot project and i tried to connect my server to a postgresql database. When i run the program with my IDE (on my windows OS) it's working but when i make a jar file and run it on my ubuntu server virtual machine which host my DB it doesn't work.

org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

I've check my firewall rules but still no sucess.

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

I make some research and I heard about the configuration files of postgresql to modify but it still doesn't work and i have no idea where the issue comes.

Below the lines that i've modified on postgresql.conf:

listen_addresses = '*'          # what IP address(es) to listen on;
ssl = on

and for the pg_hba.conf:

local   all             postgres                                peer
local   all             kapitax                                trust
# TYPE  DATABASE        USER            ADDRESS                 METHOD
#host   all             kapitax        *                       password
#host   all             all             0.0.0.0/0               md5
# "local" is for Unix domain socket connections only
local   all             all             *                       trust
# IPv4 local connections:
host    all             all             *                       password
# IPv6 local connections:
host    all             all             ::1/128                 password
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             *                       md5
host    replication     all             ::1/128                 md5

The issue can comes from the applcation.properties code ?

spring.datasource.url= jdbc:postgresql://localhost:5432/kapitax
spring.datasource.username=kapitax
spring.datasource.password=kapitax
spring.jpa.hibernate.ddl-auto=create-drop
server.port=8090

Answer:

The line

#host   all             all             0.0.0.0/0               md5

should be enabled like:

host   all             all             0.0.0.0/0               md5

With 0.0.0.0/0 you will listen for all IPv4 addresses. After you change this configuration make sure to reload your server settings or restart the database server. A more detailed explanation can be found in the following answer: How to configure PostgreSQL to accept all incoming connections

Question:

I am not able to run my maven based spring-boot project on ubuntu 17.04 even though it's running in windows nicely. So far it is throwing the same error as in the picture even if I try from my Eclipse photon IDE or the Maven CLI.

I tried changing the java versions of the PC and pretty sure it might not be the issue now since its java-8-oracle after a lot of testing with different versions. wget is not working for the terminal for URL http://repo.maven.apache.org/maven2 even though it's working in the browser. Almost trying from 2 Days now so desperately looking for some tricks to get this to work. Thanks in advance


Answer:

With all the trouble i went through finally figured out the issue and it was related to SSL since after working on with this answer issue with ca-certificates after doing those steps got it to work

sudo apt purge openjdk-9-jdk openjdk-8-jdk java-common

(Just purging and reinstalling the jdk was not enough, I still had a java command after that. Only by purging java-common that also went away and then reinstallation worked.)

Afterwards, I reinstalled java again (I opted only for openjdk-8):

sudo apt install openjdk-8-jdk

Question:

Following the instructions here, I made an executable jar from my spring boot project (1.5.8) in order to run it as a service (I would like to run it on port 443). If I just start it with java -jar proj.jar I get an error saying the port is in use, but using sudo java -jar proj.jar tomcat can start and the site works.

I tried to allow low level port access to the jar, but I still get the error. (sudo setcap CAP_NET_BIND_SERVICE=+eip /path/to/jar or setcap 'cap_net_bind_service=+ep' /path/to/jar)

How can I give the jar/tomcat low level port access, so it runs on 443 and I could launch it as a service?

As a non root user, I installed the jar this way:

  1. Cloned the repo
  2. chmod +x ./mvnw
  3. ./mvnw package -Dmaven.test.skip=true
  4. cd target and making application.protperties and copying keystore.jks
  5. sudo ln -s /home/user/projectname/target/proj-0.0.1-SNAPSHOT.jar /etc/init.d/projectname
  6. sudo chmod +x /etc/init.d/projectname
  7. sudo update-rc.d projectname defaults
  8. sudo service projectname start

Checking the logging file, I can see the error, but as I mentioned, If I start the jar using sudo it works.

The Tomcat connector configured to listen on port 443 failed to start. The port may already be in use or the connector may be misconfigured.


Answer:

I hope someone can give me a better answer, but I could start the jar If I added low level port access directly to Java (I had oracle installed).: sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/lib/jvm/java-8-oracle/jre/bin/java I guess you could try.: sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/lib/jvm/java-8-oracle/bin/java

Should work for OpenJDK too but with different executable locations, I check mine with.: echo $PATH