Cannot execute Groovy apps on command line. Only in the ide.
Hi,
Our Groovy apps are running fine, when executed within the Ultimate version of Intellij. However, when we try to execute them on the command line, there are only errors.
We have tried both 1. Create the Project as a Java type & then and including Groovy libraries; and 2. Creating the Project as a Groovy Module.
Also, have tried both
1. Setting the CLASSPATH to the Oracle jdbc jar and the whattheGroovy$_ImportRoomRecordsFromRZCSVFile_closure1.class, and executing the .class file from the command line, thus
java whattheGroovy whattheGroovy.ini
which generates a classnotfound exception.
and
2. Generating an Artfifact fat jar, thus
java -jar whattheGroovy.jar whattheGroovy.ini,
which generates the famous
Invalid signature file digest for Manifest main attributes
error. I've tried removing as much as possible from the fat jar, but cannot get rid of this error.
Please sign in to leave a comment.
Hello,
Could you create a sample project which illustrates the problem and link it to this thread?
Denis
Thanks, Denis. There's obviously some difference in specifying the main class, in a Java app, vs. a Groovy app, that I'm missing. We have no problems executing our Java apps, in both Windows and Linux, via the class file with classpaths; or executing the single jar artifact (the artificate is our preferred method).
Attached is the Zip file, for the project. The Single Artifact Jar can't be included, because the zip file will be over the forum limit. But, of course it can be generated easily.
If the class file is executed directly, then there's a ClassNotFound error, referring to groovy/lang/GroovyObject. So I guess the question would be, what classpath should be used for this? The classpath that Intellij generates in the IDE is too long & cumbersome for the command line.
Also, this is developed in Windows. Most of the Java apps I develope in Intellij Windows, are able to execute in Linux without any changes. We will probably have to install Groovy on the Linux server as well, and that will require permission first. (We use the single jar artificats for the most part, but occasionally execute the class file with just a couple of classpath differences between Windows and Linux).
If the single jar artifact is executed, then there's an
Invalid signature file digest for Manifest main attributes
error. (This is actually the main problem, because we prefer to generate standalone jars.)
******************************************************
java whatthe
Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
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:247)
Caused by: java.lang.ClassNotFoundException: groovy.lang.GroovyObject
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
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:247)
... 12 more
Could not find the main class: whatthe. Program will exit.
******************************************************
******************************************************
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:221)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:288)
at java.util.jar.JarVerifier.update(JarVerifier.java:199)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:323)
at java.util.jar.JarFile.getInputStream(JarFile.java:388)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:692)
at sun.misc.Resource.cachedInputStream(Resource.java:61)
at sun.misc.Resource.getByteBuffer(Resource.java:144)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:256)
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:247)
Could not find the main class: whatthe. Program will exit.
******************************************************
Attachment(s):
GroovyWhatthe.zip
Can't reproduce the problem locally so far. Please provide your resulting artifact jar. You can use ftp://ftp.intellij.net/.uploads/ for that.
Denis
Just tried to copy it across, and it disappeared after the copy. Trying again.
You can only write into that ftp resource, not read.
Just tell me the file's name
Denis
Sent it a second time, and just realized the 'disappearance' is by intent. Your ftp site immediately moves uploads to a private area ( I think ).
Ok, thanks Denis, let me know if you can't locate the whatthe.jar.
Denis,
Were you able to locate the whathe.jar?
Sorry, completely forgot about the problem
Yes, I downloaded the jar from the ftp. Checking in right now.
Denis
So, the problem is that your jar file contains KITFOX.SF and KITFOX.DSA files which were used for signing class files. Verification fails as you repacked them.
Checked that everything works fine if you remove that files from the jar
Denis
Ok, we'll take them out manually, thanks.
How do you tell Intellij not to include them, in the artifact Jar?
I'm afraid the ide doesn't offer facility like 'exclusion/inclusion filters'
There is an alternative approach - deliver dependencies as separate jars and link them via manifest (choose corresponding setting during new artifact configuration).
Denis
Yeah, I like the standalone jars, they are more convenient. We can always automate the removal of the offending files from the jar archive.
Ok, thanks for your assistance, Denis. This problem is resolved.
You are welcome
Denis