I've installed groovy on my OS X via terminal and I can't run anything. The following exception occurs:
java.lang.SecurityException: Prohibited package name: java.lang
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:659)
at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:175)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:100)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
It seems that its developers used java.lang package name which makes the class loader angry.
If it can help I checked which tools.jar are found by startGroovy in the following lines:
208 # For Darwin, use classes.jar for TOOLS_JAR
209 TOOLS_JAR="$JAVA_HOME/lib/tools.jar"
In my case JAVA_HOME is:
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/
More details:
$ which java
/usr/bin/java
$ which groovy
/Users/maksim/.sdkman/candidates/groovy/current/bin/groovy
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/
echo $CLASSPATH is empty.
$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Related
I have a spring boot REST API jar file which works perfectly fine when I run it in my local machine using eclipse IDE, however when I upload the jar file to my VPS server I get the following error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/JarLauncher : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
I changed the java version in my POM file from version 11 to java 8:
<properties>
<java.version>8</java.version>
</properties>
In the VPS server I could see that the available java versions are: java 7 (Version : 7u80) and java 8 (Version : 8u92 - 1.8.0_92-b14), however my JRE version is jre 1.8.0_201.
If I keep java 7 in the VPS server I get the exception mentioned above and if I remove java 7 from the VPS server, then I get the following error when trying to run the jar file from ssh using Putty:
[root#vps public_html]# java -jar SpringBootProject-0.0.1-SNAPSHOT.jar
-bash: java: command not found
[root#vps public_html]#
How do I fix this?
I am trying to setup CI for https://github.com/amCap1712/pljava using Travis. But it fails with following log:
find pljava-packaging -name \*.jar | sudo xargs java -jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/gjt/cuspy/JarX has
been compiled by a more recent version of the Java Runtime (class file version 53.0), this
version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
The complete build log and travis config is available at https://travis-ci.org/github/amCap1712/pljava/builds/661687014 . I am using OpenJDK9 for this build but it fails for OpenJDK14 as well.
How to fix the error ?
I'm trying to configure JMX Exporter as an agent of a Wildfly 10.1.0 box. Everything works fine with default configuration.
Now I need to add Sentry as a custom-handler which fail the Wildfly start with the following error:
java.lang.IllegalArgumentException: Failed to load module "io.sentry" for handler "SENTRY"
at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:64)
...
at java.util.logging.Logger.getLogger(Logger.java:502)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.<clinit>(JmxCollector.java:38)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.NoClassDefFoundError: org/jboss/modules/ModuleLoader
at org.jboss.logmanager.config.AbstractPropertyConfiguration$ModuleFinder.getClassLoader(AbstractPropertyConfiguration.java:463)
at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:62)
... 27 more
When I add -Xbootclasspath/p:/opt/jboss/wildfly/jboss-modules.jar to JAVA_OPTS the error changes to:
java.lang.IllegalArgumentException: Failed to load module "io.sentry" for handler "SENTRY"
at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:64)
...
at java.util.logging.Logger.getLogger(Logger.java:502)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.<clinit>(JmxCollector.java:38)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: org.jboss.modules.ModuleNotFoundException: io.sentry:main
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:223)
at org.jboss.logmanager.config.AbstractPropertyConfiguration$ModuleFinder.getClassLoader(AbstractPropertyConfiguration.java:467)
at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:62)
... 27 more
org.jboss.modules.ModuleNotFoundException: org.jboss.as.standalone:main
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:223)
at org.jboss.modules.Main.main(Main.java:394)
Is there a proper way to configure an agent and a custom-handler in the same Wildfly deployment?
EDIT 1:
The current JAVA_OPTS is:
-server
-Xms1024m
-Xmx1024m
-XX:MetaspaceSize=256m
-XX:MaxMetaspaceSize=256m
-XX:NewRatio=2
-XX:SurvivorRatio=20
-XX:+UnlockExperimentalVMOptions
-XX:+UseCGroupMemoryLimitForHeap
-XX:+UseGCOverheadLimit
-XX:+ExitOnOutOfMemoryError
-Djava.net.preferIPv4Stack=true
-Djava.awt.headless=true
-Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager,io.sentry
-javaagent:/opt/agent/prometheus/jmx_prometheus_javaagent.jar=1234:/opt/jboss/wildfly/bin/jmx-exporter-config.yaml
-Djava.util.logging.manager=org.jboss.logmanager.LogManager
-Xbootclasspath/p:/opt/jboss/wildfly/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.0.4.Final.jar
-Xbootclasspath/p:/opt/jboss/wildfly/modules/system/layers/base/io/sentry/main/sentry-1.7.2.jar
-Xbootclasspath/p:/opt/jboss/wildfly/jboss-modules.jar
JVM version:
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (IcedTea 3.6.0) (Alpine 8.151.12-r0)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
OS version (container):
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.7.0
PRETTY_NAME="Alpine Linux v3.7"
HOME_URL="http://alpinelinux.org"
BUG_REPORT_URL="http://bugs.alpinelinux.org"
This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 7 years ago.
I'm not sure what has happened but I have a maven based Java project in Eclipse (Mars) where when I go to Run As-> Mvn install (from the UI), I've tried cleaning the project, Maven-> update project, mvn eclipse:eclipse, etc...nothing works
I get the following Exception thrown at me:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:254)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Earlier this was working with no trouble. This project is configured at with Java 1.6
I run mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.3", arch: "x86_64", family: "mac"
I run java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
I have seen the other similar question which solutions like
export JAVA_HOME=<path to installed java version> but this does not work for me.
Any help or assistance would be much appreciated, thanks.
Configure java 1.7 for this project. As java version doesn't match with maven so please use java 1.7
It is clear that your default java version is 1.7
Go to project properties and from here set java 1.7 for your project. Hope this may help you out.
My java application cannot open in Yosemite.
the error message like this :
java.lang.UnsupportedClassVersionError: .../.../view/Launcher : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.install4j.runtime.MacLauncher.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at apple.launcher.LaunchRunner.run(LaunchRunner.java:116)
at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)
I heard this message occur when the JRE1.7 is not installed.
So I checked the version in my console like this :
....-MacBook:~ thrisis$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.10.1
BuildVersion: 14B25
....-MacBook:~ thrisis$ java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
....-MacBook:~ thrisis$
I'm very confused and please help me.
PS, sorry for my poor english.
It may also occur is 1.8 is not installed. Make sure you are running the latest versions of Java runtime environment (and Development kit if you need it).
I had the same problem and I fixed it by setting my JAVA_HOME
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
In my .zshrc file. I use zsh shell. You can do the same in your .bashrc or .profile
You mainly see this error when your "jar" is compiled with a higher JDK and you are trying to run it with a lower version. Check out this Wikipedia entry for reference.