Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hazelcast 3.7.3 and Spring Boot 1.4.2 getting error PortableFactory[-22] is already registered! #9353

Closed
bmudda opened this issue Dec 1, 2016 · 10 comments

Comments

Projects
None yet
4 participants
@bmudda
Copy link

commented Dec 1, 2016

Running a simple test application with Hazelcast 3.7.3 and Spring Boot 1.4.2.RELEASE. The HazelcastRunner class is instantiated by SpringBoot using a configuration XML found in the classpath. When building and running the application, we get the following error.

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'hazelcastRunner' defined in class path resource [springConfigs/hazelcast/hazelcastRunner.xml]: 
Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [com.bmudda.hazelcast.docker.test.HazelcastRunner]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: PortableFactory[-22] is already registered! 
com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@1a8a8f7c -> 
com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@2353b3e6

The sample application can be found at https://github.com/bmudda/hazelcast-docker-spring-test/releases/tag/1.0-RC1

This issue was raised before here: #2395 but is now closed.

The log info and stacktrace seen when running application can be found here: #2395 (comment)

@jerrinot jerrinot added this to the 3.8 milestone Dec 1, 2016

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

Hi @bmudda,

I tried to start your sample application via ./gradlew bootRun and it appears to work fine:

2016-12-01 19:43:48.442  INFO 30886 --- [           main] com.hazelcast.system                     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Hazelcast 3.7.3 (20161117 - 8166eea) starting at [127.0.0.1]:5701
2016-12-01 19:43:48.444  INFO 30886 --- [           main] com.hazelcast.system                     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
2016-12-01 19:43:48.444  INFO 30886 --- [           main] com.hazelcast.system                     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Configured Hazelcast Serialization version : 1
2016-12-01 19:43:48.609  INFO 30886 --- [           main] c.h.s.i.o.impl.BackpressureRegulator     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Backpressure is disabled
2016-12-01 19:43:49.038  INFO 30886 --- [           main] com.hazelcast.instance.Node              : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Creating TcpIpJoiner
2016-12-01 19:43:49.039  INFO 30886 --- [           main] com.hazelcast.core.LifecycleService      : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] [127.0.0.1]:5701 is STARTING
2016-12-01 19:43:49.127  INFO 30886 --- [           main] c.h.s.i.o.impl.OperationExecutorImpl     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Starting 4 partition threads
2016-12-01 19:43:49.128  INFO 30886 --- [           main] c.h.s.i.o.impl.OperationExecutorImpl     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Starting 3 generic threads (1 dedicated for priority tasks)
2016-12-01 19:43:49.132  INFO 30886 --- [           main] c.h.n.t.n.NonBlockingIOThreadingModel    : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] TcpIpConnectionManager configured with Non Blocking IO-threading model: 3 input threads and 3 output threads
2016-12-01 19:43:49.145  INFO 30886 --- [           main] com.hazelcast.cluster.impl.TcpIpJoiner   : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] 


Members [1] {
	Member [127.0.0.1]:5701 - e9366d9f-5f30-4584-b928-de983d8c38c6 this
}

2016-12-01 19:43:49.174  INFO 30886 --- [           main] com.hazelcast.core.LifecycleService      : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] [127.0.0.1]:5701 is STARTED
@bmudda

This comment has been minimized.

Copy link
Author

commented Dec 1, 2016

@jerrinot We did a build and run using this command when we encountered the error.

./gradlew build --refresh-dependencies -x test && java -jar build/libs/hazelcast-docker-spring-test-1.0-RC1.jar --debug

I have added the gradle-wrapper.jar in the project and retagged @ https://github.com/bmudda/hazelcast-docker-spring-test/releases/tag/1.0-RC1

@bitsofinfo

This comment has been minimized.

Copy link

commented Dec 1, 2016

blocker for us, I get

LAPTOP $ wget https://github.com/bmudda/hazelcast-docker-spring-test/archive/1.0-RC1.tar.gz
--2016-12-01 13:04:35--  https://github.com/bmudda/hazelcast-docker-spring-test/archive/1.0-RC1.tar.gz
Resolving github.com... 192.30.253.113, 192.30.253.112
Connecting to github.com|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/bmudda/hazelcast-docker-spring-test/tar.gz/1.0-RC1 [following]
--2016-12-01 13:04:35--  https://codeload.github.com/bmudda/hazelcast-docker-spring-test/tar.gz/1.0-RC1
Resolving codeload.github.com... 192.30.253.120, 192.30.253.121
Connecting to codeload.github.com|192.30.253.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: '1.0-RC1.tar.gz'

    [ <=>                                                                                                                                                                 ] 59,681      --.-K/s   in 0.07s

2016-12-01 13:04:35 (787 KB/s) - '1.0-RC1.tar.gz' saved [59681]

LAPTOP $ tar -xvf 1.0-RC1.tar.gz
x hazelcast-docker-spring-test-1.0-RC1/
x hazelcast-docker-spring-test-1.0-RC1/.gitignore
x hazelcast-docker-spring-test-1.0-RC1/Dockerfile
x hazelcast-docker-spring-test-1.0-RC1/LICENSE
x hazelcast-docker-spring-test-1.0-RC1/README.md
x hazelcast-docker-spring-test-1.0-RC1/build.gradle
x hazelcast-docker-spring-test-1.0-RC1/docker-entrypoint.sh
x hazelcast-docker-spring-test-1.0-RC1/gradle.properties
x hazelcast-docker-spring-test-1.0-RC1/gradle/
x hazelcast-docker-spring-test-1.0-RC1/gradle/wrapper/
x hazelcast-docker-spring-test-1.0-RC1/gradle/wrapper/gradle-wrapper.jar
x hazelcast-docker-spring-test-1.0-RC1/gradle/wrapper/gradle-wrapper.properties
x hazelcast-docker-spring-test-1.0-RC1/gradlew
x hazelcast-docker-spring-test-1.0-RC1/gradlew.bat
x hazelcast-docker-spring-test-1.0-RC1/settings.gradle
x hazelcast-docker-spring-test-1.0-RC1/src/
x hazelcast-docker-spring-test-1.0-RC1/src/main/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/bmudda/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/bmudda/hazelcast/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/bmudda/hazelcast/docker/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/bmudda/hazelcast/docker/test/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/bmudda/hazelcast/docker/test/HazelcastRunner.java
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/bmudda/util/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/bmudda/util/boot/
x hazelcast-docker-spring-test-1.0-RC1/src/main/java/com/bmudda/util/boot/Application.java
x hazelcast-docker-spring-test-1.0-RC1/src/main/resources/
x hazelcast-docker-spring-test-1.0-RC1/src/main/resources/log4j.properties
x hazelcast-docker-spring-test-1.0-RC1/src/main/resources/springConfigs/
x hazelcast-docker-spring-test-1.0-RC1/src/main/resources/springConfigs/common.xml
x hazelcast-docker-spring-test-1.0-RC1/src/main/resources/springConfigs/hazelcast/
x hazelcast-docker-spring-test-1.0-RC1/src/main/resources/springConfigs/hazelcast/hazelcast-docker.xml
x hazelcast-docker-spring-test-1.0-RC1/src/main/resources/springConfigs/hazelcast/hazelcastRunner.xml
LAPTOP $ cd hazelcast-docker-spring-test-1.0-RC1/
LAPTOP $ ./gradlew build --refresh-dependencies -x test && java -jar build/libs/hazelcast-docker-spring-test-1.0-RC1.jar —debug
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-gradle-plugin/1.4.2.RELEASE/spring-boot-gradle-plugin-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-tools/1.4.2.RELEASE/spring-boot-tools-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-parent/1.4.2.RELEASE/spring-boot-parent-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-dependencies/1.4.2.RELEASE/spring-boot-dependencies-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/spring-framework-bom/4.3.4.RELEASE/spring-framework-bom-4.3.4.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/data/spring-data-releasetrain/Hopper-SR5/spring-data-releasetrain-Hopper-SR5.pom
Download https://jcenter.bintray.com/org/springframework/data/build/spring-data-build/1.8.5.RELEASE/spring-data-build-1.8.5.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/integration/spring-integration-bom/4.3.5.RELEASE/spring-integration-bom-4.3.5.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-loader-tools/1.4.2.RELEASE/spring-boot-loader-tools-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/spring-core/4.3.4.RELEASE/spring-core-4.3.4.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-gradle-plugin/1.4.2.RELEASE/spring-boot-gradle-plugin-1.4.2.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-loader-tools/1.4.2.RELEASE/spring-boot-loader-tools-1.4.2.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/spring-core/4.3.4.RELEASE/spring-core-4.3.4.RELEASE.jar
Spring Boot plugin's support for Gradle 2.5 is deprecated. Please upgrade to Gradle 2.9 or later.
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter-web/1.4.2.RELEASE/spring-boot-starter-web-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starters/1.4.2.RELEASE/spring-boot-starters-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter-parent/1.4.2.RELEASE/spring-boot-starter-parent-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter/1.4.2.RELEASE/spring-boot-starter-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter-tomcat/1.4.2.RELEASE/spring-boot-starter-tomcat-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/com/fasterxml/jackson/core/jackson-databind/2.8.4/jackson-databind-2.8.4.pom
Download https://jcenter.bintray.com/org/springframework/spring-web/4.3.4.RELEASE/spring-web-4.3.4.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/spring-webmvc/4.3.4.RELEASE/spring-webmvc-4.3.4.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot/1.4.2.RELEASE/spring-boot-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-autoconfigure/1.4.2.RELEASE/spring-boot-autoconfigure-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter-logging/1.4.2.RELEASE/spring-boot-starter-logging-1.4.2.RELEASE.pom
Download https://jcenter.bintray.com/org/apache/tomcat/embed/tomcat-embed-core/8.5.6/tomcat-embed-core-8.5.6.pom
Download https://jcenter.bintray.com/org/apache/tomcat/embed/tomcat-embed-el/8.5.6/tomcat-embed-el-8.5.6.pom
Download https://jcenter.bintray.com/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.6/tomcat-embed-websocket-8.5.6.pom
Download https://jcenter.bintray.com/com/fasterxml/classmate/1.3.3/classmate-1.3.3.pom
Download https://jcenter.bintray.com/com/fasterxml/jackson/core/jackson-annotations/2.8.4/jackson-annotations-2.8.4.pom
Download https://jcenter.bintray.com/com/fasterxml/jackson/core/jackson-core/2.8.4/jackson-core-2.8.4.pom
Download https://jcenter.bintray.com/org/springframework/spring-aop/4.3.4.RELEASE/spring-aop-4.3.4.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/spring-beans/4.3.4.RELEASE/spring-beans-4.3.4.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/spring-context/4.3.4.RELEASE/spring-context-4.3.4.RELEASE.pom
Download https://jcenter.bintray.com/org/springframework/spring-expression/4.3.4.RELEASE/spring-expression-4.3.4.RELEASE.pom
Download https://jcenter.bintray.com/com/fasterxml/jackson/core/jackson-core/2.8.4/jackson-core-2.8.4.jar
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter-web/1.4.2.RELEASE/spring-boot-starter-web-1.4.2.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter/1.4.2.RELEASE/spring-boot-starter-1.4.2.RELEASE.jar
Download https://jcenter.bintray.com/com/fasterxml/jackson/core/jackson-annotations/2.8.4/jackson-annotations-2.8.4.jar
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter-tomcat/1.4.2.RELEASE/spring-boot-starter-tomcat-1.4.2.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/spring-aop/4.3.4.RELEASE/spring-aop-4.3.4.RELEASE.jar
Download https://jcenter.bintray.com/com/fasterxml/jackson/core/jackson-databind/2.8.4/jackson-databind-2.8.4.jar
Download https://jcenter.bintray.com/org/springframework/spring-web/4.3.4.RELEASE/spring-web-4.3.4.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/spring-beans/4.3.4.RELEASE/spring-beans-4.3.4.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/spring-webmvc/4.3.4.RELEASE/spring-webmvc-4.3.4.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot/1.4.2.RELEASE/spring-boot-1.4.2.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-autoconfigure/1.4.2.RELEASE/spring-boot-autoconfigure-1.4.2.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/spring-context/4.3.4.RELEASE/spring-context-4.3.4.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/boot/spring-boot-starter-logging/1.4.2.RELEASE/spring-boot-starter-logging-1.4.2.RELEASE.jar
Download https://jcenter.bintray.com/org/springframework/spring-expression/4.3.4.RELEASE/spring-expression-4.3.4.RELEASE.jar
Download https://jcenter.bintray.com/org/apache/tomcat/embed/tomcat-embed-core/8.5.6/tomcat-embed-core-8.5.6.jar
Download https://jcenter.bintray.com/org/apache/tomcat/embed/tomcat-embed-el/8.5.6/tomcat-embed-el-8.5.6.jar
Download https://jcenter.bintray.com/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.6/tomcat-embed-websocket-8.5.6.jar
Download https://jcenter.bintray.com/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar
:compileJava
:processResources
:classes
:findMainClass
> Building 40% > :jar



:jar
:sourcesJar
:bootRepackage
:assemble
:check
:build

BUILD SUCCESSFUL

Total time: 2 mins 10.754 secs

This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.5/userguide/gradle_daemon.html
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/private/tmp/x/hazelcast-docker-spring-test-1.0-RC1/build/libs/hazelcast-docker-spring-test-1.0-RC1.jar!/BOOT-INF/classes!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/private/tmp/x/hazelcast-docker-spring-test-1.0-RC1/build/libs/hazelcast-docker-spring-test-1.0-RC1.jar!/BOOT-INF/lib/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

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

2016-12-01 13:06:58.083  INFO 88063 --- [           main] com.bmudda.util.boot.Application         : Starting Application on USNYZADOAAALX8.local with PID 88063 (/private/tmp/x/hazelcast-docker-spring-test-1.0-RC1/build/libs/hazelcast-docker-spring-test-1.0-RC1.jar started by bof in /private/tmp/x/hazelcast-docker-spring-test-1.0-RC1)
2016-12-01 13:06:58.088  INFO 88063 --- [           main] com.bmudda.util.boot.Application         : No active profile set, falling back to default profiles: default
2016-12-01 13:06:58.108  INFO 88063 --- [           main] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [springConfigs/common.xml]
2016-12-01 13:06:58.234  INFO 88063 --- [           main] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [springConfigs/hazelcast/hazelcastRunner.xml]
2016-12-01 13:06:58.355  INFO 88063 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@28c97a5: startup date [Thu Dec 01 13:06:58 EST 2016]; root of context hierarchy
2016-12-01 13:07:01.134  INFO 88063 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-12-01 13:07:01.150  INFO 88063 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-12-01 13:07:01.152  INFO 88063 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
2016-12-01 13:07:01.270  INFO 88063 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-12-01 13:07:01.270  INFO 88063 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2917 ms
2016-12-01 13:07:01.426  INFO 88063 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2016-12-01 13:07:01.430  INFO 88063 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-12-01 13:07:01.431  INFO 88063 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-12-01 13:07:01.431  INFO 88063 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-12-01 13:07:01.431  INFO 88063 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2016-12-01 13:07:01.508  INFO 88063 --- [           main] com.hazelcast.config.ClasspathXmlConfig  : Configuring Hazelcast from 'springConfigs/hazelcast/hazelcast-docker.xml'.
2016-12-01 13:07:01.687  INFO 88063 --- [           main] c.h.instance.DefaultAddressPicker        : [LOCAL] [hazelcast-docker-test] [3.7.3] Interfaces is disabled, trying to pick one address from TCP-IP config addresses: [127.0.0.1]
2016-12-01 13:07:01.710  INFO 88063 --- [           main] c.h.instance.DefaultAddressPicker        : [LOCAL] [hazelcast-docker-test] [3.7.3] Picked [127.0.0.1]:5701, using socket ServerSocket[addr=/127.0.0.1,localport=5701], bind any local is false
2016-12-01 13:07:01.751  INFO 88063 --- [           main] com.hazelcast.system                     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Hazelcast 3.7.3 (20161117 - 8166eea) starting at [127.0.0.1]:5701
2016-12-01 13:07:01.751  INFO 88063 --- [           main] com.hazelcast.system                     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
2016-12-01 13:07:01.751  INFO 88063 --- [           main] com.hazelcast.system                     : [127.0.0.1]:5701 [hazelcast-docker-test] [3.7.3] Configured Hazelcast Serialization version : 1
2016-12-01 13:07:01.795  WARN 88063 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hazelcastRunner' defined in class path resource [springConfigs/hazelcast/hazelcastRunner.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.bmudda.hazelcast.docker.test.HazelcastRunner]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: PortableFactory[-22] is already registered! com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@7e2d773b -> com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@2173f6d9
2016-12-01 13:07:01.798  INFO 88063 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2016-12-01 13:07:01.819  INFO 88063 --- [           main] utoConfigurationReportLoggingInitializer :

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2016-12-01 13:07:01.831 ERROR 88063 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hazelcastRunner' defined in class path resource [springConfigs/hazelcast/hazelcastRunner.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.bmudda.hazelcast.docker.test.HazelcastRunner]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: PortableFactory[-22] is already registered! com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@7e2d773b -> com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@2173f6d9
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:279) ~[classes!/:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1148) ~[classes!/:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050) ~[classes!/:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) ~[classes!/:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[classes!/:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[classes!/:na]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[classes!/:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[classes!/:na]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[classes!/:na]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754) ~[classes!/:na]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[classes!/:na]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[classes!/:na]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[classes!/:na]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [classes!/:na]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [classes!/:na]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [classes!/:na]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [classes!/:na]
	at com.bmudda.util.boot.Application.main(Application.java:21) [classes!/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [hazelcast-docker-spring-test-1.0-RC1.jar:na]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [hazelcast-docker-spring-test-1.0-RC1.jar:na]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [hazelcast-docker-spring-test-1.0-RC1.jar:na]
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [hazelcast-docker-spring-test-1.0-RC1.jar:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.bmudda.hazelcast.docker.test.HazelcastRunner]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: PortableFactory[-22] is already registered! com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@7e2d773b -> com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@2173f6d9
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154) ~[classes!/:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122) ~[classes!/:na]
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:271) ~[classes!/:na]
	... 25 common frames omitted
Caused by: java.lang.IllegalArgumentException: PortableFactory[-22] is already registered! com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@7e2d773b -> com.hazelcast.replicatedmap.impl.client.ReplicatedMapPortableHook$1@2173f6d9
	at com.hazelcast.internal.serialization.impl.PortableHookLoader.register(PortableHookLoader.java:87) ~[classes!/:na]
	at com.hazelcast.internal.serialization.impl.PortableHookLoader.load(PortableHookLoader.java:54) ~[classes!/:na]
	at com.hazelcast.internal.serialization.impl.PortableHookLoader.<init>(PortableHookLoader.java:44) ~[classes!/:na]
	at com.hazelcast.internal.serialization.impl.SerializationServiceV1.<init>(SerializationServiceV1.java:88) ~[classes!/:na]
	at com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder.createSerializationService(DefaultSerializationServiceBuilder.java:264) ~[classes!/:na]
	at com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder.build(DefaultSerializationServiceBuilder.java:218) ~[classes!/:na]
	at com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder.build(DefaultSerializationServiceBuilder.java:46) ~[classes!/:na]
	at com.hazelcast.instance.DefaultNodeExtension.createSerializationService(DefaultNodeExtension.java:126) ~[classes!/:na]
	at com.hazelcast.instance.Node.<init>(Node.java:181) ~[classes!/:na]
	at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:155) ~[classes!/:na]
	at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:126) ~[classes!/:na]
	at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:218) ~[classes!/:na]
	at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:176) ~[classes!/:na]
	at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:126) ~[classes!/:na]
	at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58) ~[classes!/:na]
	at com.bmudda.hazelcast.docker.test.HazelcastRunner.<init>(HazelcastRunner.java:39) ~[classes!/:na]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_45]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_45]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_45]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_45]
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142) ~[classes!/:na]
	... 27 common frames omitted
@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

Thanks guys, I can reproduce it now.

This is what's going on:

  • The FatJAR created by Gradle - SpringBoot magic has the META-INF/services/com.hazelcast.PortableHook file copied from hazelcast.jar
  • Moreover the same file is left in the hazelcast.jar inside /BOOT-INF/lib/hazelcast.jar in the FatJAR.

Then naturally the service file is picked twice when Hazelcast is starting -> the duplication error.

Now the question is how to fix this. I see these options:

  1. SpringBoot should make sure files from META-INF/services are not duplicated. They should be in one place only.
  2. Hazelcast could make a hack especially for SpringBoot.

Perhaps @vpavic could have an idea?

@bitsofinfo

This comment has been minimized.

Copy link

commented Dec 1, 2016

So... what classloader is hazelcast barfing on when getting this com.hazelcast.PortableHook, does a specific classloader need to be provided when instantiating HZ?

@vpavic

This comment has been minimized.

Copy link

commented Dec 1, 2016

@jerrinot I'm afraid this is unrelated to Spring Boot.

The problem seems to be in the custom jar task config:

jar {
  manifest { 
    attributes (
      "Main-Class": "com.bmudda.util.boot.Application"
      )
  }  

  from {
    configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
  }
}

This appears to be responsible for duplicated resources - if I comment out that part of the buildscript and rebuild the project it does not result in error on startup.

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

@bitsofinfo: No special classloader should be needed. There should be no duplicates in the FatJAR.
The Spring Boot issue I created was closed. According to @philwebb the duplication is NOT caused by Spring Boot (at least that's what I understood from spring-projects/spring-boot#7550 (comment))

Now I am no Gradle expert so I have really no way to tell what's wrong with the sample project @bmudda created. @bitsofinfo What's the simplest reproducer you have?

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

@vpavic thank you very much! this is exactly the kind of info I was looking for!
I guess this issue should be closed as it's caused by a buggy build script. Do you agree?

@vpavic

This comment has been minimized.

Copy link

commented Dec 1, 2016

@jerrinot Yes, I'd agree with that assessment.

@jerrinot

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

excellent, thanks a ton!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.