Deployment issues

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

Deployment issues

Postby ruperty » Fri Jul 11, 2014 12:34 pm

Hello,

I am trying to deploy a project from eclipse but running into a few issues to which I can't find the answers.

  1. I have external jars to use. How are they added to the classpath?
  2. Can the external jar be part of the deployed package or do I need to copy it manually to the EV3 unit?
  3. I tried to copy files with pscp but get this error,
    sh: /usr/libexec/sftp-server: not found
    Fatal: Received unexpected end-of-file from server
  4. I wanted to use arguments to the main method. I thought the way to do this was to modify the manifest file, but eclipse doesn't appear to use the manifest file I specify, through the export options.

Any pointers on these would be most welcome.
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: Deployment issues

Postby ruperty » Fri Jul 11, 2014 5:13 pm

On the third issue I discovered I needed the -scp option. File transfer now works.

The other issues are still outstanding.
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: Deployment issues

Postby lawrie » Sat Jul 12, 2014 9:55 am

It is not very clear what you are trying to do from your description.

If you have requirements for deployment that are not supported by the Eclipse plugin, the best thing to do is to write an ant build file. That can do whatever you want, including using scp and ssh tasks.

However, it looks like you are using the Eclipse export to export a runnable jar file. I have not tried that, and I don't know if anyone else has, but it should be possible to make it work.

One issue is that a launch configuration file is needed. The leJOS Eclipse plugin uses a custom launch configuration file that has different options to the normal Java launch configuration, and does not include run time parameters or class path entries. However, you can create a normal Java launch configuration and use that.

I think all the options to package the external jar files in the runnable jar file or as external jar files should work, but if you use external jar files the files names on the EV3 will not be the same as the ones on the PC.

I don't know what you mean by "Eclipse does not use the manifest file". I think the issue with parameters is that the manifest file of Java runnable jar files does not support them. You will need to find a different solution for parameters, depending on how you plan to run your application.

We probably need to add options to the Eclipse plugin to support referenced jar files, to make some of this easier. Any suggestions on how we should do that would be helpful.

On the pscp issue, I see you found the -scp solution. pscp is supposed to use scp if sftp is not available. I am not sure why it did not do that for you. I think it worked for me when I used it without the -scp option, but I may be wrong.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Deployment issues

Postby ruperty » Sat Jul 12, 2014 1:13 pm

lawrie wrote:It is not very clear what you are trying to do from your description.


I want my EV3 project to deploy from my PC to the EV3 and run on the unit as per normal, but also to specify the args to the main method, and it would need to access classes in external jar file.

If you have requirements for deployment that are not supported by the Eclipse plugin, the best thing to do is to write an ant build file. That can do whatever you want, including using scp and ssh tasks.


Ok, that might be the way to go. How do I create that? Or can I just copy a sample one into my project?

However, it looks like you are using the Eclipse export to export a runnable jar file. I have not tried that, and I don't know if anyone else has, but it should be possible to make it work.


Isn't that what is done as standard?

One issue is that a launch configuration file is needed. The leJOS Eclipse plugin uses a custom launch configuration file that has different options to the normal Java launch configuration, and does not include run time parameters or class path entries. However, you can create a normal Java launch configuration and use that.


How would the package be deployed to the EV3 in this case?

I don't know what you mean by "Eclipse does not use the manifest file". I think the issue with parameters is that the manifest file of Java runnable jar files does not support them. You will need to find a different solution for parameters, depending on how you plan to run your application.


Although there are options in eclipse for creating a custom manifest file, in which I put arguments, this seems to be ignored and the old one is still gererated.
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: Deployment issues

Postby lawrie » Sun Jul 13, 2014 8:16 pm

The project org.lejos.ev3.example (one of the sample projects) has an ant build file. You would need to modify it to copy your external jar files to the EV3 and add a reference to them to the class path in the mainfest.

If you added parameters to a custom manifest , how would they get used?

How do you plan to run your program?
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Deployment issues

Postby ruperty » Sun Jul 13, 2014 8:19 pm

I've been trying a workaround by using this shell script on the EV3.

#!/bin/sh
JAVAHOME=/home/root/lejos/ejre1.7.0_55/bin
CLASSPATH=EV3Control.jar:jars/PCT.jar:jars/RobotControl.jar:jars/RobotControlEV3Impl.jar:/home/root/lejos/lib/ev3classes.jar:
/home/root/lejos/lib/dbusjava.jar:/home/root/lejos/libjna/usr/share/java/jna.jar
$JAVAHOME/java -cp $CLASSPATH uk.co.moonsit.app.EV3Control -xml /home/root/programs/configs/001-001-Sonic.xml


but get this error, so looks like I'm missing a linkage somehow.

Exception in thread "main" java.lang.ExceptionInInitializerError
at uk.co.moons.sensors.impl.UltrasonicSensorImpl.<init>(UltrasonicSensorImpl.java:20)
at uk.co.moons.sensors.USensor.<init>(USensor.java:40)
at uk.co.moons.control.neural.USensorNeuralFunction.init(USensorNeuralFunction.java:47)
at uk.co.moons.control.RobotControlHierarchy.initNeuralFunction(RobotControlHierarchy.java:179)
at uk.co.moons.control.RobotControlHierarchy.initRobot(RobotControlHierarchy.java:115)
at uk.co.moonsit.app.EV3Control.main(EV3Control.java:90)
Caused by: java.lang.UnsupportedOperationException: Unable to access EV3 hardware. Is this an EV3?
at lejos.internal.ev3.EV3DeviceManager.getLocalDeviceManager(Unknown Source)
at lejos.hardware.ev3.LocalEV3.<clinit>(Unknown Source)
... 6 more
Caused by: java.lang.UnsatisfiedLinkError: jnidispatch (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path
at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:711)
at com.sun.jna.Native.loadNativeLibrary(Native.java:688)
at com.sun.jna.Native.<clinit>(Native.java:109)
at lejos.internal.io.NativeFile$Linux_C_lib_DirectMapping.<clinit>(Unknown Source)
at lejos.internal.io.NativeFile.<clinit>(Unknown Source)
at lejos.internal.ev3.EV3DeviceManager.initDeviceIO(Unknown Source)


Any suggestions on how I resolve this?
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: Deployment issues

Postby gloomyandy » Sun Jul 13, 2014 8:35 pm

If you are going to write your own alternative to the jrun shell script, then you need to ensure you are including all of the functionality that it includes:
https://sourceforge.net/p/lejos/ev3sdca ... s/bin/jrun
in particular you must include the code to set the LD_LIBRARY_PATH. I'm not sure why you can't just use the jrun command to do all that your script is doing (seems all it does is modify the classpath and pass in a command line, both should be possible with jrun). Having said that you may find that you need to specify the classpath as part of the manifest, but I'm not totally sure about that.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4083
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Deployment issues

Postby lawrie » Sun Jul 13, 2014 8:37 pm

Look at jrun - http://sourceforge.net/p/lejos/ev3sdcar ... s/bin/jrun.

You are probably missing LD_LIBRARY_PATH
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Deployment issues

Postby lawrie » Sun Jul 13, 2014 8:41 pm

If you specify a -jar parameter to java (or jrun) it will use the main class and class path from the jar file manifest, otherwise it will use the ones from the command line. In both cases you can use parameters on the command line.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Deployment issues

Postby ruperty » Mon Jul 14, 2014 2:09 pm

lawrie wrote:The project org.lejos.ev3.example (one of the sample projects) has an ant build file. You would need to modify it to copy your external jar files to the EV3 and add a reference to them to the class path in the mainfest.

If you added parameters to a custom manifest , how would they get used?


As args to the main method.

How do you plan to run your program?


The standard way (runnable jar) is fine with me, but that wasn't working due to external jars.

But using ant build looks the way to go, I'll have a look into it.
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: Deployment issues

Postby ruperty » Mon Jul 14, 2014 5:32 pm

The wiki says there is a build.properties file in the org.lejos.ev3.example project, but I don't seem to have it. Where can I find it?
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: Deployment issues

Postby gloomyandy » Mon Jul 14, 2014 5:54 pm

No idea if it gets installed or not, but remember all of the leJOS source is online in git, always a good place to look for things...
https://sourceforge.net/p/lejos/ev3/ci/ ... 3.example/
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4083
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Ant build failure

Postby ruperty » Tue Jul 15, 2014 8:00 pm

As an intro to the ant build methodology I was trying the supplied files (see below) in org.lejos.ev3.example, but get this error. I did try adding the ev3classes.jar to the classpath in the ant config, but that didn't seem to help.

What am I doing wrong?

Buildfile: C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\build.xml

clean:
[delete] Deleting directory C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\build

compile:
[mkdir] Created dir: C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\build\classes
[javac] Compiling 1 source file to C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\build\classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:3: error: package lejos.hardware does not exist
[javac] import lejos.hardware.BrickFinder;
[javac] ^
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:4: error: package lejos.hardware does not exist
[javac] import lejos.hardware.Keys;
[javac] ^
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:5: error: package lejos.hardware.ev3 does not exist
[javac] import lejos.hardware.ev3.EV3;
[javac] ^
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:6: error: package lejos.hardware.lcd does not exist
[javac] import lejos.hardware.lcd.TextLCD;
[javac] ^
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:16: error: cannot find symbol
[javac] EV3 ev3 = (EV3) BrickFinder.getLocal();
[javac] ^
[javac] symbol: class EV3
[javac] location: class HelloWorld
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:16: error: cannot find symbol
[javac] EV3 ev3 = (EV3) BrickFinder.getLocal();
[javac] ^
[javac] symbol: class EV3
[javac] location: class HelloWorld
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:16: error: cannot find symbol
[javac] EV3 ev3 = (EV3) BrickFinder.getLocal();
[javac] ^
[javac] symbol: variable BrickFinder
[javac] location: class HelloWorld
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:17: error: cannot find symbol
[javac] TextLCD lcd = ev3.getTextLCD();
[javac] ^
[javac] symbol: class TextLCD
[javac] location: class HelloWorld
[javac] C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\src\org\lejos\ev3\example\HelloWorld.java:18: error: cannot find symbol
[javac] Keys keys = ev3.getKeys();
[javac] ^
[javac] symbol: class Keys
[javac] location: class HelloWorld
[javac] 9 errors
[javac] 1 warning

BUILD FAILED
C:\Versioning\Personal\Libraries\java\eclipse\EV3\org.lejos.ev3.example\build.xml:31: Compile failed; see the compiler error output for details.

Total time: 1 second



<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="org.lejos.ev3.example" default="upload">
<property file="local.properties" />
<property file="build.properties" />

<path id="libraries.path">
<fileset dir="${ev3.home}/lib">
<include name="*.jar"/>
</fileset>
</path>

<target name="clean" description="delete old files">
<delete dir="${build.dir}"/>
</target>

<target name="compile" depends="clean" description="compile the source ">
<!-- Compile the java code from ${source.dir} to ${classes.dir} -->
<mkdir dir="${classes.dir}" />
<javac
srcdir="${source.dir}"
includes="${source.include}"
excludes="${source.exclude}"
encoding="${source.encoding}"
source="${source.version}"
target="${target.version}"
destdir="${classes.dir}"
debug="true"
includeAntRuntime="false"
includeJavaRuntime="false"
verbose="false"
>
<classpath refid="libraries.path" />
<!-- enable warnings -->
<compilerarg value="-Xlint:${source.warn}" />
</javac>
</target>

<target name="jar" depends="compile">
<jar destfile="${output.jar}" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${class.path}"/>
</manifest>
</jar>
</target>

<target name="upload" depends="jar">
<scp todir="${credentials}@${ev3.host}:${programs.dir}" trust="true">
<fileset file="${output.jar}"/>
</scp>
</target>

<!-- generate javadocs -->
<target name="docs" description="generate javadocs">
<delete dir="${docs.dir}" />
<mkdir dir="${docs.dir}" />
<javadoc
destdir="${docs.dir}"
source="${source.version}"
encoding="${source.encoding}"
charset="utf-8"
locale="en_US"
author="true"
access="protected"
windowtitle="Project documentation"
verbose="false"
>
<classpath refid="libraries.path" />

<packageset dir="${source.dir}"
includes="${source.include}"
excludes="${source.exclude}"
/>
</javadoc>
</target>

<!-- zip the project -->
<target name="dist.zip" description="generate zip of sources">
<zip
destfile="${dist.zip}"
basedir="${basedir}"
includes="${dist.include}"
excludes="${dist.exclude}"
/>
</target>
</project>



# Tells eclipse editor that we have a custom config
custom = true

ev3.home=${env.EV3_HOME}

source.dir = src
source.include =
source.exclude =
source.encoding = utf-8
source.warn = all,-fallthrough,-deprecation
source.version = 1.6
target.version = 1.6
build.dir=build
classes.dir=${build.dir}/classes
docs.dir=${build.dir}/docs

main.class=org.lejos.ev3.example.HelloWorld
output.basename=HelloWorld
output.jar=${build.dir}/${output.basename}.jar

dist.dir = ${build.dir}
dist.zip = ${dist.dir}/dist.zip
dist.include =
dist.exclude = bin/**, ${build.dir}/** local.properties

# EV3 brick properties
ev3.host=10.0.1.1
lejos.home = /home/root/lejos
programs.dir = /home/lejos/programs
credentials = root:
class.path = ${lejos.home}/lib/ev3classes.jar ${lejos.home}/libjna/usr/share/java/jna.jar
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: Deployment issues

Postby gloomyandy » Tue Jul 15, 2014 8:47 pm

Do you have the EV3_HOME environment variable set correctly? Basically your javac classpath is not setup correctly and you need to work out why. You might find this of use...
http://stackoverflow.com/questions/2430 ... arget-if-s
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4083
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Deployment issues

Postby ruperty » Wed Jul 16, 2014 9:42 am

gloomyandy wrote:Do you have the EV3_HOME environment variable set correctly? Basically your javac classpath is not setup correctly and you need to work out why. You might find this of use...
http://stackoverflow.com/questions/2430 ... arget-if-s


The EV3_HOME environment variable is ok.

The problem seemed to be that the library path should have been

<path id="libraries.path"><fileset dir="${ev3.home}/lib/ev3">


rather than,

<path id="libraries.path"><fileset dir="${ev3.home}/lib">


I also had to get the jsch jar (from http://sourceforge.net/projects/jsch/files/jsch.jar/0.1.51/jsch-0.1.51.jar/download)
and refer to it as an external jars in the classpath tab of the ant build configuration, so that files were uploaded to the unit.
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Next

Return to EV3 Software

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

more stuff