I'm tasked with integrating a collection of native libraries into a web application running in a Tomcat7 container.
I already found out that in order to be able to restart the application without restarting the whole server I must load the libs using the Tomcat "shared"-loader, outside the actual application.
For that I followed the accepted answer in this SO question: Shared JNI library (.so) in Tomcat - UnsatisfiedLinkError, but no luck so far.
As described I created a small "DLLBootstrapper" java class for loading the libs, compiled it and put it in "CATALINA_HOME/shared/lib" next to the libs I'm loading.
In the "catalina.properties" I set the path of the "shared.loader" to that folder.
However when I try to obtain the "DLLBootstrapper" in my application using Class.forName("msm.DLLBootstrapper"); I get a java.lang.ClassNotFoundException: msm.DLLBootstrapper.
What am I missing here?
Edit:
Sorry, forgot to mention java.library.path is set to the CATALINA_HOME/shared/lib folder.
Related
I am trying to access a JAX-WS 2.2 service from Tomcat6 with Java6. For what I have researched there is a problem with this, as Java tries to use first some of its default javax.xml.ws libraries which doesn't have the WebFault.messageName method. So it fails with this error:
GRAVE: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
at com.sun.xml.ws.model.RuntimeModeler.processExceptions(RuntimeModeler.java:1162)
...
The solution seems to be creating an "endorsed" directory in JAVA_HOME/jre/lib/ (or in TOMCAT_HOME) and putting there the required libraries.
However, some people say the library needed is webservices-api.jar, for example, here (#Issue 3):
https://www.fromdev.com/2010/01/trying-to-run-jax-ws-sample-application.html
And other people talk about jaxb-api-2.2.jar and jaxws-api.jar, for example here:
Grizzly - java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName
I have downloaded all three of them and placed them in both directories (inside JAVA_HOME and TOMCAT_HOME).
My problems:
· I have no issues accessing this service from a standalone java6 application, both from Netbeans or running the .jar from command-line, it fails only from Tomcat. So I am not sure if the stated above is the cause of my problems. Because, shouldn't it also fail from command line?
· I am not being able to test the above solutions, because Tomcat does not seem to know the "endorsed" directory. When I run this in the standalone application:
System.out.println(System.getProperty("java.endorsed.dirs"));
It prints:
/usr/lib/jvm/jdk1.6.0_45/jre/lib/endorsed
However, Tomcat prints a blank line.
I have tried to modify tomcat6.conf, with this (and restarting, of course):
JAVA_OPTS="-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -Djava.awt.headless=true -Xms1024m -Xmx1024m -XX:PermSize=1024m -XX:MaxPermSize=1024m"
But it still doesn't seem to know that property.
So, how can I tell Tomcat where the endorsed directory is located? Do you think that my problem can be another than the stated, as it works from a standalone application?
So, the solution:
Do you think that my problem can be another than the stated, as it works from a standalone application?
No, that was exactly the problem.
how can I tell Tomcat where the endorsed directory is located?
It seems that setting this option in tomcat6.conf:
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
is not enough. It is required to create a variable called JAVA_ENDORSED_DIRS. So these two lines are needed in tomcat6.conf:
JAVA_ENDORSED_DIRS="/usr/share/tomcat6/endorsed"
JAVA_OPTS="-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS [-Djava....]"
Not really well documented issue, I think.
I have been working on creating a simple Java desktop app using the RESTful API for Business Objects and have run into an issue. Whenever I run my app in Eclipse in works fine; whenever I export it as a 'Runnable Jar' and select the Library handling option 'Package required libraries into generated JAR' it works fine. However, whenever I try to export it using the Library handling option 'Extract required libraries into generated JAR' I get the following error after running the app:
java.lang.NoClassDefFoundError: Could not initialize class com.businessobjects.bcm.BCM
I have the 'bcm.jar' file added under a 'res' Source Folder and have it added to the Build Path. At one point I added all the JARs under the 'SAP BusinessObjects' java folder, and external folder, but it still throws the error. The problem stems from this line of code:
enterpriseSession = CrystalEnterprise.getSessionMgr().logon(userID, password, CMS, auth);
Would anyone know why I am getting said error? I really want to use the Extract option as it will improve performance as my app becomes larger. Any help resolving this issue would be greatly appreciated :)
EDIT: I would be happy to provide clarification or further detail upon request!
Seems this was introduced in SP04 and SAP has no intent of fixing it as the RESTful API wasn't designed to be used with Desktop apps.
Have you included the cryptojFIPS.jar? Leaving it out can cause the error.
I'm working on the client side of a project that is using DropWizard. Unfortunately what I'm experiencing is that for me to make a change to assets I have to stop the server, package the assets with maven, and then rerun the server or the assets will not be updated.
I tried adding dropwizard-configurable-assets-bundle but I'm still seeing the same behavior. Here's the service after adding it:
Service.java
public void initialize(strap<ServiceConfiguration> strap) {
// Assets
strap.addBundle(new ConfiguredAssetsBundle(
"/dashboard/app/", "/dashboard/", "index.html"
));
// Redirect /dashboard to /dashboard/
strap.addBundle(new RedirectBundle(ImmutableMap.<String, String>builder()
.put("/dashboard", "/dashboard/").build()));
}
I'm currently running mvn package && java -jar target/pack.jar server config.yml. I tried using Eclipse but I was having to restart it manually and it wasn't repackaging for me so it was slowing things down even further.
This whole process is reaaaally slowing me down and I'm hoping it's just my ignorance to the world that is Java.
In my Intellij Idea, i am using JRebel plug-in for this purpose. JRebel also supports Eclipse.
If your assets are packaged under src/main/resources then they should just update automatically with Eclipse without a restart being required, so long as you're running the executable service main() from within the IDE.
You may need to check that your Maven plugin is set to "generate-resources" on changes but that is just the default setting so should be in place already.
What you're describing is definitely possible in Eclipse - I have personal experience of making resource changes (e.g. change and save an HTML asset) and then seeing an immediate update upon doing nothing more than a browser refresh.
I'm getting ClassNotFoundException on Class.forname("com.mysql.jdbc.Driver")
I'm using Windows Vista 64-bit, Eclipse Galileo, GWT framework. I downloaded mysql-connector-java-5.1.6-bin, but what is the exact path I should put this file in? I'm getting this exception while I'm in gwt-projects, but in normal projects it works good. Any idea how that should be done?
Finally its worked, the problem was not in the classpath, but from the .jar file itself, im using mysql-connector-java-5.1.6-bin which was not working, but when i tried mysql-connector-java-3.0.17-ga-bin everything works good, i hope to fix the new version soon
anyway thanks BalusC for helping :)
Just put the JAR file in the runtime classpath of the application in question.
In case of a Servlet based webapplication, you normally put it in /WEB-INF/lib folder. It's by default covered by the webapp's runtime classpath.
Disable Google App Engine. Its a setting in Eclipse.
Google App Engine doesn't allow you to open Sockets. When you try to load the JDBC driver, it makes a socket connection in a static block. An exception in the static block leads to a ClassNotFoundException, which is what you are seeing.
I've created a GWT project using Eclipse which was working perfectly (I was able to run it in both Hosted Mode and on Google App Engine) until I tried to import the Gears API for Google Web Toolkit. After adding the following line to my java source file:
import com.google.gwt.gears.client.geolocation.Geolocation;
I get the following error when I try to compile:
19-Jun-2009 3:36:09 AM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed com.google.apphosting.utils.jetty.DevAppEngineWebAppContext#1c7d682{/,C:\Documents and Settings\Geoff Denning\workspace\TaskPath\war}
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
I've already added the gwt-gears.jar file to my \war\WEB-INF\lib directory, and I've referenced it in Eclipse as follows:
I've even opened the gwt-gears.jar file and confirmed that org/apache/xerces/jaxp/SAXParserFactoryImpl.class does exist. Can anyone give me any pointers as to why I'm getting the above error?
Check that Xerces exists in:
$JAVA_HOME/lib/endorsed
Sounds like a Java 5 issue. Also check the Java system property for:
javax.xml.parsers.SAXParserFactory
It should be:
org.apache.xerces.jaxp.SAXParserFactoryImpl
If not then that's your issue, make sure you set the system property.
Apparently this is a bug in jre 1.5. I was able to resolve the problem by switching my default JRE in Eclipse from 1.5.0_06 to 1.6.0_03, as shown below:
Thanks to Jon and Rahul for pointing me in the right direction.
This happened to me. I had conflicting JARs in my workspace. I removed one and boom it worked. The message didn't lend very well to the root of the error.
My SAXParserFactoryImpl problem was caused by gwt-gadgets.jar I had in my boot class path. Removing this JAR from the boot class path solved the problem for me. Basically you have to remove any JAR containing a SAXParserFactoryImpl class from your build path (user libs).
Remove the $JAVA_HOME/jre/lib/jaxp.properties fixed the issue.
Take a look at Trouble with Selenium (XercesImpl) and Google App Engine.
I had a similar problem with GWT / GAE (SAXParserFactoyImpl not found) and solved it by;
Importing the jar to war/WEB-INF/lib
Adding the jar to the build path