ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Testing rosjava

asked 2011-05-01 18:23:39 -0500

updated 2011-05-01 19:13:17 -0500

tfoote gravatar image

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

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2011-05-01 21:39:26 -0500

Lorenz gravatar image

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.

edit flag offensive delete link more
1

answered 2011-05-01 20:30:19 -0500

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2011-05-01 18:23:39 -0500

Seen: 1,500 times

Last updated: May 01 '11