Unable to start Spring Boot executable jar using IBM JRE 1.8 - spring-boot

We have a Spring Boot application which is built as an executable jar and runs fine using both the Oracle and OpenJDK JREs (using 1.8 versions).
Attempting to run it using the IBM 1.8 JRE however results in the following error at the command line.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This occurs if we execute the jar (using ./application.jar) or using java -jar application.jar
This led us to change the packaging to not make the jar executable and this allows us to start the application using java -jar application.jar. So it appears the IBM JRE doesn't like the launch script.
The problem is we don't want to have two packaging methods for different deployment environments, if possible.
Does anyone have any experience of why the IBM JRE doesn't like the script on the front of the jar file and whether there are any command line options to disable whatever checking its doing?

From your post it is unclear if you have problem with
1) running jar from Linux like chmod a+x application.jar and executing
Or
2) running via /opt/IBM/java/jre/bin/java -jar application.jar
For option 1) it is not a good idea as you do not explicitly choose jvm binary and rely on OS to choose one for you.
Read about binfmt_misc mechanism:
https://en.m.wikipedia.org/wiki/Binfmt_misc
For option 2)-it might be class loading problem, please add
/opt/IBM/java/jre/bin/java -verbose:class -jar application.jar
and consult documentation here: https://www.ibm.com/developerworks/library/j-dclp1/index.html

Related

No main manifest attribute found in Corda Standalone Shell jar of Corda Enterprise v4.0

I want to evaluate Corda Standalone Shell of Corda Enterprise v4.0.
I have downloaded corda-shell-4.0.jar from below URL
https://www.r3.com/corda-enterprise-download/
And refering to below document
https://docs.corda.r3.com/releases/4.0/shell.html?highlight=standalone%20shell#the-standalone-shell I am analysing the Standalone Shell and when I run java -jar corda-shell-4.0.jar command then I get the following error:
no main manifest attribute, in corda-shell/corda-shell-4.0.jar
When I checked the MANIFEST.MF file then there is no Main-Class specified in the Manifest file.
Can anyone please guide me how to use the standalone shell?
Have a read of this - https://docs.corda.r3.com/releases/4.0/cli-application-shell-extensions.html .
It the jar is not meant to be run via java -jar. Instead, you install the CLI commands and need to set up some config to get it all to work.

Spring boot running a fully executable JAR and specify -D properties

The Spring Boot Maven and Gradle plugins can now generate full executable archives for Linux/Unix operating systems.Running a fully executable JAR is as easy as typing:
$ ./myapp.jar
My question is in this case how to set -D properties, e.g.
-Dspring.profiles.active=test
In addition, if server does not install jdk , could this fully executable jar still run?
There are two ways to configure properties like that:
1:
By specifying them in a separate configuration file. Spring Boot will look for a file named like JARfilename.conf which should be stored in the same folder like the JAR file. There you can add the environment variable JAVA_OPTS:
JAVA_OPTS="-Dpropertykey=propvalue"
2:
Or you can just specify the value for the environment variable in the shell before you execute the application:
JAVA_OPTS="-Dpropertykey=propvalue" ./myapp.jar
Have a look at the documentation for the complete list of available variables: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#deployment-service
Regarding your second question: To execute a JAR, you don't need a JDK, a JRE is sufficient (but you need at least that, if you don't have any java installed on the server, the application won't run).
By default SpringApplication will convert any command line option arguments (starting with ‘--’, e.g. --server.port=9000) to a property and add it to the Spring Environment. As mentioned above, command line properties always take precedence over other property sources.
e.g.
$ java -jar myapp.jar --spring.application.json='{"foo":"bar"}'
please see http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/

Start Equinox from Windows prompt

I want to start the latest Equinox framework but I'm stuck. I downloaded the latest version and tried to execute the command into windows prompt:
C:\equinox\plugins>java -jar org.eclipse.osgi_3.10.100.v20150529-1857.jar -console
But nothing happens. Do you know how I can start the framework?
EDIT
I downloaded launchers-win32.win32.x86_64.Mars.zip
C:\equin\eclipse\plugins>java -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dosgi.console.enable.builtin=true -jar org.eclipse.equinox.la
uncher_1.3.100.v20150511-1540.jar -console
An error has occurred. See the log file
c:\equin\eclipse\configuration\1435578389939.log
C:\equin\eclipse\plugins>
In error log I get this:
!SESSION Mon Jun 29 14:44:18 IDT 2015 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2015-06-29 14:44:18.529
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.RuntimeException: Could not find framework
at org.eclipse.equinox.launcher.Main.getBootPath(Main.java:1025)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Looks like starting standalone Equinox is very tricky.
It seems that sadly the build-in console is removed in equinox 3.10 so the osgi.console.enable.builtin=true system property will not work. It was useful when someone wanted to start equinox with a console rapidly, without adding any more bundles.
To use the gogo shell, there are many tutorials. In short:
Download the following artifacts (they are in the zip of Equinox Mars):
org.eclipse.equinox.console_1.1.100.v20141023-1406.jar
org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar
org.apache.felix.gogo.shell_0.10.0.v201212101605.jar
org.apache.felix.gogo.command_0.10.0.v201209301215.jar
Run the command:
java -Declipse.ignoreApp=true -Dosgi.bundles=reference:file:org.eclipse.equinox.console_1.1.100.v20141023-1406.jar#start,reference:file:org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar#start,org.apache.felix.gogo.shell_0.10.0.v201212101605.jar#start,org.apache.felix.gogo.command_0.10.0.v201209301215.jar#start -jar org.eclipse.osgi_3.10.100.v20150529-1857.jar -console -consoleLog
Alternatively, you can specify osgi.bundles in the config.ini file of equinox if there is one.
You can put the necessary jars into a subfolder. In that case, you must use the relative path after reference:file:. E.g.: reference:file:lib/myjar.jar.
Edit
I uploaded two samples (one with config.ini and one without) to here: https://drive.google.com/file/d/0B1GigvByKQkIbFRqbjFvbmNYdk0/view?usp=sharing
There are pre-configured Equinox OSGi Starter Kits available from eclipse itself. They are somehow tricky to find. Open the Equinox Project Download page and click on the blue triangle for OSGi starter kits.
Then you can download them for your platform. They have native executables but also valid configuration for "java -jar ..." executions.

JDBC Driver class not found: oracle.jdbc.OracleDriver

I have installed a third party java webservice which uses Oralce jdbc thin driver to write data into Oracle database. When i run this, i get the following error;
JDBC Driver class not found: oracle.jdbc.OracleDriver
I have oracle installed and set classpath variable to following value:
*D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar*
and path variable to following value;
*D:\oracle\product\10.2.0\client_1\bin;C:\Program Files\Java\jdk1.7.0\bin\;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip*
Any suggestion why web service is not able to identify jdbc driver?
Thanks
I know 2 ways of turning Java app into Windows service and both do not use CLASSPATH. One is Java Service Wrapper by Tanuki Software. This tool uses wrapper.conf where you can show directories with .jar libraries:
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=c:\jars\*
wrapper.java.classpath.2=myservice.jar
Second tool I know is JSL: Java Service Launcher. In this tool there is jsl.ini where you put command line to run your server. It can use java with -cp option to show location of .jar libraries:
[defines]
MY_LIBS=d:\jars\*
AXIS_LIBS=d:\axis2-1.5.4\lib\*
CLASSPATH=.;%MY_LIBS%;%AXIS_LIBS%
export = CLASSPATH
...
[java]
...
cmdline = -Dfile.encoding=utf8 -cp %CLASSPATH% example.my.server
In both configuration you can use * to add all .jar files or you can show those files one by one (just like in CLASSPATH).
At first you should know what Windows is trying to execute. Check it in the service properties page. Then try to localize its configuration. If it uses one of tools I know then you know what to change. Other tools probably have similar configuration.
Method 1:
Download ojdbc.jar
add ojdbc6.jar to deployment assembly.
Right click on project->properties->select deployment assembly->click on 'Add'
->select 'Archives from File System'->browse to the folder where ojdbc6.jar is saved.->add the jar->click finish->Apply/OK.
Method 2:
if you want to add ojdbc.jar to your maven dependencies you follow this link:
http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/
.
.
Even if you're using a maven project it is not necessary to add ojdbc to maven dependencies(method 2), method 1 (adding directly to deployment assembly) works just fine.
Make sure you have the ojdbc jar file (make sure you are using the correct one because depending on java version you may need to choose a different one).
use ojdbc14.jar for Java 1.4
use ojdbc5.jar for Java 1.5
ojdbc6.jar for Java 1.6
here is linke where you can download ojdbc6.jar file
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
You also have to add the jdbc jar to your server classpath. if tomcat, rigth-click on your Project->run as->run configurations, click on classpath and add your jdbc jar in Add external jars option
add ojdbc-6.jar to your lib directory of tomcat installation. Maven will downlowd this jar for you in .m2 directory, but you need to have this jar in tomcat lib as well.

Jetty server for Windows

Can the Jetty server run on Windows-based environments. If there is a Windows installable, can someone please point me to it?
I found a good tutorial and the quick start documentation on the installation of Jetty in a windows environment. It's not simply an installer, but you merely unzip the files into a folder and run the command:
java -jar start.jar
in the folder where you unzipped it to start the server.
Jetty downloads
Reference: Jetty Quick Start
Updated:
1 – Downloading
You can download Jetty from two sources: Eclipse or Codehaus.
http://jetty.codehaus.org/jetty/
http://www.eclipse.org/jetty/downloads.php
2 - Simply uncompress the file to a directory.
3 – Running Jetty
Open a terminal.
Go to the Jetty installation directory.
Enter the following command:
$ java -jar start.jar
Now open a browser and go to localhost to check if Jetty was installed sucessfully:
http://localhost:8080/
In case you have jar file created by maven and has all the dependencies you will require following command.
java -jar XXX.SNAPSHOT.jar server config.yml
You can make your own XML based configuration file and pass it along with the startup command:
java -jar start.jar /path/to/jetty.xml
For example, if you want to use something else than 8080, then just put jetty.port inside the jetty.xml:
<Set name="port"><Property name="jetty.http.port" deprecated="jetty.port" default="9090" /></Set>
Or those who are impatient, can just start up their instance with:
java -jar start.jar --module=http jetty.port=9090
If you'r using Jetty version 9.x. You need to go to $JETTY_HOME/start.ini file and edit this setting jetty.http.port.
jetty.http.port=9090

Resources