How to use matlabcontrol api and jboss - matlab

thanks in advance for attention.
It's the first time i am writing on this site (quite newbie :) )
I previously read question of a user asking for my same problem. Although i read a lot i could not find a solution.
Problem:
I am trying to use MatlabControl jar (http://code.google.com/p/matlabcontrol/) to "call" matlab within my java code.
When i try this api within a normal java application to try it (including matlabcontrol.jar in the buildpath) everything works perfectly.
My issue is to make it work on an ejb module with jboss 5 AS:
i can deploy the ejb module and i can see classes of the matlabcontrol.jar (which i put in server/default/lib folder), but it is not working and is returning me the following exception:
Caused by: java.lang.NullPointerException
at java.io.File.<init>(File.java:251)
at matlabcontrol.Configuration.getSupportCodeLocation(Configuration.java:227)
at matlabcontrol.RemoteMatlabProxyFactory.createProcess(RemoteMatlabProxyFactory.java:278)
at matlabcontrol.RemoteMatlabProxyFactory.requestProxy(RemoteMatlabProxyFactory.java:116)
at matlabcontrol.RemoteMatlabProxyFactory.getProxy(RemoteMatlabProxyFactory.java:134)
at matlabcontrol.MatlabProxyFactory.getProxy(MatlabProxyFactory.java:81)
that lead me to the following lines:
URL url = Configuration.class.getProtectionDomain().getCodeSource().getLocation();
File file = new File(url.toURI().getPath()).getCanonicalFile();
The very strange thing is that very very rarely, after restarting jboss and re-deploying the ejb module, the system works!.
I really don't know if i have to modify the source code of these last 2 lines (as if it is a problem of not properly getting the location of the jar code) or to set some configuration files of jBoss to set the classpath differently.
Thanks again in advance.
Any help would be very appreciate.

The mistake was in the code to find the location of the jar at runtime.
I printed the path, which ended with "!" and double slash, so I removed these chars and I was finally able to make this API work.

Related

Problem while trying to execute ant file in java

I'm trying to compile a service using a java ant file as appears below:
and my buid-jar.xml looks like this:
the problem i have is that eclipse is not recognizing the enviroment variables and it takes the names literally causing an error on building time:
Both, paths and ant files does exists in these routes in my user folder, but i don't know why this error is happening. I'm using jdk 1.8.0_45.
Any idea? Sorry i had to attach screenshots instead code, but the proxy of the company network that i work for doesn't allow me to navigate on stackoverflow.

Native library in Tomcat UnsatisfiedLinkError + Windows + eclipse

This question might have been asked earlier on SO, and please be assured I did check all the available solutions. Was still unable to get it to run
My problem is exactly as described in this post Shared native library in Tomcat UnsatisfiedLinkError
Standalone Java application is running perfectly well. However with Tomcat(9) it fails to run and throws
java.lang.UnsatisfiedLinkError: third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init()V
at third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init(Native Method)
at third_party.org.chokkan.crfsuite.crfsuiteJNI.<clinit>(crfsuiteJNI.java:87)
at third_party.org.chokkan.crfsuite.Tagger.<init>(Tagger.java:39)
I know that my DLL is being loaded, also I checked that the folder my dll is in, is in the PATH variable. I have also checked the classes being loaded and the DLL is infact being loaded.
I have noticed 3 types of UnsatisfiedLinkError at SO
1) java.lang.UnsatisfiedLinkError: third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init()V
2) java.lang.UnsatisfiedLinkError: third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init()B
3) Where the class loader is loading twice.
I believe the V , at the end does signifies something. But I am not able to figure out exactly what?
One of the accepted answers in the SO post I shared above claims it has something to do with version. I do not understand how is that an acceptable solution since it works perfectly well when run as a standalone java application.
Wasted a lot of time already, any help is appreciable.
Thanks
Chahat
I faced with the same issue. I finally find the solution. It works for me.
First, I instaled libLBFGS and crfsuite. You can find the instruction here (http://www.chokkan.org/software/crfsuite/manual.html). The libcrfsuite.so will be install in /usr/local/lib
Second, I edit tomcat config in order to load native library. I create setenv.sh in tomcat bin folder, set CATALINA_OPTS variable with content :
export CATALINA_OPTS="-Djava.library.path=/usr/local/bin:/usr/local/lib"
Finally, I used custom ServletContextListener and explicitly load libcrfsuite.so by System.load(). I go this link to download lib (https://github.com/vinhkhuc/jcrfsuite/tree/master/src/main/resources/crfsuite-0.12)
I had a similar problem but not with Tomcat.
I ended up copying the logic from one of their classes and simply invoking:
static {
try {
CrfSuiteLoader.load();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

Eclipse does not recognize my changes in src folder, throws the same error

I'm having a hard time using eclipse because of the following issue.
It goes like this. I'll code and try to run it. Then, it will throw some errors (of any kind). And so, after I have changed a part of the code, comment out which codes I suspect makes the error, or delete something, I then restart the websphere application server in order to republish my work. Next is to test my work using SoapUI then all of a sudden eclipse throws an error which is the same as before. I've tried to search in here answers to this questions but it involves codes which don't need in my project and also answers that I can't understand well (since I am very new to programming). However, I have found a way to resolve this but it's very inconvenient. To be able for eclipse to detect changes in the src folder, I should restart eclipse after editing my codes then remove my project in the server, start the server and then publish my work in websphere all over again. It solves my problem but I do all of these stuff every now and then even if I only comment out a single line in the code. What I want is to avoid doing this process of resolving the issue since it consumes so much of my time whenever I republish the project in the server.
Can somebody help me with this? Any suggestions would be very helpful. Thanks a lot!
It is a bit strange that you need to restart eclipse. The normal way would be to just re run your application server.
Try only he 3 second steps you mentioned (remove my project in the server, start the server and then publish my work in websphere) and if that works try again without removing the project. Just restart the servers.
And let us know if that worked!

mobicents jain slee hello world serivce for beginner

I am trying to build a simple jain slee project by following the steps given here
https://developer.jboss.org/wiki/HelloSLEEWorldServiceJAINSLEETutorial
but when i try to create a service i get an error message error message scr shot
can anyone help me
This question is quite old, but I will answer nevertheless for future visitors' sake.
The issue is with the Eclipslee service creation plugin. Can you install one from here and try to create the service again.
If not find the plugin jar file named;
org.mobicents.eclipslee.servicecreation_2.0.0.v20130704-2333.jar
This is the one I use. But I think the 2.0.0.FINAL should do the job. I can't upload the exact file because I don't remember where I got it from. Probably a forum somewhere or an issue tracker thread. But can't quote the source properly. :(
P.S.(in case you didn't know) Installation == Copying the jar file to the plugins directory in Eclipse.
edit:
This is another workaround. v2.0.0 apparently does not work too.

gwt module does not load on gae

on a particular page on our site http://www.sakshum.org/ui/page/JoinUs.jsp which is build using gwt and deployed on GAE the module does not load.
This works fine in development env in eclipse and have no errors when looking via firebug in the console.
Please advise what may be wrong here and how to fix it?
look at the AE logs. firebug will only show you client side stuff. It's probably a classpath issue -- such as you have something locally but aren't uploading that jar ...etc.
Edit:
please post your JoinUs.jsp
I am calling my gwt module via a jsp page on AE no problem. Maybe the path in your script tag pointing to the *.nocache.jsp file is off somehow. Usually when things resolve locally but not on AE, for me, the problem was appengine-web.xml and setting include and exclude paths. I had to be careful there because things worked differently locally and deployed - especially using wildcard.
Also, look for uri errors under the dashboard (ae administration page). static resources that are not found will show there and not in the ae log since they are static.
Thanks all for the help. So, the issue was completely different. Actually the div tag was not rendering at all due to the coding error of a if statement in the jsp. On fixing that it started working