Sharders / sharder-chain

A blockchain-based multi-chain notary and storage network
http://scan.sharder.io
Other
41 stars 7 forks source link

NullPointerException reading properties #67

Open mc-sunw opened 4 years ago

mc-sunw commented 4 years ago

Firstly, there is no script to compile the classes which would be useful. (I imported into Eclipse to get it compiled).

When running run.sh, I get:

mark@mac-work[800]% ./run.sh Initializing COS server version 0.1.8 Command line arguments -Dsharder.runtime.mode=desktop isHeadless=false Runtime mode org.conch.env.DesktopMode User home folder /Users/mark/.sharder Loading sharder-default.properties from classpath Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.lang.NullPointerException at org.conch.Conch.getBooleanProperty(Conch.java:657) at org.conch.Conch.getRunningMode(Conch.java:999) at org.conch.Conch.(Conch.java:305)

This seems to be happening because the code has a bunch of separate static blocks, the first of which is calling a method referring to a class variable which won't be set until a later static block.

Specifically, getBooleanProperty() is being called at line 656 from getRunningMode() line 999 from the first static block before the class variable Properties properties at line 376 is populated from the second static block.

ben-xy commented 4 years ago

You should run the main method of the org.conch.Conch after you finish the compilation in the project. Shells is used for the independent client mode;

You can appoint the JVM parameter -Dsharder.runtime.network=$NETWORK to connect the specific network like following screenshot;

And you can set the configuration item sharder.isOffline=true in the conf/sharder.properties to execute in the local offline mode, it will help you to develop and test in your local environment.

Conch-Main-Method