SO libraries not loading when running as Java web application - java

I searched a lot in So. But could not find a proper solution. Here is the problem
I have some .so files to load in my java application.
I created a Java class with main method and loading it using System.load();
System.load("/home/myfolder/TFS-SDK-11.0.0/redist/native/linux/x86_64/libnative_auth.so");
System.load("/home/myfolder/TFS-SDK-11.0.0/redist/native/linux/x86_64/libnative_console.so");
And then my Java codes. When I run the class as Java application, it is working fine.
Then I added the same code in my Java web application. And I run it in tomcat. But It is showing some error
Exception in thread "main" java.lang.UnsatisfiedLinkError
I found that this is because it is not loading the library files.
When I searched in google, I found some solutions but it didnt help me. I tried adding the so file location in
setenv.sh, catalina.sh in JAVA_OPTS. But none worked.
Some solutions I don't even understood.
Can someone give the step by step proces of
Where to put the so files in tomcat?
Which file I should edit and What should I add?
I searched a lot. But most answers I don't understand.

When you run your app in a web container such as Tomcat, your main method will NOT be called.
If you want to load these libraries when the container starts, then I'd suggest using a ContextListener.
Try googleing "context listener example in java" - you'll get plenty of hits and plenty of examples to follow.
You will probably also need to add these libraries on to your Unix Library Path. It's usually convenient to do this in your tomcat start up script. The name of the library path variable is unix flavour dependent, so I can't tell you what that path is I'm afraid.

Related

Loading an external class folder in eclipse - java

I am trying to use the LPsolver on a project I am working on. (it contains both jar and DLLs).
When I ran it locally it worked (System.loadLibrary("lpsolver"))
But now I am trying to upload it to an amazon server which is running tomcat.
I can't get the tomcat server to load class library correctly.
Tried to include it in all kind of different locations and loading it but non seemed to work.
Any idea how I can accomplish it ?
Thanks!
EDIT:
Tried lots of stuff I found on the web, mainly ways to include the class library I need inside the project and not a reference through the local vars.but my project does not seem to recognize it. Also wanted to upload it to my amazon web server ( to system32) but I guess because I use the free version that option is not included...

PlayFramework2: css not loading on heroku

I have a play2 application and have tried to deploy it on heroku .After deployment, the application does not have styles at all. I've re-tested the application on my local/dev machine and all is working fine.
So, Could some one told me how to fix play2 issues with css ?
Thanks to all, I've found problem and fixed it. So, short description:
After log analysis I've found some issues in urls like next path=/assets//stylesheets/style.css, so, after deleting one / symbol from url all is started working.
So, as conclusion , local version can work and load resources with additional / symbols in path but heroku cant.

Load jar file locally

Let's say I have a jar file and I want users to load it locally from the Internet... to speed up the loading I say... how would I go about doing that?
Like when you access it from http://mydomain.com... the jar file is from my documents/game/test.jar
Look up the URLClassLoader class, I think it will do what you want.
Here is a good description:
http://java.sun.com/developer/technicalArticles/Networking/classloaders/
EDIT: Forget it, Unsigned Applets cannot create ClassLoaders.
For an Applet you will need to download everything at once.
It is exactly the purpose of JNLP files (also called "Java Web Start"). Or I have misunderstood your problem...
You can find the official documentation on Oracle website : http://download.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/syntax.html
An example famous application using this system : SweetHome3D
I'm not sure if I understand your question, but it sounds like you want Java Web Start.
http://download.oracle.com/javase/tutorial/deployment/webstart/index.html
You would create a jnlp file, and put a link to it on your website. Java will take care of downloading the file and starting it. The .jar file would be stored in a cache, and it shouldn't need to be redownloaded unless the cache is cleared or you replace your old .jar file with a new one.

Build a JS server inside of Java for Google AppEngine

I just needed to create a little interface for a project. So I decided to take given code and to run it on Google AppEngine. My problem is, that I'm experienced in JavaScript and got some basic knowledge of Java, but I got no clue how a Java webapp has to be structured. I started Eclipse and installed the AppEngine-addon, downloaded Rhino and env.js (which is necessary for the bunch of code I need to run) but then found me in the situation of sitting on this files not knowing where to put them.
It would be great if someone could tell me in which directory to put which files for Rhino (I assume it's "/war/WEB-INF/lib/"), how to add the env.js-file and how to access all these files inside the .java-file which is the index of the app.
I don't know about app engine in particular, but I have had good success using Rhino jsc to compile script files which extend the Servlet API. The end result is a nice WAR file which you can deploy in any servlet container, and perhaps App Engine as well. See here for my relevant blog post about this technique, and here for a sample Eclipse project.
Have you taken a look at this tutorial on running Rhino on GAE?
It's a link from the official "Will it play in App Engine?" thread.
http://www.appenginejs.org/ may be of interest as well.

Help with IzPack - Creating Java and JNLP One Click Installations

I took the advice I've been given here to look at IzPack to create a JNLP based one click installation for computer illiterate clients who are using a Java desktop application I've created.
Java Web Start Driven Installation
However, I can't seem to find my way around it.
I don't know where to begin and seems the online tutorials are basic "look at the examples" which are themselves pre compiled and not sourced.
I want to create a simple form - be it in JSP or the JNLP install app (preferably JSP and the JNLP should get arguments from the JSP that launches it).
Then when the users click Install, the program installs to the default directory of userappdata with no questions (except for the UAC).
But IzPack seems to be forcing me to use panels and stuff... Not sure I want all of that.
Or maybe....
Hmmm, writing this just gave me an idea, but I'd still like some feedback.
Thanks.
Another approach perhaps?
If all what you need is to allow the user invoke a JAR, then consider using JSmooth to wrap it in an exe file. The exe file knows how to invoke java correctly and prompt the user to download if not present.
We also have used one-jar to wrap multiple jars in a single jar for exactly this purpose.

Categories

Resources