tomcat7 UnsupportedClassVersionError when running with java7 - tomcat7

problem: when deploying my war to tomcat7 i get the error
java.lang.UnsupportedClassVersionError: org.MyLibraryClass : Unsupported major.minor version 51.0
(this is the error one gets when compiling java with a newer version than the java used when running the code.)
situation, in order:
brand new ubuntu 12.04.1 server 64bit minimal, in a virtualbox
installed tomcat6
tried to deploy my war
realized the error, and that i need java7 because ubuntu 12 still comes with outdated java
installed oracle java 7 using this guide https://askubuntu.com/questions/197248/java-on-ubuntu-server-12-04
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
removed tomcat6 and installed tomcat7
sudo apt-get remove tomcat6-common
sudo apt-get install tomcat7
deployed my war to tomcat7
started tomcat
sudo service tomcat7 start
checked my app's log file. same error.
echo $JAVA_HOME is empty, java -version shows:
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
it's a default tomcat7 install, no modification. still i checked the startup scripts and config to make sure no custom java version is specified anywhere. also checked by asking catalina:
ubuntu#ubuntu:/home$ /usr/share/tomcat7/bin/catalina.sh version
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.26
Server built: Jul 19 2012 03:21:30
Server number: 7.0.26.0
OS Name: Linux
OS Version: 3.2.0-29-generic
Architecture: amd64
JVM Version: 1.7.0_07-b10
JVM Vendor: Oracle Corporation
now i'm stuck. i don't see how any java code could fail to run on oracle's jre7.
my war is a brand new very basic hello world grails 2.1 app with maven, which has a maven dependency (org.MyLibraryClass) that is compiled with jdk7. that's the one for which i get the error.
in grails i changed BuildConfig.groovy to have 1.7 instead of 1.6:
grails.project.target.level = 1.7
grails.project.source.level = 1.7
then did a grails clean, rebuild, war, redeploy. no change.
any idea what to try next?

Typical error when compiling code with Java7 and running it under Java6.

The critical line in your query is this one I think:
sudo service tomcat7 start
I think it may be triggering the inheritance of OpenJDK still in the system there. What you want to do is instead try tomcat from your own environment.
Login as your normal user
java -version
/usr/share/tomcat7/bin/startup.sh
and check. You should also login as a clean user, root or elsewhere and check java -version to check.
If all else fails, go to /etc/profile and make sure path to Oracle's Java/bin directory is the very first thing in the PATH variable for the environment.

I have the same problem just now,but now it's solved.
Please check this symbolic
/usr/lib/jvm/default-java
it's default link is open-jdk, reset the correct jdk dirctory.
good luck!

Related

Quarkus Install Error [jbang] [ERROR] java.nio.charset.MalformedInputException

I am following the Getting Started Guide from the Quarkus site to try out Quarkus. But, when I execute this curl command
curl -Ls https://sh.jbang.dev | bash -s - app install --fresh --force quarkus#quarkusio
the following error is displayed.
[jbang] [ERROR] java.nio.charset.MalformedInputException: Input length = 1
Running quarkus install on Mac (Intel) running Monterey OS and here's my java info:
java --version
java 11.0.6 2020-01-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)
whereis java
java: /usr/bin/java
which java
/Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Home/bin/java
Can somebody please let me know what I might be doing wrong?
Thanks
I used SDKMAN! to install Quarkus and that seemed to work.

Maven version error while trying to install ambari on centos

I am trying to install ambari 2.7.5 on centos 7. I am following the instructions given on this link. When I run the build command for maven I get the following error:
I have installed maven 3.6.3 . And I could not find maven 3.1.0 in apache downloads. So how to resolve this error?
#VK for Ambari-web you have to edit some files and set your versions. If you are having hard time with npm/node version make sure they match the posted versions I gave. In centos7 I am using the epel repository. Sounds like you already got current maven so good to go there.
Also this post is pretty much a duplicate of:
Building Ambari 2.7.5 on CentOS 7 from source, Worked 2 weeks ago, now fails
Its also discussed here:
Ambari 2.7.5 installation failure on CentOS 7
And a jira with another bower file sample:
https://issues.apache.org/jira/browse/AMBARI-25519

jps command not found while installing hadoop

ian new to centos 7
and iam configuring hadoop 2.7.1 cluster so i need to install openjdk as a requirement
so i installed one by the command
yum install java-1.7.0-openjdk
and java version command out put is
java version "1.7.0_131"
OpenJDK Runtime Environment (rhel-2.6.9.0.el7_3-x86_64 u131-b00)
OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode)
but my problem is that i want to use jps command and it is found in
java-1.7.0-openjdk-1.7.0.101-2.6.6.1.el7_2.x86_64
so i iwant to install this rpm and i used the command
cd /usr/lib/jvm
rpm -ivh --nodeps ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/7.0/x86_64/updates/security/java-1.7.0-openjdk-1.7.0.101-2.6.6.1.el7_2.x86_64.rpm
but becuase a newer version of jdk is installed i wasn't able to install this rpm
with the error
package java-1.7.0-openjdk-1:1.7.0.131-2.6.9.0.el7_3.x86_64 (which is newer than java-1.7.0-openjdk-1:1.7.0.101-2.6.6.1.el7_2.x86_64) is already installed
i don't know if iam using the right way to make jps command works
what should i do to include jps command
and is it right to install an old release of openjdk i mean 101 when newer one already exists i mean 131
java-1.7.0-openjdk contains only the JRE. jps is part of the openjdk development package. Refer here.
Try
yum install java-1.7.0-openjdk-devel

Using Gradle with OpenJDK 1.9

I cannot seem to use Gradle with OpenJDK 1.9.
When I run the following command:
react-native run-android
I end up getting this error.
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9-internal'.
Running java -version shows me:
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)
Any ideas how I can fix this?
Which version of gradle are you using?
cd android
./gradlew -version
I think there was a bug determining versions for java 1.9 which was fixed in Gradle 2.10.
Another option is to try spoofing a java.version that Gradle can parse
export JAVA_TOOL_OPTIONS='-Djava.version=1.9'
react-native run-android
#see JavaVersion.java and JavaVersionSpec.groovy
This seems to be an incompatibility with your build of OpenJDK 9 and Gradle.
Your OpenJDK version is:
openjdk version "9-internal"
And it appears Gradle can't parse it:
Could not determine java version from '9-internal'.
Looks like gradle is prepared to accept 9-ea, but not 9-internal.
You will have to modify your build of OpenJDK to have it return "9-ea" or something similar for java -version.
The following configure options when building OpenJDK 9 should do the trick:
configure \
--with-version-pre="ea" \
--with-version-opt="" \
... your other options ...
I had the same exact issue and, in my case, it worked by removing OpenJDK:
sudo rm /var/lib/dpkg/info/openjdk-*
sudo apt-get purge openjdk-*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update
and installing the Oracle Java SDK:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
I know this is not the exact answer (using Gradle with OpenJDK 1.9), but I managed to keep going and run the app both in a virtual device and in my smartphone. Hope it helps.
Note: I am running react-native: 0.40.0 and react-native-cli: 2.0.1 in Ubuntu 16.04

Webstart running the wrong jre version on OSX

I am running a jnlp in OSX 10.8.2 with jre the jre version 1.7.0_11 and jnlp tag is set to run in 1.6 as:
<j2se version="1.6" href="http://java.sun.com/products/autodl/j2se">
or
<j2se version="1.6*" ...>
However, when the jnlp runs shows the following in the console:
Java Web Start 10.11.2.21
Using JRE version 1.7.0_11-b21 Java HotSpot(TM) 64-Bit Server
When I run the same jnlp file in windows using jre 1.7 works fine, it loads with jre 1.7 and then download jre 1.6 and run on it.
Any ideas?
Now, they told me they need java 1.7 as default.
So, I found that installing JDK 1.7 instead of JRE, it was fixed. I can have both versions and my jnlp is using jre 1.6 to run.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
And then I had to run the follwoing commands from http://support.apple.com/kb/HT5559:
sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
After run this, the java applet plug-in starts to work in Chrome and I can handle all versions of Java from Application/Utilities/JavaPreferences
The root cause:
jnlp is set to only use java 1.6 otherwise download it from auto download site and installed automatically
All java versions for mac but 1.7 were developed by Apple so they do not have autodownload url
After 1.7 oracle is developing java for macs
When I review the java preferences only found java 1.7
Jnlp looks for java 1.6 and is unable to find it and try to autodownload and is unable to do it either, so the only option it has is run on java 1.7
To solve this we uninstall java 1.7 and then we use the following instructions to make 1.6 java default:
http://support.apple.com/kb/dl1573
http://blog.nominet.org.uk/tech/2008/04/24/restarting-the-awt-native-event-thread/
http://support.apple.com/kb/HT5559
Then we had a problem with certificates but we did the following:
https://stackoverflow.com/questions/11727955/the-digital-signature-is-not-trusted-java-will-not-allow-any-access-to-this-app
java-will-not-allow-any-access-to-this-app
fix these links to get java -version pointing to 7
cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo rm CurrentJDK
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/ CurrentJDK
sudo ln -s CurrentJDK 1.7
sudo ln -s CurrentJDK 1.7.0
you could create links to the old 1.6
sudo rm 1.6 1.6.0
sudo ln -s /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents 1.6
sudo ln -s /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents 1.6.0

Resources