Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » shared native library
shared native library [message #638837] Fri, 12 November 2010 17:43 Go to next message
Stefan Harjes is currently offline Stefan HarjesFriend
Messages: 3
Registered: November 2010
Junior Member
Hi,

I am writing a java servlet which I deploy using tomcat-6. It uses native C++ code for USB access.
Depoying by hand works fine. The wrapper .jar goes to CATALINA_BASE/lib and the library libnative.so is placed in CATALINA_BASE/shared/lib. I can deploy the eclipse war file, but when I start the eclipse tomcat instance, I get an error that the native library is not in the java.library.path.

In the tomcat-6 system instance I add -Djava.library.path in the config files. Is there any way to do this in eclipse??

Best

p.s. I tried the native library entry in the Deployment Assembly properties without success



Re: shared native library [message #638844 is a reply to message #638837] Fri, 12 November 2010 18:02 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 2010.11.12 10:43, Stefan Harjes wrote:
> Hi,
>
> I am writing a java servlet which I deploy using tomcat-6. It uses
> native C++ code for USB access.
> Depoying by hand works fine. The wrapper .jar goes to CATALINA_BASE/lib
> and the library libnative.so is placed in CATALINA_BASE/shared/lib. I
> can deploy the eclipse war file, but when I start the eclipse tomcat
> instance, I get an error that the native library is not in the
> java.library.path.
> In the tomcat-6 system instance I add -Djava.library.path in the config
> files. Is there any way to do this in eclipse??
>
> Best
>
> p.s. I tried the native library entry in the Deployment Assembly
> properties without success

As a total shot in the dark, does the following link help?

http://www.javahotchocolate.com/tutorials/jni.html#a_native
Re: shared native library [message #638847 is a reply to message #638844] Fri, 12 November 2010 18:30 Go to previous messageGo to next message
Stefan Harjes is currently offline Stefan HarjesFriend
Messages: 3
Registered: November 2010
Junior Member
Hi Russel,

thanks for the quick response, I tried the tip, but got the
same error. I also tried to add the native library to other
jars without success.

Do you by any chance know if the eclipse tomcat makes a copy of the tomcat system libraries (if so where)?

Best
Re: shared native library [message #638882 is a reply to message #638847] Fri, 12 November 2010 21:19 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 2010.11.12 11:30, Stefan Harjes wrote:
> Hi Russel,
>
> thanks for the quick response, I tried the tip, but got the
> same error. I also tried to add the native library to other jars without
> success.
> Do you by any chance know if the eclipse tomcat makes a copy of the
> tomcat system libraries (if so where)?
>
> Best

I may not be the best resource on this. What version of Eclipse are you
developing in?

In Eclipse, you're going to use Build Path to make known the libraries
you're using. In my example, which didn't use Tomcat so there may be a
difference, I made the path to the JNI (shared object) known to the one
JAR that consumed it. Eclipse did the rest such that, when flexlm.jar
code went to open it, it was there.

Eclipse sort of makes copies of the Tomcat libraries. The way Eclipse
deploys the application inside Eclipse (for debugging, running, etc.) is
to copy everything as if really deploying it to the path:

<workspace> /.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpweba pps/...

where "..." is what you'd expect to find under Tomcat's webapps
directory. So, for the JARs, this would be
<application-name>/WEB-INF/lib. What you'll find there is all the
libraries you signed up for in Build Path including the Tomcat ones:

http://www.javahotchocolate.com/tutorials/tut-images/web-app -libs.png

....and all of the others (in this case, Hibernate, MyFaces JSTL, Log4j,
etc.) that aren't shown in this illustration.

Last, this is influenced by marking a lot of the JARs in Build Path as
"Java EE Module Dependencies" as shown here. However, this stopped being
done this way in Galileo. It's done differently in Helios and I don't
know if that's relevant here.


http://www.javahotchocolate.com/tutorials/tut-images/web-app -module-dependencies.png

I'm not sure I'm helping you, but perhaps knowing this and comparing it
to what you see will jar something in your mind (no pun intended).

Russ
Re: shared native library [message #639178 is a reply to message #638837] Mon, 15 November 2010 14:34 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 11/12/2010 12:43 PM, Stefan Harjes wrote:
> Hi,
>
> I am writing a java servlet which I deploy using tomcat-6. It uses
> native C++ code for USB access.
> Depoying by hand works fine. The wrapper .jar goes to CATALINA_BASE/lib
> and the library libnative.so is placed in CATALINA_BASE/shared/lib. I
> can deploy the eclipse war file, but when I start the eclipse tomcat
> instance, I get an error that the native library is not in the
> java.library.path.
> In the tomcat-6 system instance I add -Djava.library.path in the config
> files. Is there any way to do this in eclipse??
>
> Best
>
> p.s. I tried the native library entry in the Deployment Assembly
> properties without success
>
>
>
>

Open the Tomcat server's launch configuration per:

http://wiki.eclipse.org/WTP_Tomcat_FAQ#How_can_I_view_or_mod ify_the_launch_configuration_properties_for_a_Tomcat_server. 3F

You can set what you need there. You can set a java.library.path
directly in the VM Arguments on the Arguments tab. Also, I typically
override the PATH environment variable on Environment tab and allow Java
to build a default java.library.path, which includes the PATH entries.

For details about the WTP Tomcat support, see the other info in the
Tomcat FAQ, especially:

http://wiki.eclipse.org/WTP_Tomcat_FAQ#When_I_create_a_new_T omcat_server.2C_what_should_I_know_about_its_default_configu ration.3F

Cheers,
Larry
Re: shared native library [message #639503 is a reply to message #639178] Tue, 16 November 2010 18:53 Go to previous message
Stefan Harjes is currently offline Stefan HarjesFriend
Messages: 3
Registered: November 2010
Junior Member
Great!

thanks, that was exactly what I was looking for!

Must have missed it in the first encounter steep learning curve

Best

Stefan
Previous Topic:Helios jar with Main-class attribute in manifest only deploys to one location
Next Topic:Eclipse - Cannot create a Tomcat 6.0 Server
Goto Forum:
  


Current Time: Fri Mar 29 09:50:04 GMT 2024

Powered by FUDForum. Page generated in 0.02622 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top