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

Factory method 'bootstrap' threw exception; nested exception is java.lang.NullPointerException: handler #10

Open
yijvyan opened this issue May 14, 2020 · 4 comments

Comments

@yijvyan
Copy link

yijvyan commented May 14, 2020

Factory method 'bootstrap' threw exception; nested exception is java.lang.NullPointerException: handler----------------------------idea里面跑没有任何问题,但是打成包后,dht-server-1.0-SNAPSHOT.jar,运行这个包就出现上面的问题了。我搞了好久,还是没办法。

@yijvyan
Copy link
Author

yijvyan commented May 14, 2020

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'DHTServer': Unsatisfied dependency expressed through field 'b'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverBootstrap' defined in class path resource [cc/dodder/dhtserver/netty/config/NettyConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.netty.bootstrap.Bootstrap]: Circular reference involving containing bean 'nettyConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'bootstrap' threw exception; nested exception is java.lang.NullPointerException: handler

@yijvyan
Copy link
Author

yijvyan commented May 14, 2020

希望作者能帮我一下,没弄过netty,这个问题,我实在解决不了。明明idea里面运行没任何问题,但是打成包后,就直接报错了,我也是懵了。。。

@goldhawk1010
Copy link

一模一样的错误,楼主解决了吗?愿意付费 xgshi@vip.163.com

@itlezy
Copy link

itlezy commented Apr 29, 2022

So after few attempts changing the spring-boot and netty versions and no luck, I think it all lies with some classpath precedence problem that I've no time to investigate further.
What you can do is just take the command line that is executed from the IDE and run it in a script, here an example in PowerShell

Please note that some libraries here below have been updated, as I've forked the project

# check your classpath and run with powershell .\run-dht-server.ps1

$m2repo = "$Env:USERPROFILE\.m2\repository"           # your Maven repo with downloaded jars
$dodderHome = "C:\prj\p2p\LezyDodder"                 # home of the Dodder root project
$jvmArgs = "-Dfile.encoding=UTF-8 -Xms1024m"          # any other JVM arg

$ps = New-Object System.Diagnostics.Process

# your java exe
$ps.StartInfo.Filename = "c:\bin\jdk-18.0.1\bin\java.exe"

Write-Output "M2 Repo [$m2repo] Dodder Home [$dodderHome]"
Write-Output "Starting.."

$ps.StartInfo.Arguments = "$jvmArgs -classpath $dodderHome\dodder-dht-server\target\classes;$dodderHome\dodder-common\target\classes;$dodderHome\words\target\classes;$m2repo\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;$m2repo\com\optimaize\languagedetector\language-detector\0.6\language-detector-0.6.jar;$m2repo\net\arnx\jsonic\1.2.11\jsonic-1.2.11.jar;$m2repo\com\intellij\annotations\12.0\annotations-12.0.jar;$m2repo\com\google\guava\guava\18.0\guava-18.0.jar;$m2repo\org\springframework\boot\spring-boot-starter\2.4.3\spring-boot-starter-2.4.3.jar;$m2repo\org\springframework\boot\spring-boot\2.4.3\spring-boot-2.4.3.jar;$m2repo\org\springframework\spring-context\5.3.4\spring-context-5.3.4.jar;$m2repo\org\springframework\spring-beans\5.3.4\spring-beans-5.3.4.jar;$m2repo\org\springframework\spring-expression\5.3.4\spring-expression-5.3.4.jar;$m2repo\org\springframework\boot\spring-boot-autoconfigure\2.4.3\spring-boot-autoconfigure-2.4.3.jar;$m2repo\org\springframework\boot\spring-boot-starter-logging\2.4.3\spring-boot-starter-logging-2.4.3.jar;$m2repo\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;$m2repo\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;$m2repo\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;$m2repo\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;$m2repo\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;$m2repo\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;$m2repo\org\springframework\spring-core\5.3.4\spring-core-5.3.4.jar;$m2repo\org\springframework\spring-jcl\5.3.4\spring-jcl-5.3.4.jar;$m2repo\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;$m2repo\org\springframework\cloud\spring-cloud-starter-stream-kafka\3.1.2\spring-cloud-starter-stream-kafka-3.1.2.jar;$m2repo\org\springframework\cloud\spring-cloud-stream-binder-kafka\3.1.2\spring-cloud-stream-binder-kafka-3.1.2.jar;$m2repo\org\springframework\cloud\spring-cloud-stream-binder-kafka-core\3.1.2\spring-cloud-stream-binder-kafka-core-3.1.2.jar;$m2repo\org\springframework\integration\spring-integration-kafka\5.4.4\spring-integration-kafka-5.4.4.jar;$m2repo\org\springframework\cloud\spring-cloud-stream\3.1.2\spring-cloud-stream-3.1.2.jar;$m2repo\org\springframework\boot\spring-boot-starter-validation\2.4.3\spring-boot-starter-validation-2.4.3.jar;$m2repo\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;$m2repo\org\hibernate\validator\hibernate-validator\6.1.7.Final\hibernate-validator-6.1.7.Final.jar;$m2repo\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;$m2repo\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;$m2repo\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;$m2repo\org\springframework\spring-messaging\5.3.4\spring-messaging-5.3.4.jar;$m2repo\org\springframework\integration\spring-integration-core\5.4.4\spring-integration-core-5.4.4.jar;$m2repo\org\springframework\integration\spring-integration-jmx\5.4.4\spring-integration-jmx-5.4.4.jar;$m2repo\org\springframework\retry\spring-retry\1.3.1\spring-retry-1.3.1.jar;$m2repo\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;$m2repo\org\springframework\cloud\spring-cloud-function-context\3.1.2\spring-cloud-function-context-3.1.2.jar;$m2repo\net\jodah\typetools\0.6.2\typetools-0.6.2.jar;$m2repo\org\springframework\cloud\spring-cloud-function-core\3.1.2\spring-cloud-function-core-3.1.2.jar;$m2repo\com\fasterxml\jackson\core\jackson-databind\2.11.4\jackson-databind-2.11.4.jar;$m2repo\com\fasterxml\jackson\core\jackson-annotations\2.11.4\jackson-annotations-2.11.4.jar;$m2repo\com\fasterxml\jackson\core\jackson-core\2.11.4\jackson-core-2.11.4.jar;$m2repo\org\apache\kafka\kafka-clients\2.6.0\kafka-clients-2.6.0.jar;$m2repo\com\github\luben\zstd-jni\1.4.4-7\zstd-jni-1.4.4-7.jar;$m2repo\org\lz4\lz4-java\1.7.1\lz4-java-1.7.1.jar;$m2repo\org\xerial\snappy\snappy-java\1.1.7.3\snappy-java-1.1.7.3.jar;$m2repo\org\springframework\kafka\spring-kafka\2.6.6\spring-kafka-2.6.6.jar;$m2repo\io\netty\netty-all\4.1.76.Final\netty-all-4.1.76.Final.jar;$m2repo\io\netty\netty-buffer\4.1.59.Final\netty-buffer-4.1.59.Final.jar;$m2repo\io\netty\netty-codec\4.1.59.Final\netty-codec-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-dns\4.1.59.Final\netty-codec-dns-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-haproxy\4.1.59.Final\netty-codec-haproxy-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-http\4.1.59.Final\netty-codec-http-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-http2\4.1.59.Final\netty-codec-http2-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-memcache\4.1.59.Final\netty-codec-memcache-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-mqtt\4.1.59.Final\netty-codec-mqtt-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-redis\4.1.59.Final\netty-codec-redis-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-smtp\4.1.59.Final\netty-codec-smtp-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-socks\4.1.59.Final\netty-codec-socks-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-stomp\4.1.59.Final\netty-codec-stomp-4.1.59.Final.jar;$m2repo\io\netty\netty-codec-xml\4.1.59.Final\netty-codec-xml-4.1.59.Final.jar;$m2repo\io\netty\netty-common\4.1.59.Final\netty-common-4.1.59.Final.jar;$m2repo\io\netty\netty-handler\4.1.59.Final\netty-handler-4.1.59.Final.jar;$m2repo\io\netty\netty-handler-proxy\4.1.59.Final\netty-handler-proxy-4.1.59.Final.jar;$m2repo\io\netty\netty-resolver\4.1.59.Final\netty-resolver-4.1.59.Final.jar;$m2repo\io\netty\netty-resolver-dns\4.1.59.Final\netty-resolver-dns-4.1.59.Final.jar;$m2repo\io\netty\netty-transport\4.1.59.Final\netty-transport-4.1.59.Final.jar;$m2repo\io\netty\netty-transport-rxtx\4.1.59.Final\netty-transport-rxtx-4.1.59.Final.jar;$m2repo\io\netty\netty-transport-sctp\4.1.59.Final\netty-transport-sctp-4.1.59.Final.jar;$m2repo\io\netty\netty-transport-udt\4.1.59.Final\netty-transport-udt-4.1.59.Final.jar;$m2repo\io\netty\netty-transport-classes-epoll\4.1.76.Final\netty-transport-classes-epoll-4.1.76.Final.jar;$m2repo\io\netty\netty-transport-native-unix-common\4.1.59.Final\netty-transport-native-unix-common-4.1.59.Final.jar;$m2repo\io\netty\netty-transport-classes-kqueue\4.1.76.Final\netty-transport-classes-kqueue-4.1.76.Final.jar;$m2repo\io\netty\netty-resolver-dns-classes-macos\4.1.76.Final\netty-resolver-dns-classes-macos-4.1.76.Final.jar;$m2repo\io\netty\netty-transport-native-epoll\4.1.59.Final\netty-transport-native-epoll-4.1.59.Final-linux-x86_64.jar;$m2repo\io\netty\netty-transport-native-epoll\4.1.59.Final\netty-transport-native-epoll-4.1.59.Final-linux-aarch_64.jar;$m2repo\io\netty\netty-transport-native-kqueue\4.1.59.Final\netty-transport-native-kqueue-4.1.59.Final-osx-x86_64.jar;$m2repo\io\netty\netty-transport-native-kqueue\4.1.76.Final\netty-transport-native-kqueue-4.1.76.Final-osx-aarch_64.jar;$m2repo\io\netty\netty-resolver-dns-native-macos\4.1.59.Final\netty-resolver-dns-native-macos-4.1.59.Final-osx-x86_64.jar;$m2repo\io\netty\netty-resolver-dns-native-macos\4.1.76.Final\netty-resolver-dns-native-macos-4.1.76.Final-osx-aarch_64.jar;$m2repo\org\springframework\boot\spring-boot-starter-data-redis\2.4.3\spring-boot-starter-data-redis-2.4.3.jar;$m2repo\org\springframework\data\spring-data-redis\2.4.5\spring-data-redis-2.4.5.jar;$m2repo\org\springframework\data\spring-data-keyvalue\2.4.5\spring-data-keyvalue-2.4.5.jar;$m2repo\org\springframework\data\spring-data-commons\2.4.5\spring-data-commons-2.4.5.jar;$m2repo\org\springframework\spring-tx\5.3.4\spring-tx-5.3.4.jar;$m2repo\org\springframework\spring-oxm\5.3.4\spring-oxm-5.3.4.jar;$m2repo\org\springframework\spring-aop\5.3.4\spring-aop-5.3.4.jar;$m2repo\org\springframework\spring-context-support\5.3.4\spring-context-support-5.3.4.jar;$m2repo\io\lettuce\lettuce-core\6.0.2.RELEASE\lettuce-core-6.0.2.RELEASE.jar;$m2repo\io\projectreactor\reactor-core\3.4.3\reactor-core-3.4.3.jar;$m2repo\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;$m2repo\redis\clients\jedis\3.1.0\jedis-3.1.0.jar;$m2repo\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;$m2repo\org\apache\commons\commons-pool2\2.9.0\commons-pool2-2.9.0.jar;$m2repo\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;$m2repo\org\projectlombok\lombok\1.18.18\lombok-1.18.18.jar cc.dodder.dhtserver.DhtServerApplication"

$ps.StartInfo.UseShellExecute = $false
$ps.Start()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants