Run Talend job on a Unix-like machine - java

I try to run simple job generated from Talend Open Studio v5.4.0.
It invokes a web service and save responce into an XML file. On my development (Windows 7) machine everything works fine.
On RHEL machine, with this version of Java:
[root#localhost checkws]# java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
when I try to run my job I get:
[root#localhost checkws]# sh checkws_run.sh
Exception in thread "main" java.lang.NoClassDefFoundError: routines/system/api/TalendJob
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: routines.system.api.TalendJob
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more
How to solve this problem?

To solve this issue (like the OP did) I exported the job both for Windows and Linux platforms. Seems to be a bug in Talend exportation.

On TOS 3.2.2.r33000 I exported for Unix only and checked "Export Dependencies"

Talend generate a zip package which work fine in Windows (using a bat file) and Linux (using a sh file). The sh have all lib jars in classpath.
If you want to change the lib path, and add dynamically all jars in your lib path, this is a way to do that.
#!/bin/sh
cd `dirname $0`
path_lib=/path/to/your/lib/directory
# include all jars in lib directory to classpath
for jar_file in `find $path_lib -name "*.jar"`
do
classpath="${jar_file}:${classpath}"
done
# x_y is the version of your job, x_y = 0_1 for the first version of a talend job.
java -Xms256M -Xmx1024M -cp ${classpath} projectname.jobname_x_y.jobname --context=Default "$#"

Related

Can't Run the Web Application Project using IntelliJ IDEA | Glassfish

I have tried to create a web application project using IntelliJ IDEA and I am using a Glassfish 6.2.5 version as the server and JDK version is 1.8 but when I started the server it showed this error
Application Server was not connected before run
configuration stop, reason: Unable to ping server
at localhost:4848
is there someone who knows about this error please help me.
this is the log
C:\glassfish6\glassfish\bin\asadmin.bat start-domain domain1
C:\Users\Lakshitha\.jdks\corretto-1.8.0_312\bin\java.exe -Dfile.encoding=windows-1252 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\Lakshitha\AppData\Local\Temp\idea_classpath1962225907 com.intellij.javaee.oss.process.JavaeeProcess 65261 com.intellij.javaee.oss.glassfish.agent.Glassfish51Agent
Error running admin process:
Message: com/sun/enterprise/admin/remote/RemoteSuccessException has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 Stack trace: java.lang.UnsupportedClassVersionError: com/sun/enterprise/admin/remote/RemoteSuccessException has been compiled by a more recent version of the Java Runtime (class file version 55.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:756) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) 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:418) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at com.intellij.javaee.oss.process.JavaeeProcess.main(JavaeeProcess.java:30) 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 com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64) IDEA requires application server's bundled JDK to be 5.0+, please replace JDK manually
Process finished with exit code 0
[2022-04-27 04:13:03,148] Artifact Test WAP:war exploded: Waiting for server connection to start artifact deployment…
Detected server admin port: 4848
Detected server http port: 8080
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/glassfish/admin/cli/AsadminMain has been compiled by a more recent version of the Java Runtime (class file version 55.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(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
C:\glassfish6\glassfish\bin\asadmin.bat stop-domain domain1
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/glassfish/admin/cli/AsadminMain has been compiled by a more recent version of the Java Runtime (class file version 55.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(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Disconnected from server
The exception does not tell you that you need Java 8 but instead that Java 8 (class version 52) is too old to run classes compiled by version 55 (i.e. Java 11).
So you need to install JDK 11.

ActiveMQ New build, latest version not working with latest Java

I am installing activemq on a new windows 2016 server. I have installed the latest version of Java "1.8.0_321" and the latest download of activemq "5.17.0", but when I try to start activemq I get this error:
Warning: JAVA_HOME environment variable is not set.
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/activemq/console/Main has been compiled by a more recent version of the Java Runtime (class file version 55.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(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
C:\Program Files (x86)\apache-activemq-5.17.0\bin>
The JAVA_HOME variable is set:
Java home variable
When I run
echo %JAVA_HOME%
I get
C:\Program Files (x86)\Java\jre1.8.0_321\bin
From that I would infer that it is correct?
Any ideas please?
It states, on the ActiveMQ home page, that ActiveMQ 5.17.0 release requires JDK 11+.
Your error message indicates the class version number of Java 11, i.e. 55.
Either migrate your code to Java 11 or use ActiveMQ 5.16.4 release which is compatible with Java 8.

how to deploy jenkins on the jetty correctly?

I'm trying to deploy jenkins on the jetty application server as follows:
Unpack the distribution
[~]$ unzip jetty-distribution-9.3.2.v20150730
[~]$ cd jetty-distribution-9.3.2.v20150730
Copy your war into place
[jetty-distribution-9.3.2.v20150730]$ cp ~/Projects/mywebapp.war webapps/
Run Jetty
[jetty-distribution-9.3.2.v20150730]$ java -jar start.jar
My version of java is:
$ 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 am getting the following message:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/eclipse/jetty/start/Main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Which version of the jetty I use with version 7 of java?
Java 7 is now EOL (End of Life) with Oracle.
Would highly recommend you use Java 8 from here on out.
Jenkins runs fine on Java 8 and Jetty 9.3.2 (the Jetty project themselves do this).
Jetty 9.3.x runs only with Java 1.8.
Jetty 9.0.x - 9.2.x runs with Java 1.7, so download latest stable 9.2.13.v20150730.

Running class from JAR with multiple JAR dependencies via command prompt

I cannot understand why none of these are working. I've seen similar situations on stackoverflow and their solutions haven't worked for me.
I have a lib directory containing 15 JARs. When I run this command in command prompt from within that lib directory:
java -cp openjpa-2.2.1.jar org.apache.openjpa.enhance.PCEnhancer
I get a NoClassDefFoundError for one of it's dependencies.
Exception in thread "main" java.lang.NoClassDefFoundError: serp/bytecode/Instruction
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: serp.bytecode.Instruction
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Now when I try to add the jar containing that dependency:
java -cp openjpa-2.2.1.jar:serp-1.13.1.jar org.apache.openjpa.enhance.PCEnhancer
I get this:
Error: Could not find or load main class org.apache.openjpa.enhance.PCEnhancer
I've also tried:
java -cp openjpa-2.2.1.jar:serp-1.13.1.jar:. org.apache.openjpa.enhance.PCEnhancer
java -cp . org.apache.openjpa.enhance.PCEnhancer
With the same effect, and when I try:
java -cp serp-1.13.1.jar -jar openjpa-2.2.1.jar org.apache.openjpa.enhance.PCEnhancer [path to .java file]
All I get is:
>OpenJPA 2.2.1
>version id: openjpa-2.2.1-r422266:1396819
>Apache svn revision: 422266:1396819
>os.name: Windows 7
>os.version: 6.1
>os.arch: amd64
>java.version: 1.8.0_25
>java.vendor: Oracle Corporation
>java.class.path:
> openjpa-2.2.1.jar
With no file output, even when I add the -d flag with a directory.
Where am I going wrong?
RealSkeptic's comment was correct. Semicolons are the proper syntax to separate JARs listed on the classpath in Windows, like so:
java -cp jar1;jar2;jar3 classToRun args

Error due to version compatibility in running jar file

I have created a jar file using JDK 8.0 and I tried to run the jar file in a system which is having JRE 7.0, but I am getting an error like this:
C:\Users\admin\Desktop>java -jar test.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: test : Uns
upported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
What change am I need to make in my jar file creation. So that it will run without version compatibility?
You need to use the -source option for javac. For example:
javac -source 1.7 foo/Bar.java
In theory you can specify the source and target options separately, but judging by your comment, it sounds like you can't use Java 8 language features at all when targeting 1.7.
Note that this only covers your own source code. If xbasej-20091203.jar was built against Java 8, you'll need to find a version which targets Java 7 instead.

Categories