Is there a way to pass JVM arguments when starting Ignite client - java

I am able to start up my Ignite server on Java 17 by adding some JVM arguments the ignite.sh script but when I startup my Ignite client via Ignition.start or Ignition.startClient I am getting reflection exceptions.
Is there a way to:
Provide additional arguments that will be given when Ignition.start spins up a new jvm process?
If not, is there a way to create a Ignite Client via ignite.sh?
I know these issues could be fixed by using Java 11 but that is not an option.
Below is stack trace I get after calling Ignition.start
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-28 18:50:34.518 ERROR 53868 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'igniteThinCacheManager': Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar!/:2.6.3]
at com.niksun.myService.MyServiceApplication.main(MyServiceApplication.java:10) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: java.lang.ExceptionInInitializerError: null
at org.apache.ignite.internal.util.IgniteUtils.<clinit>(IgniteUtils.java:865) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient$ClientMarshallerContext.<init>(TcpIgniteClient.java:542) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.<init>(TcpIgniteClient.java:114) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.<init>(TcpIgniteClient.java:102) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.start(TcpIgniteClient.java:339) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.Ignition.startClient(Ignition.java:615) ~[ignite-core-2.12.0.jar!/:2.12.0]
at com.niksun.myService.cache.IgniteThinCacheManager.init(IgniteThinCacheManager.java:45) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.3.15.jar!/:5.3.15]
... 26 common frames omitted
Caused by: java.lang.RuntimeException: java.nio.DirectByteBuffer.address field is unavailable.
at org.apache.ignite.internal.util.GridUnsafe$2.run(GridUnsafe.java:1570) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.util.GridUnsafe$2.run(GridUnsafe.java:1557) ~[ignite-core-2.12.0.jar!/:2.12.0]
at java.base/java.security.AccessController.doPrivileged(Unknown Source) ~[na:na]
at org.apache.ignite.internal.util.GridUnsafe.bufferAddressOffset(GridUnsafe.java:1557) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.util.GridUnsafe.<clinit>(GridUnsafe.java:109) ~[ignite-core-2.12.0.jar!/:2.12.0]
... 40 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field long java.nio.Buffer.address accessible: module java.base does not "opens java.nio" to unnamed module #27abe2cd
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Field.setAccessible(Unknown Source) ~[na:na]
at org.apache.ignite.internal.util.GridUnsafe$2.run(GridUnsafe.java:1562) ~[ignite-core-2.12.0.jar!/:2.12.0]
... 44 common frames omitted
Edit, to anyone that finds this I was incorrectly passing in the JVM arguments when starting up my spring boot application. Once I fixed that the InaccessibleObjectException no longer occurred.
Below is the list of arguments I used:
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED
--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED

Ignite doesn't support Java 17 yet. I don't think passing in a few parameters will help.
In any case, Ignition.start() does not fire up a new JVM; it starts a node in the current JVM. So you need to pass your parameters to your SpringBoot application.

In the end the problem was that I was not properly passing in the jvm arguments. Once I fixed that the application works with Java 17 given the arguments above. I suppose these are no guarantees I wont hit some other snags.

Related

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OpensearchClient' defined in class path resource

I am using Java and spring boot. I have 2 files, an #configuration file and a #Service file.
Configuration file:
#Configuration
public class OpenSearchRestClientConfiguration {
#Value("${aws.opensearch.domain.endpoint}")
private String endpoint;
#Value("${aws.region}")
private String region;
#Value("${aws.serviceName}")
private String myServiceName;
#Bean //I get an error when I add #Bean, but when I remove #Bean, I get no errors.
public OpenSearchClient OpensearchClient(){
SdkHttpClient myHttpClient = ApacheHttpClient.builder().build();
AWS4Signer mySigner = new AWS4Signer();
mySigner.setServiceName(myServiceName);
mySigner.setRegionName(region);
return new OpenSearchClient(
new AwsSdk2Transport(myHttpClient, endpoint, Region.of(region), AwsSdk2TransportOptions.builder().build()));
}
}
Service file:
#Service
public class PostsSearchService {
private final OpenSearchRestClientConfiguration myOpenSearchClient;
public PostsSearchService(OpenSearchRestClientConfiguration openSearchClient){
this.myOpenSearchClient = openSearchClient;
}
}
I get an error when I add #Bean at the top of the OpensearchClient method in OpenSearchRestClientConfiguration class, but when I remove #Bean, I get no errors.
Here is the error I'm getting:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OpensearchClient' defined in class path resource [com/search_engine_microservice_group/search_engine_microservice/Configuration/OpenSearchRestClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.opensearch.client.opensearch.OpenSearchClient]: Factory method 'OpensearchClient' threw exception; nested exception is java.lang.NoClassDefFoundError: jakarta/json/spi/JsonProvider
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.23.jar:5.3.23]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.23.jar:5.3.23]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.5.jar:2.7.5]
at com.search_engine_microservice_group.search_engine_microservice.SearchEngineMicroserviceApplication.main(SearchEngineMicroserviceApplication.java:10) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.7.5.jar:2.7.5]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.opensearch.client.opensearch.OpenSearchClient]: Factory method 'OpensearchClient' threw exception; nested exception is java.lang.NoClassDefFoundError: jakarta/json/spi/JsonProvider
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.23.jar:5.3.23]
... 24 common frames omitted
Caused by: java.lang.NoClassDefFoundError: jakarta/json/spi/JsonProvider
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[na:na]
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[na:na]
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) ~[na:na]
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) ~[na:na]
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) ~[na:na]
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
at org.opensearch.client.json.jackson.JacksonJsonpMapper.<init>(JacksonJsonpMapper.java:61) ~[opensearch-java-2.1.0.jar:na]
at org.opensearch.client.json.jackson.JacksonJsonpMapper.<init>(JacksonJsonpMapper.java:57) ~[opensearch-java-2.1.0.jar:na]
at org.opensearch.client.json.jackson.JacksonJsonpMapper.<init>(JacksonJsonpMapper.java:68) ~[opensearch-java-2.1.0.jar:na]
at org.opensearch.client.transport.aws.AwsSdk2Transport.<init>(AwsSdk2Transport.java:156) ~[opensearch-java-2.1.0.jar:na]
at org.opensearch.client.transport.aws.AwsSdk2Transport.<init>(AwsSdk2Transport.java:99) ~[opensearch-java-2.1.0.jar:na]
at com.search_engine_microservice_group.search_engine_microservice.Configuration.OpenSearchRestClientConfiguration.OpensearchClient(OpenSearchRestClientConfiguration.java:38) ~[classes/:na]
at com.search_engine_microservice_group.search_engine_microservice.Configuration.OpenSearchRestClientConfiguration$$EnhancerBySpringCGLIB$$606bb8d1.CGLIB$OpensearchClient$0(<generated>) ~[classes/:na]
at com.search_engine_microservice_group.search_engine_microservice.Configuration.OpenSearchRestClientConfiguration$$EnhancerBySpringCGLIB$$606bb8d1$$FastClassBySpringCGLIB$$549e6b4b.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.23.jar:5.3.23]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.23.jar:5.3.23]
at com.search_engine_microservice_group.search_engine_microservice.Configuration.OpenSearchRestClientConfiguration$$EnhancerBySpringCGLIB$$606bb8d1.OpensearchClient(<generated>) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.23.jar:5.3.23]
... 25 common frames omitted
Caused by: java.lang.ClassNotFoundException: jakarta.json.spi.JsonProvider
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
... 50 common frames omitted
I get an error when I add #Bean at the top of the OpensearchClient *method *in **OpenSearchRestClientConfiguration **class, but when I remove the #Bean annotation, I get no errors.
What is the reason behind such error ?
When you add #Bean, it tells Spring to add bean by bean configuration, as you can see in the docbean-configuration.When you remove #Bean, the method OpensearchClient() will not be executed. And the reason you get the error ClassNotFoundException, is maybe that you forget to import package jakarta-json or the version of jakarta-json might be wrong.
//private final OpenSearchRestClientConfiguration myOpenSearchClient;
private final OpenSearchClient myOpenSearchClient;

Spring Boot - After upgrading from 2.2.5 to 2.5.7, application failed to start

I upgraded spring boot from 2.2.5 to 2.5.7 and I'am using MongoDB. Since compilation failed i removed spring-boot-starter-mongo and i added below dependencies which resolved my compilation issues
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.11.2</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>3.11.0</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>2.2.5.RELEASE</version>
With all above changes if i run application i am facing java.lang.ClassNotFoundException: org.springframework.data.mongodb.MongoDatabaseFactory
Also adding runtime log:
Need inputs to resolve this issue
2021-12-21 20:16:00.263 ERROR [ht-ui-api : ] 19004 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalArgumentException: Could not find class [org.springframework.data.mongodb.MongoDatabaseFactory]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:334) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.annotation.TypeMappedAnnotation.adapt(TypeMappedAnnotation.java:446) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.annotation.TypeMappedAnnotation.getValue(TypeMappedAnnotation.java:369) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.annotation.TypeMappedAnnotation.asMap(TypeMappedAnnotation.java:284) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.annotation.AbstractMergedAnnotation.asAnnotationAttributes(AbstractMergedAnnotation.java:193) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.type.AnnotatedTypeMetadata.getAnnotationAttributes(AnnotatedTypeMetadata.java:106) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.AnnotationConfigUtils.attributesFor(AnnotationConfigUtils.java:285) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.AnnotationBeanNameGenerator.determineBeanNameFromAnnotation(AnnotationBeanNameGenerator.java:102) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.AnnotationBeanNameGenerator.generateBeanName(AnnotationBeanNameGenerator.java:81) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.registerBeanDefinitionForImportedConfigurationClass(ConfigurationClassBeanDefinitionReader.java:169) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:150) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:343) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:765) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:445) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.7.jar:2.5.7]
at com.htds.api.HtUiApiApplication.main(HtUiApiApplication.java:15) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.5.7.jar:2.5.7]
Caused by: java.lang.ClassNotFoundException: org.springframework.data.mongodb.MongoDatabaseFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
at java.base/java.lang.Class.forName(Class.java:468) ~[na:na]
at org.springframework.boot.devtools.restart.classloader.RestartClassLoader.loadClass(RestartClassLoader.java:145) ~[spring-boot-devtools-2.5.7.jar:2.5.7]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
at java.base/java.lang.Class.forName(Class.java:468) ~[na:na]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:284) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:324) ~[spring-core-5.3.13.jar:5.3.13]
... 29 common frames omitted
Why you "upgrade spring boot to 2.5.7"? (why, today, not 2.6.1?;) But why do you leave spring-data-mongodb: 2.2.5.RELEASE ?
Please align
I.e.: Confirm spring-data-mongodb version with spring-boot version (or vice versa)! In case of 2.5.7, these would be:
org.mongodb:mongodb-driver-sync:4.2.3
org.springframework.data:spring-data-mongodb:3.2.7
...proof for both. #
For upgrading spring-data-mongodb (or not!) 2.x -> 3.x, (which is obviously required by upgrading to spring-boot:2.XXX), please refer to Reference Documentation#upgrading.2-3.
Hopefully also helpful: (latest) Spring Boot Release Notes (with quick links to previous releases, Ctrl+F, mongo... data;)

Spring Boot deploy with Tomcat

I want to deploy my first Java application - I have a place to deploy it. I made Spring Boot application with Tomcat. Using some web instruction I make a fat jar file (maven package). I have exceptions. I try to search for it, but any solutions isn't work for this.
What can I add - I do not setup Tomcat, simple base on maven package jar with Tomcat. Could someone tell me what I can do? I will be very grateful for your understanding and help. This is my first deploy.
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:895) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at pl.foodies.app.AppApplication.main(AppApplication.java:10) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[app-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) ~[app-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[app-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[app-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
... 22 common frames omitted
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
... 24 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1067) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
... 26 common frames omitted
Caused by: java.net.SocketException: Operation not permitted
at java.base/sun.nio.ch.Net.bind0(Native Method) ~[na:na]
at java.base/sun.nio.ch.Net.bind(Net.java:461) ~[na:na]
at java.base/sun.nio.ch.Net.bind(Net.java:453) ~[na:na]
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227) ~[na:na]
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80) ~[na:na]
at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:228) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:211) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1227) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:592) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1064) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
... 28 common frames omitted
Some items to check for here....
1 - Make sure you're including the Tomcat dependency in your POM.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
2 - Check to see if your application.properties has the correct port number.
server.port=XXXX
3 - If this is running on a linux environment, try running the application with the following in your VM:
-Dserver.port=8181
4 - Make sure your Application Class extends SpringBootServletInitializer:
#SpringBootApplication
public class App extend SpringBootServletInitializer
{
public static void main( String[] args )
{
SpringApplication.run(App.class, "hello");
}
}
It seems that you do not configure a valid port, it should > 1024.

java.io.IOException: invalid constant type: 19 at 5

I have a project. It uses spring boot 2, java 9 and maven. It can be build sucessfully using mvn clean package.
To run spring boot application I used the command
java -jar java-cloud-rest-api/target/java-cloud-rest-api-0.0.1-SNAPSHOT.jar
But it failed with error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; n
ested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1716) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:499) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) ~[spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:858) ~[spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at com.lapots.breed.platform.cloud.boot.app.JavaCloudSampleApplication.main(JavaCloudSampleApplication.java:10) [classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:208) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:163) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:51) ~[spring-orm-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:358) ~[spring-orm-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:384) ~[spring-orm-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1776) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1712) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
... 24 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/java.net.URLClassLoader.findClass(Unknown Source) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ~[na:na]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ~[na:na]
... 34 common frames omitted
I added additional argument to start command
java --add-modules java.xml.bind -jar java-cloud-rest-api/target/java-cloud-rest-api-0.0.1-SNAPSHOT.jar
But when I run it, I get this error
java.lang.ClassCastException: org.springframework.boot.context.event.ApplicationFailedEvent cannot be cast to org.springframework.boot.web.context.WebServerInitializedEvent
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:159) [spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) [spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.boot.context.event.EventPublishingRunListener.finished(EventPublishingRunListener.java:114) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplicationRunListeners.callFinishedListener(SpringApplicationRunListeners.java:79) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:803) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at com.lapots.breed.platform.cloud.boot.app.JavaCloudSampleApplication.main(JavaCloudSampleApplication.java:10) [classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2017-09-09 18:03:42.242 INFO 9200 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-09-09 18:03:42.242 ERROR 9200 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/H
ibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.boot.archive.spi.ArchiveException: Could not build ClassFile
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1716) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:499) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) ~[spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:858) ~[spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M3.jar!/:2.0.0.M3]
at com.lapots.breed.platform.cloud.boot.app.JavaCloudSampleApplication.main(JavaCloudSampleApplication.java:10) [classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [java-cloud-rest-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.hibernate.boot.archive.spi.ArchiveException: Could not build ClassFile
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassFile(ClassFileArchiveEntryHandler.java:64) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:47) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:146) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:47) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:75) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:228) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:163) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:51) ~[spring-orm-5.0.0.RC3.
jar!/:5.0.0.RC3]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:358) ~[spring-orm-5.0.0.RC3.jar!/:5
.0.0.RC3]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:384) ~[spring-orm-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-5.0.0.RC3.jar!/:5.0.0.RC3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1776) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.R
C3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1712) ~[spring-beans-5.0.0.RC3.jar!/:5.0.0.RC3]
... 24 common frames omitted
Caused by: java.io.IOException: invalid constant type: 19 at 5
at javassist.bytecode.ConstPool.readOne(ConstPool.java:1244) ~[javassist-3.21.0-GA.jar!/:na]
at javassist.bytecode.ConstPool.read(ConstPool.java:1175) ~[javassist-3.21.0-GA.jar!/:na]
at javassist.bytecode.ConstPool.<init>(ConstPool.java:185) ~[javassist-3.21.0-GA.jar!/:na]
at javassist.bytecode.ClassFile.read(ClassFile.java:829) ~[javassist-3.21.0-GA.jar!/:na]
at javassist.bytecode.ClassFile.<init>(ClassFile.java:154) ~[javassist-3.21.0-GA.jar!/:na]
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassFile(ClassFileArchiveEntryHandler.java:61) ~[hibernate-core-5.2.10.Final.jar!/:5.2.10.Final]
... 37 common frames omitted
What is the problem?
Though this doesn't answer on how to fix this but as stated in JDK-8161256 about the Constant pool tags:
Java 9 uses codes 19 and 20 for the module system.
and the way currently javassist creates ClassFile is by looking up in the ConstantPool (table until Java8) using the readOne method which certainly lacks something like a Module for the latest java version. Your dependency hierarchy for javassist:
org.springframework.boot:spring-boot-starter-actuator:jar:2.0.0.M3:compile
org.springframework.boot:spring-boot-starter-data-jpa:jar:2.0.0.M3:compile
org.hibernate:hibernate-core:jar:5.2.10.Final:compile
org.javassist:javassist:jar:3.21.0-GA:compile
Looking at the javassist side of things:
There seems to be a similar bug registered on javassist/issues#147.
The rel_3_22_0_cr2 (last release) from them
reads Compatible with Java 9-ea+164. Same issue occurs with this version of javassist as well.
So you can probably wait for javassist to come back over this with a solution.

Webstart application: SecurityException: setContextClassLoader

I have a webstart application which connects to a web service. The manifest has:
Permissions: all-permissions
And the jnlp has:
<security>
<all-permissions/>
</security>
However when the connection to the web service is created I get a java.lang.SecurityException: setContextClassLoader (full stack trace below). When I run the application directly (without webstart) it works fine. Is there anything that I should check or change in my setup to fix the problem?
Note: I am using Java 8. The application was working fine with build 121 but fails with build 123, 124 or 125 (the most recent one). So either my setup is fine and a bug has been introduced between b121 and b123 or a bug has been fixed in b123 which exposes a problem in my setup.
org.glassfish.hk2.api.MultiException: A MultiException has 2 exceptions. They are:
1. java.lang.SecurityException: setContextClassLoader
2. java.lang.IllegalStateException: Unable to perform operation: create on org.jvnet.hk2.internal.DynamicConfigurationServiceImpl
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:362) ~[na:na]
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:454) ~[na:na]
at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:119) ~[na:na]
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2296) ~[na:na]
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:590) ~[na:na]
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:577) ~[na:na]
at org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:89) ~[na:na]
at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:144) ~[na:na]
at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:137) ~[na:na]
at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:352) ~[na:na]
at org.glassfish.jersey.client.ClientConfig$State.access$000(ClientConfig.java:85) ~[na:na]
at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:117) ~[na:na]
at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:114) ~[na:na]
at org.glassfish.jersey.internal.util.collection.Values$LazyValue.get(Values.java:311) ~[na:na]
at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:669) ~[na:na]
at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:214) ~[na:na]
at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:124) ~[na:na]
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:97) ~[na:na]
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:90) ~[na:na]
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:396) ~[na:na]
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:296) ~[na:na]
at com.assylias.fund.master.impl.DefaultUserMaster.authenticate(DefaultUserMaster.java:55) ~[na:na]
at com.assylias.bigblue.gui.javafx.users.Login$AuthenticationTask.call(Login.java:342) ~[na:na]
at com.assylias.bigblue.gui.javafx.users.Login$AuthenticationTask.call(Login.java:325) ~[na:na]
at javafx.concurrent.Task$TaskCallable.call(Unknown Source) ~[na:na]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[na:1.8.0-ea]
at java.util.concurrent.CompletableFuture$AsyncRun.exec(Unknown Source) ~[na:1.8.0-ea]
at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) ~[na:1.8.0-ea]
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) ~[na:1.8.0-ea]
at java.util.concurrent.ForkJoinPool.scan(Unknown Source) ~[na:1.8.0-ea]
at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) ~[na:1.8.0-ea]
at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) ~[na:1.8.0-ea]
Caused by: java.lang.SecurityException: setContextClassLoader
at java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread.setContextClassLoader(Unknown Source) ~[na:1.8.0-ea]
at org.glassfish.hk2.utilities.reflection.ReflectionHelper$2.run(ReflectionHelper.java:1049) ~[na:na]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0-ea]
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.setContextClassLoader(ReflectionHelper.java:1045) ~[na:na]
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1101) ~[na:na]
at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:261) ~[na:na]
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:336) ~[na:na]
I should have read the stacktrace more carefully. The exception is thrown by java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread.setContextClassLoader which is a default, no-permission, worker thread. The change has been made following this post and this is the diff.
I was accessing the web service with:
CompletableFuture.runAsync(accessWebservice());
which uses the default ForkJoinPool threadpool, which itself relies on the new InnocuousForkJoinWorkerThread, which throws an exception if setContextClassLoader is called.
Workaround:
CompletableFuture.runAsync(accessWebservice(), executor); //provide an executor

Categories