Re: Maven build for sensor-vernier etc.

5 views
Skip to first unread message

Scott Cytacki

unread,
Jan 24, 2013, 12:59:05 PM1/24/13
to Charles Xie, org-concord-sensor, Saeid Nourian
It sounds like you are using the old sensor code.
The new sensor code is located here:

So you don't need thirdparty anymore.

The approach I use is to clone that repository with git on the command line.
Install the m2e support into eclipse, this can be found in the eclipse marketplace.
Then use the import the maven projects in eclipse.

I made a video where I'm doing these steps:

There are 2 caveats I can think of specific to you and Saeid:
- you might not have command line git setup since you are using windows. github.com provides a simple installer to set this up for you. You can probably also use the Eclipse egit plugin to do this, I haven't tried that yet.
- I think Saeid made some changes to the sensor projects specifically to get them to work with NetLogo.  Some of those same changes are in the sensor-projects on github, but some are not. I think many of these changes were not checked into a repository. If you need them, the best way would be to fork the sensor-projects github project and try adding the changes there. Then you can Saeid can share these changes, and I can more easily look at them. Also the code has changed somewhat since Saeid worked on it so the changes might not apply cleanly.




On Thu, Jan 24, 2013 at 10:48 AM, Charles Xie <qx...@concord.org> wrote:
Hi Scott:

I am trying to remember how to build your sensor package in Eclipse using pom.xml. I am not familiar with Maven. Can you give a hand? The packages involved are labquest-jna, sensor, sensor-examples, sensor-vernier, and I have imported thirdparty.

Do you have a web page for instruction?

Thanks,
Charles 



--
Scott Cytacki
The Concord Consortium

Scott Cytacki

unread,
Jan 24, 2013, 3:17:04 PM1/24/13
to Charles Xie, org-concord-sensor
It looks like the you don't have the sensor-vernier project in your classpath.
I'm not sure where you are putting the org.concord.frame.MRSensorService. Is it in a new project or are you sticking it in a existing project?

Just to get this to work, you can manually add the sensor-vernier and labquest-jna projects to the eclipse launcher classpath.

To manage dependencies correctly, org.concord.frame.MRSensorService should be in its own project and that project should be a maven project that specifies these dependencies: sensor-vernier and labquest-jna.


On Thu, Jan 24, 2013 at 1:43 PM, Charles Xie <qx...@concord.org> wrote:
Thanks. I have no problem checking out and building the project from GIT using Eclipse. There is no compilation error.

However, it seems the LabQuest device cannot be found (java.lang.ClassNotFoundException: org.concord.sensor.vernier.labquest.LabQuestSensorDevice). The follow is the code. Where did it go wrong?

private int deviceId = DeviceID.VERNIER_LAB_QUEST;
private SensorDevice device;
private JavaDeviceFactory deviceFactory;
protected volatile float[] data = new float[256];
protected Runnable shutdown;
private Window owner;

public MRSensorService() {
            ...
}

private void prepareDevice() {
deviceFactory = new JavaDeviceFactory() {
public void log(String message) {
System.out.println("DeviceTest: " + message);
}
};
device = deviceFactory.createDevice(new DeviceConfigImpl(deviceId, null));
}

Stack trace:

java.lang.ClassNotFoundException: org.concord.sensor.vernier.labquest.LabQuestSensorDevice
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.concord.sensor.device.impl.JavaDeviceFactory.createDevice(JavaDeviceFactory.java:179)
at org.concord.frame.MRSensorService.prepareDevice(MRSensorService.java:56)

Scott Cytacki

unread,
Jan 25, 2013, 12:37:13 PM1/25/13
to Charles Xie, org-concord-sensor
Both of the following options will put a jar in the target folder of the project.

If you have maven installed on the command line you can just run:
'mvn package' inside of the labquest-jna folder

From eclipse you can run the same thing by making a Maven Build run configuration:
Inline image 1


On Fri, Jan 25, 2013 at 12:04 PM, Charles Xie <qx...@concord.org> wrote:
The sensor projects work fine in Eclipse. However, when I include labquest-jna in a jardesc file, the resource folder in it somehow is placed outside the org package (see the following screenshot). As a result, when I try to run the jar file, it says that the DLL file is not found. The SVN version doesn't have this problem. Can you tell me how to include the labquest-jna package in a jar?
image.png

Scott Cytacki

unread,
Jan 25, 2013, 4:54:35 PM1/25/13
to Charles Xie, org-concord-sensor
That error code implies an invalid parameter was passed somehow.
Can you sign up for the org-concord-sensor google group:

And post the code you are using to initialize the sensor library?

Can you run the TestLabQuestDevice as a JUnit test in Eclipse? 
That will run some simple tests and print out info to the console.

On Windows you need to install the LabQuest device driver. However I'd expect it fail in a different way if you haven't done that.

Scott

On Fri, Jan 25, 2013 at 1:38 PM, Charles Xie <qx...@concord.org> wrote:
That seems to be working in terms of including the DLL folders.
... 
 
However, when the jar is run, a new problem occurred:


Loading sensor device: org.concord.sensor.vernier.labquest.LabQuestSensorDevice
error sending command: 54
org.concord.sensor.labquest.jna.LabQuestException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at java.lang.Class.newInstance0(Class.java:372)
        at java.lang.Class.newInstance(Class.java:325)
        at org.concord.sensor.labquest.jna.SingleThreadDelegator.invokeMethod(Si
ngleThreadDelegator.java:63)
        at org.concord.sensor.labquest.jna.SingleThreadDelegator$1.invoke(Single
ThreadDelegator.java:35)
        at $Proxy1.getSensorId(Unknown Source)
        at org.concord.sensor.vernier.labquest.LabQuestSensorDevice.getCurrentCo
nfig(LabQuestSensorDevice.java:149)
        at org.concord.frame.MRSensorService.run(MRSensorService.java:70)
        at org.concord.frame.MRFrame.main(MRFrame.java:76)
Caused by: org.concord.sensor.labquest.jna.LabQuestException: org.concord.sensor
.labquest.jna.NGIOException
        at org.concord.sensor.labquest.jna.LabQuestImpl.getSensorId(LabQuestImpl
.java:128)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.concord.sensor.labquest.jna.SingleThreadDelegator.run(SingleThrea
dDelegator.java:90)
Caused by: org.concord.sensor.labquest.jna.NGIOException
        at org.concord.sensor.labquest.jna.LabQuestImpl.sendCmdAndGetResponse(La
bQuestImpl.java:392)
        at org.concord.sensor.labquest.jna.LabQuestImpl.getSensorId(LabQuestImpl
.java:125)
        ... 5 more
LabQuest: closing
LabQuest: called close
LabQuest: claimed to close
Exception in thread "main" java.lang.NullPointerException
        at org.concord.sensor.impl.SensorUtilJava.experimentConfigToString(Senso
rUtilJava.java:70)
        at org.concord.sensor.impl.SensorUtilJava.printExperimentConfig(SensorUt
ilJava.java:64)
        at org.concord.frame.MRSensorService.run(MRSensorService.java:75)
        at org.concord.frame.MRFrame.main(MRFrame.java:76)
Closing LabQuestSensorDevice.
Exception in thread "Thread-5" java.lang.IllegalStateException: The thread has e
xited so no more methods can be called
        at org.concord.sensor.labquest.jna.SingleThreadDelegator.invokeMethod(Si
ngleThreadDelegator.java:47)
        at org.concord.sensor.labquest.jna.SingleThreadDelegator$1.invoke(Single
ThreadDelegator.java:35)
        at $Proxy1.close(Unknown Source)
        at org.concord.sensor.vernier.labquest.LabQuestSensorDevice.close(LabQue
stSensorDevice.java:103)
        at org.concord.sensor.vernier.labquest.LabQuestSensorDevice$1.run(LabQue
stSensorDevice.java:58)


Scott Cytacki

unread,
Jan 25, 2013, 5:08:39 PM1/25/13
to Charles Xie, org-concord-sensor
One thing that just came to mind is:
How are dealing with the JNA dependency?
The jar exporter in eclipse using the settings I described would not include the JNA classes. So I'm guessing you have JNA added a different way.
The sensor projects are currently using JNA version 3.5.1

If you are using an older version I'd guess that is what is causing the error.

Scott Cytacki

unread,
Jan 25, 2013, 5:16:12 PM1/25/13
to Charles Xie, org-concord-sensor
By works with Eclipse do you mean the JUnit test I suggested?

In that case, it is more evidence that the problem is the JNA version you are using with the exported jar file.


On Fri, Jan 25, 2013 at 5:12 PM, Charles Xie <qx...@concord.org> wrote:
What puzzles me is that it works fine with Eclipse. It is only the jar file that is exported that fails...
> --
> Scott Cytacki
> The Concord Consortium
> http://concord.org
>

--
Sincerely yours,

Charles Xie, Ph.D.
Resume: http://www.concord.org/~qxie
The Concord Consortium
Skype: charles.xie3
Blog: http://molecularworkbench.blogspot.com/
________________________________________________
Bridging the gap between research and education

Scott Cytacki

unread,
Jan 25, 2013, 10:09:41 PM1/25/13
to Charles Xie, org-concord-sensor, Saeid Nourian
On Fri, Jan 25, 2013 at 7:58 PM, Charles Xie <qx...@concord.org> wrote:
I finally got it. It is the JNA versioning problem. I used V3.0.9 inherited from SVN. After updating to 3.5.1, it works now.

Thanks for your help.

Great.
 


On Fri, Jan 25, 2013 at 5:08 PM, Scott Cytacki <scyt...@concord.org> wrote:
One thing that just came to mind is:
How are dealing with the JNA dependency?
The jar exporter in eclipse using the settings I described would not include the JNA classes. So I'm guessing you have JNA added a different way.
The sensor projects are currently using JNA version 3.5.1

If you are using an older version I'd guess that is what is causing the error.


Reply all
Reply to author
Forward
0 new messages