0
$\begingroup$

Rosanswers logo

Good morning,

I would like to create a node for ROS using rosjava so I was testing ros to check that all goes right. To test rosjava, I got the following example from the community:

  • start up roscore
  • in a terminal, execute: rosrun test_rosjava AddTwoIntsServer
  • in another terminal execute: rosrun test_rosjava AddTwoIntsClient 1 2

I executed without any problem roscore but when I execute the second instruction:

rosrun test_rosjava AddTwoIntsServer

I receive the following error:

jabrena@almaFactory:~$ rosrun test_rosjava AddTwoIntsServer
Exception in thread "main" java.lang.NoClassDefFoundError: AddTwoIntsServer
Caused by: java.lang.ClassNotFoundException: AddTwoIntsServer
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: AddTwoIntsServer.  Program will exit.

I was thinking about the problem and I read the area about rosjava: http://www.ros.org/wiki/rosjava

and it says that it necessary to add 2 variables:

LD_LIBRARY_PATH= <rosjava>/bin
LD_PRELOAD="path to libjsig.so"

in my case:

LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/opt/ros/diamondback/stacks/client_rosjava/rosjava/bin
export LD_LIBRARY_PATH
export LD_PRELOAD=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386

When I execute again, I receive another error about LD_PRELOAD:

ERROR: ld.so: object '/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386/' from LD_PRELOAD cannot be preloaded: ignored.
Exception in thread "main" java.lang.NoClassDefFoundError: AddTwoIntsServer
Caused by: java.lang.ClassNotFoundException: AddTwoIntsServer
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: AddTwoIntsServer.  Program will exit.

Variables related to ROS are:

export
declare -x JAVA_HOME="/usr/lib/jvm/java-6-sun/"
declare -x PATH="/opt/ros/diamondback/ros/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/lejos/bin"
declare -x PYTHONPATH="/opt/ros/diamondback/ros/core/roslib/src:"
declare -x ROS_MASTER_URI="http://localhost:11311"
declare -x ROS_PACKAGE_PATH="/opt/ros/diamondback/stacks"
declare -x ROS_ROOT="/opt/ros/diamondback/ros"

Can you help me?

I would like to run ROS in a right way to create my first node but I need to solve this problem.

Cheers


Originally posted by Juan Antonio Breña Moral on ROS Answers with karma: 274 on 2011-05-01

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

The problem is a bug in creating the java wrapper script inside the debian build chain. I will fix it as soon as possible and re-release rosjava. But it will take some time until the changes are available as debs.


Originally posted by Lorenz with karma: 22731 on 2011-05-01

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$
0
$\begingroup$

Rosanswers logo

Using the comments by Lorenz,

I checked some steps:

I reinstalled stack for rosjava:

sudo aptitude reinstall ros-diamondback-client-rosjava 

and I removed variables in the procedure to test:

LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/opt/ros/diamondback/stacks/client_rosjava/rosjava/bin

export LD_LIBRARY_PATH
export LD_PRELOAD=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386

I found rosjava in rospack:

jabrena@almaFactory:~$ rospack find test_rosjava
/opt/ros/diamondback/stacks/client_rosjava/test_rosjava

But the result is the same:

jabrena@almaFactory:~$ rosrun test_rosjava AddTwoIntsServer
Exception in thread "main" java.lang.NoClassDefFoundError: AddTwoIntsServer
Caused by: java.lang.ClassNotFoundException: AddTwoIntsServer
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: AddTwoIntsServer.  Program will exit.

In my opinion is something related with Classpath. Maybe.

Cheers


Originally posted by Juan Antonio Breña Moral with karma: 274 on 2011-05-01

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.