I'm trying to run Spring Boot executable-jar built using spring-boot-maven-plugin on a Linux machine. The machine has multiple jdks installed, the one on PATH is jdk8 and changing it is unfortunately not an option. My executable-jar however needs jdk17, so when I just launch it as is I get UnsupportedClassVersionError.
I was following the official documentation and created the corresponding .conf file to override JAVA_HOME. But this does not seem to solve the issue:
[root#ios-maket updater-new]# ls
updater-new-3.0-SNAPSHOT.conf updater-new-3.0-SNAPSHOT.jar
[root#ios-maket updater-new]# cat updater-new-3.0-SNAPSHOT.conf
JAVA_HOME=/opt/jdk-17/bin/java
[root#ios-maket updater-new]# ./updater-new-3.0-SNAPSHOT.jar
Application is running as root (UID 0). This is considered insecure.
Exception in thread "main" java.lang.UnsupportedClassVersionError...
On the other hand if I run it manually everything works fine:
[root#ios-maket updater-new]# /opt/jdk-17/bin/java -jar ./updater-new-3.0-SNAPSHOT.jar
[main] INFO com.icl.ios.fias.updaternew.UpdaterNew - Starting UpdaterNew using Java 17.0.6
What am I doing wrong?
Setting JAVA_HOME is not enough, you also need to set PATH to point to JAVA_HOME/bin.
JAVA_HOME=/opt/jdk-17
PATH=${JAVA_HOME}/bin:$PATH
java -jar updater-new-3.0-SNAPSHOT.jar
Try running the jar with -Dloader.path to specify the config manually.
java -Dloader.path=./updater-new-3.0-SNAPSHOT.conf -jar ./updater-new-3.0-SNAPSHOT.jar
If this still does not work, then probably there is an issue with your config file, but from what I can see, your config file looks okay, unless the java path is incorrect.
Related
I want to run JMeter test plans from a UNIX server where env variables for java is not set. Its a test server and I dont have access to set that. We have different JDK versions and all are sitting in directories. I need to run my JMeter TestPlans on this server. I went to JDK /bin folder and tired to execute the below command
$ {jmeter-path}/bin/jmeter -nt testplan.jmx -l testresult.jtl
but this says
./bin/java: not found
But if I do simple java -version it shows the version result.Is that something that JMeter needs specifically the java env variable set or it wont run ? I dont have permission to set and I want to run the testplan using the JDK/JRE from its directories. A help would be appreciated. Thanks in advance!
UPDATE:
I think I could work around this by editing the jmeter script file as suggested in the one of the comments. Since my requirement was running the JMeter from a specific server, I could achieve this by editing the JAVA_HOME variable value in the script.
JMeter looks for java executable in system PATH so you have 2 options:
Add bin folder of your JDK or JRE to PATH, something like:
PATH=$PATH:/location/of/your/jbk/bin && export PATH && {jmeter-path}/bin/jmeter -nt testplan.jmx -l testresult.jtl
Or if you have java in PATH just run ApacheJMeter.jar like:
java -jar {jmeter-path}/bin/ApacheJMeter.jar
You might also want to use jmeter.sh wrapper script instead of jmeter, it has some logic regarding java binary location
More information: Get Started With JMeter: Installation & Tests
The official JMeter Getting Started documentation says this:
To install a release build, simply unzip the zip/tar file into the directory where you want JMeter to be installed. Provided that you have a JRE/JDK correctly installed and the JAVA_HOME environment variable set, there is nothing more for you to do.
Based on the symptoms that you reported, I think that you have not set JAVA_HOME correctly. It should be set to an absolute path to your Java installation's top directory.
I have a flume agent run on different servers.It can work in centos and windows 2008.
But when I run it in windows 2003,It got errors.
All point in the path is replaced to '/',what's wrong with it?I guess that which windows variable is not be correct set?
Thanks.
When you set your agnet using bin/flume-ng.... make sure to specify the file where the agent configuration is.
--conf-file flume_Agent.conf -> -f conf/flume_Agent.conf
I have built my own hippo project based on hippo-maven-archetype.
I have prepared the PostgreSQL configuration of repository and created hippo database.
Then I've built my app and run it by maven (mvn -Pcargo.run -Drepo.path=storage).
All is ok, Postgresql repository was initialized successsfully and hippo works.
Now I am trying to deploy my project on my Linux server, as described here, using tomcat 8 and java 8.
All is ok, except that the repository does not initializing in any way.
Cms Web-page always redirects to localhost/cms/wicket/bookmarkable/org.hippoecm.frontend.NoRepositoryAvailablePage.
At tomcat startup there are no errors, but also there are no messages about bootstrapping the repository.
After successful startup, log files contain exception: java.lang.IllegalArgumentException: The resource path [WEB-INF/storage] is not valid
Tomcat java command prompt (as ps shows:)
/usr/bin/java -Djava.util.logging.config.file=/opt/apache-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -server -Xmx512m -Xms128m -XX:PermSize=128m -Drepo.path=storage -Drepo.config=file:/opt/apache-tomcat/conf/repository.xml -Drepo.bootstrap=true -Dlog4j.configuration=file:/opt/apache-tomcat/conf/log4j.xml -Djava.endorsed.dirs=/opt/apache-tomcat/endorsed -classpath /opt/apache-tomcat/bin/bootstrap.jar:/opt/apache-tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/apache-tomcat -Dcatalina.home=/opt/apache-tomcat -Djava.io.tmpdir=/opt/apache-tomcat/temp org.apache.catalina.startup.Bootstrap start
Any ideas?
It's a best practice to put your repository storage outside of your web application. I would advise you to explicitly set the storage location by using the repo.path system property to a full qualified location on the filesystem instead of a relative path like you do now. With Tomcat you could specify this in your setenv.sh file by appending the following parameter to your CATALINA_OPTS.
CATALINA_OPTS="-Xmx1024m -Drepo.path=/opt/cms-storage/"
You also need to take into account that the configured workspace will be extracted to a separate file within this storage directory, so if you change something within the repository.xml you will probably have to change the existing workspace.xml as well. As of version 7.9.7 Hippo supports running the entire stack on Java 8. See the release notes for more information and what has changed.
I have been running a Tomcat 6.0.37 server for quite some time via the startup.bat.Now I want to run tomcat as a service that starts automatically when the machine starts up.
I created the service with the bat : service.bat install.This created the service succesfully.When trying to start it however I get the error in the title.I then tried running just the exe(tomcat6.exe).This gave me the exact same error.
I have checked that CATALINA_HOME,JAVA_HOME and JRE_HOME is set correctly.bootstrap.jar does exist in tomcat/bin.Path to the jvm is correct.jvm.dll does exist in jre6/bin/server.
I also found a thread with a different class missing where they said rt.jar was missing from the jre,I checked this and mine exists in jre6/lib/.I really don't have anymore ideas as to what can be wrong.
try to update the service by executing (adapt to your path):
C:\> tomcat6 //US//Tomcat6 --Description="Apache Tomcat Server - http://tomcat.apache.org/ " \
C:\> --Startup=auto --Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar
US means: update service.
This should fix the classpath.
All the necessary information are in the official website:
http://tomcat.apache.org/tomcat-6.0-doc/windows-service-howto.html
Recommend using one of the "Java as a Windows Service" frameworks as they handle adding JARs to the classpath, etc. This can be done manually however via the "java -cp {set your classpath here...}" options as well.
I have Mysql installed on my Linux box and wrote a sample program to access one of it's table.
I am using 'mysql-connector-java-5.1.10.jar'
The code is working fine if i put the jar in 'jre/lib/ext'. However, other ways of recognizing that jar are not working. I tried with setting $CLASSPATH and tried to use '.' current directory.
It's failing with the following error :
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
I usually don't use the global $CLASSPATH variable, the easiest way to get it running is
java -cp .;/path/to/mysql-connector-java-5.1.10.jar[;<other libs>] pkg.name.MyApplication
Sidenote
If you have your application exportet to a jar with a Main-Class attribute ("executable jar") and start it with java -jar myjar.jar, then you have to add all required libraries to the jars manifest, $CLASSPATH and -cp are ignored in this case. And that's why I usually don't use the -jar option...
Edit
To answer your additional question: If the current directory was added to the classpath by default, then the location from where the application was started could influence the application itself.
Imagine an application inside a jar and a start command
java -cp application.jar com.example.Main
Now we have a defined environment: only the content of application.jar (and the jre classes) are on the classpath and part of the application. If the current directory was added to the classpath automatically then all files at the current location (and at locations of all subfolders) would be on the classpath too, intend or not. With a result, that the application might work if started from the users home directory but maybe not if started from the root directory (/).