How to include external library to jetty (start jetty by using start.jar) - memcached

I am trying to use jetty-nosql-memcached as jetty session backend.
jetty-nosql-memcached: https://github.com/yyuu/jetty-nosql-memcached
After I compiled the jar and put the file "jetty-nosql-memcached-0.4.1-SNAPSHOT-jar-with-dependencies.jar" into the following folder,
$JETTY_HOME/lib or
$JETTY_HOME/lib/ext or
$JETTY_BASE/lib or
$JETTY_BASE/lib/ext
Then I try to start up jetty, all the above setup throws the following exception:
ClassNotFoundException: org.eclipse.jetty.nosql.memcached.MemcachedSessionIdManager
I tried with an param after starts.jar
e.g. java -jar start.jar jetty.home=$JETTY_HOME
it successfully loads the class, however, it does not read the $JETTY_BASE war file anymore. ($JETTY_HOME and $JETTY_BASE rested in different directories)
May I know what is the correct why to include an external library for Jetty?
Many thanks!
Add More information
Jetty version
9.1.0.v20131115

I figured out two ways to include external libraries
Add --lib=$EXTERNAL_LIB_LOCATION in the command line.
java -jar start.jar --lib=$EXTERNAL_LIB_LOCATION
Put the library in $JETTY_HOME\lib\ext, and start jetty in $JETTY_HOME
cd $JETTY_HOME
java -jar start.jar

Related

Run junit4 test from cmd

I tried to run junit4 test case from command line using:
java -cp junit-4.8.1.jar;test\Dijkstra;test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
but I got the following error:
java.lang.NoClassDefFoundError: graph/shortestgraphpath;
while the test case is working without any problems in eclipse.
Hint: in eclipse, shortestgraphpath was added in Referenced Libraries.
You need to the jar file containing shortestgraphpath to java class path.
java -cp junit-4.8.1.jar;test\Dijkstra; test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
The class path is the value that you pass to java with -cp so in your question you just supply junitand your compiled classes.
Try updating it with the jar file with the missing class.
java -cp junit-4.8.1.jar;<path to jar file>;test\Dijkstra;test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
You might have to add additional jar files as well. I recommend that you take a look at some build tool to help you build and run your java applications for example Maven, Gradle, Buildr.

java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging

I am trying to implement push notification for my app. i had set up the project in eclipse added google-play-services.jar in the java buildpath and checked it in order and export.so my app was working absolutely fine when i was doing registration with gcm and was getting the registration id from gcm too.but when i try to build my app from command line i am getting the below error
java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging
i added the google-play-services.jar in the classpath so the code compiled without any issue but at runtime i am getting the above exception.looks like its not able to find the jar at runtime. how can i make the jar available at runtime also please help.
Go to configure build path -> order and export and select(check box) the packages(jars).
No matter what the build path contains in eclipse, it has nothing to do with an application. All the jars have to be added to the classpath.
I would use the following command to start the application after build:
java -cp google.jar;jarA.jar;jarB.jar;jarC.jar -jar application.jar
After the -cp option fill in the semicolon separated list of jars that you use.

how to pass configuration file to scala jar file

I am using the typesafe config library in my code and then I generate a jar file. The application works fine when I embed the reference.conf file inside the jar. But is it possible to provide the config file as a parameter to the jar ? for example
java -DmyconfigFile=/dir/dir/reference.conf -jar myjar package.class.myobject.
Yes it is. See this thread on using an external akka config here.
java -Dconfig.file=/dir/dir/reference.conf -jar myjar package.class.myobject.

See OSGi bundles

I have Eclipse 3.8.1 and I want to see which OSGi bundles are started so I wrote in cmd from eclipse/plugins directory:
java -jar org.eclipse.osgi_3.8.1.v20120830-144521.jar -console
But nothing happens only empty line
Do I have to install something to see them?
If you have eclipse already running then you can access the Host OSGI Console from the Console view
UPDATE
I think this is what you are looking for
$ java -Dosgi.bundles=org.eclipse.equinox.console_1.0.0.v20120522-1841.jar#start,org.apache.felix.gogo.command_0.8.0.v201108120515.jar#start,org.apache.felix.gogo.runtime_0.8.0.v201108120515.jar#start,org.apache.felix.gogo.shell_0.8.0.v201110170705.jar#start -jar org.eclipse.osgi_3.8.1.v20120830-144521.jar -console
There are two options. These are as follows:
Create a configuration folder and put a config.ini file. Set the below content in the config.ini file:
osgi.console.enable.builtin=true
This will start equinox framework with the default console.
Or take the following steps. For details check: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fconsole_shell.htm
Place the necessary bundles in a folder. The bundles are:
org.apache.felix.gogo.command_0.8.0v<version>.jar
org.apache.felix.gogo.runtime_0.8.0v<version>.jar
org.apache.felix.gogo.shell_0.8.0v<version>.jar
org.eclipse.equinox.console_1.0.0v<version>.jar
org.eclipse.osgi.jar
Create a configuration subfolder and a config.ini file in it.
Add the following entries in the config.ini file:
osgi.bundles=./org.apache.felix.gogo.runtime_0.8.0v<version>.jar#start,\
./org.apache.felix.gogo.command_0.8.0v<version>.jar#start,\
./org.apache.felix.gogo.shell_0.8.0v<version>.jar#start,\
./org.eclipse.equinox.console.jar#start,\
osgi.console.enable.builtin=false
osgi.console=<port>
Start the Equinox framework with the following command line: java -jar org.eclipse.osgi.jar

Eclipse VM Argument and external JAR file error

I just added "-Djava.library.path=" to the "VM Arguments" under Run Configuration in Eclipse and everything works fine until I tried to add an external JAR file. I get the following error:
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
Am I not setting something properly in Eclipse?
If your interested I forked RXTXserial a while back since thier update "schedule" sucks. I have just ported it over to the Android platform too. We decided to move the native libs into the jar and use reflection to deploy them. The API is the same as RXTX, but everything just works. You can find jars and full project sources at:
http://code.google.com/p/nrjavaserial/
The exception indicates that the class gnu.io.RXTXCommDriver tries to load a native library, which would be named rxtxSerial.dll on Windows and rxtxSerial.so on Linux, and the JVM cannot find it in the directories listed in java.library.path. Have you tried to add a JAR containing the library to java.library.path? I don't think that's possible, it has to be a directory containing the extracted library file.
Appearently that external library has a dependancy with another class gnu.io.RXTXCommDriver
. Perhaps you will need to add that library to class path.