Build from Source Traccar

Nikhil6 years ago

Hi,
I was successfully able to build from Traccar source code following your documentation. The local build is running fine on the local machine using the IntelliJ IDE. I used the package.sh script to generate the installers and got the setups created. When I am installing the software using my custom setups it is giving the following error and the service stops automatically when started. Below is the error message:

INFO|4776/0|Service traccar|18-06-05 15:00:09|java.lang.ClassNotFoundException: org.traccar.Main
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at java.net.URLClassLoader.findClass(Unknown Source)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at java.lang.ClassLoader.loadClass(Unknown Source)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at java.lang.ClassLoader.loadClass(Unknown Source)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at org.rzo.yajsw.app.WrapperManagerImpl.loadJar(WrapperManagerImpl.java:876)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at org.rzo.yajsw.app.WrapperManagerImpl.init(WrapperManagerImpl.java:328)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at org.rzo.yajsw.app.WrapperManagerProxy.getWrapperManager(WrapperManagerProxy.java:53)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at org.rzo.yajsw.app.AbstractWrapperJVMMain$1.run(AbstractWrapperJVMMain.java:64)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at java.security.AccessController.doPrivileged(Native Method)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at org.rzo.yajsw.app.AbstractWrapperJVMMain.preExecute(AbstractWrapperJVMMain.java:56)
INFO|4776/0|Service traccar|18-06-05 15:00:09|	at org.rzo.yajsw.app.WrapperJVMMain.main(WrapperJVMMain.java:41)
INFO|4776/0|Service traccar|18-06-05 15:00:09|no java main method found -> aborting
INFO|4776/0|Service traccar|18-06-05 15:00:09|ERROR: could not load main method from class/jar: org.traccar.Main/traccar.jar
INFO|wrapper|Service traccar|18-06-05 15:00:09|calling onStop
INFO|wrapper|Service traccar|18-06-05 15:00:09|Win service stop - timeout: 30000
INFO|wrapper|Service traccar|18-06-05 15:00:09|Win service wrapper.control -> stopping application
INFO|wrapper|Service traccar|18-06-05 15:00:09|Win service stop - after shutdown
INFO|wrapper|Service traccar|18-06-05 15:00:09|Win service stop - before notify
INFO|wrapper|Service traccar|18-06-05 15:00:09|Win service terminated

What can be the reason for this error as before making the installers it was working well on the local machine? Kindly help!

Regards,
Nikhil

Anton Tananaev6 years ago

Looks like you haven't compiled it properly.

Nikhil6 years ago

What I did was build the code to see if server was running fine or not.
After the above step i am running the script to generate the installers.

Let me know if I missed anything. I can share small video of the same if it helps you in tracking the issue.
Kindly advice.

Anton Tananaev6 years ago

As I said, your Java compilation clearly failed. You are missing a class. I would recommend to use Maven instead of IDE.

Nikhil6 years ago

Your documentation says one of the options as IntelliJ IDE. I am compiling using maven only. Let me send send across a small video of my workflow if u can point out my error it would be great.

Nikhil6 years ago

Hi Anton,
I found out once i am compiling the project the jar file created has some issues as it is not able to load/locate the main function. Can you please list down the steps as to how to create a valid jar file from the traccar source code. It would be really helpful for me as I think I am doing a mistake there because if I try to run the server from JAR it does not work but if I try to create a new application in the Edit Configuration menu as per your doc at https://www.traccar.org/build-in-intellij-idea/ it runs fine.

Thanks for your assistance.

Anton Tananaev6 years ago

I already suggested you to use Maven to compile:

mvn package
Nikhil6 years ago

Now I am able to build the jar I cloned the tag 3.15 and it worked. Thanks!