No console output available on linux when executing grails/groovy - linux

When a groovy script or a grails app is executed, there is no output/input available -> just a clear console screen. Even without starting the X-Window-System, the output is not visible.
I tried also:
grails compile --plain-output (does not work too)
executing grails commands in IntelliJ (works fine with grailsCommand, but not on CommandLine)
How can the output made visible?
Thank you

What version of grails?
env|grep JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64/
env|grep GRAILS
GRAILS_HOME=/home/vahid/ggts-bundle/grails-2.3.7/
which grails
grails is aliased to `/home/vahid/ggts-bundle/grails-2.3.7/bin/grails'
alias|grep grails
alias grails='/home/vahid/ggts-bundle/grails-2.3.7/bin/grails'
Do you see anything actually being done, or is it after completion that it does not show up?
grails refresh-dependencies --plain-output 2>&1 > /tmp/vh.txt
The above redirected all output to /tmp/vh.txt
cat /tmp/vh.txt
|Loading Grails 2.3.7
|Configuring classpath
.
|Environment set to development
....
|Dependencies refreshed.

Related

Passing global envvar JAVA_HOME to builds through jenkins.war

I administrate a jenkins instance on Linux.
I have been asked to pass a system-wide JAVA_HOME as a global ENV var for jenkins builds (as opposed to just jenkins itself), and I wish to do this through the service/daemon startup script. (Please don't give per-job Jenkinsfile / build pipeline solutions.)
Some plugins like maven-javadoc-plugin apparently require this variable.
(Curiously, this was never before necessary for the existing builds on this jenkins install. Either the used plugins changed, or jenkins did? Since I don't build on this, I can't say which.)
The only way I managed to do make this work for now, is using a fixed string through the GUI at <jenkins-url>/configure under "Global properties > Environment variables".
I understand I can add JDK installations under <jenkins-url>/configureTools/, but this, again, only allows fixed strings, which I can't be bothered to remember correcting on every system update.
What I should be able to do instead, is pass the ENV var to the jenkins service at startup, such as: JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))).
jenkins (debian package) in fact brings an /etc/default/jenkins file,
which says you can pass a --javahome=$JAVA_HOME argument; like this:
/usr/bin/java -jar jenkins.war --javahome=/usr/lib/jvm/java-11-openjdk-amd64
However, this seems incorrect and does not work on current jenkins versions. It throws java.lang.IllegalArgumentException: Unrecognized option: --javahome=/usr/lib/jvm/java-11-openjdk-amd64 at winstone.cmdline.CmdLineParser.parse(CmdLineParser.java:52)
Since some other options uses camelCase (like --httpPort), I have also tried --javaHome=$JAVA_HOME instead.
This option is accepted (jenkins doesn't choke on startup), but it also doesn't work, it appears to get ignored?
I didn't manage to figure out if this should be the correct option from the source code either.
Jenkins version: 2.319
Perhaps someone can tell me if this used to work, is a bug, or how to do this if I'm doing it wrong.

Not able to execute groovy script from command ".GroovyRuntimeException: Conflicting module versions."

I have run groovy script for a while from command line. Recently I have started to work with spock/groovy in the eclipse. I have run couple of test using Groovy Console when console was loaded from eclipse. Any way after these activities I have tried to execute groovy from command line and it failed with the following error:
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-xml is loaded in version 2.4.3 and you are trying to load version 2.4.1
I was using gvm tool to reinstall groovy and set is a primary version but still have the problem. Something was changed from eclipse where my groovy installation gets affected and can not be fixed by by reinstalling.
I have some search done but did not find solution. most solution were mentioning this problem but they were trying to fix this withing eclipse, where in my case I am trying to fix it outside of eclipse. Also will be nice if I be able to prevent this from happening in the future. If somebody have similar experience please share.
Thanks,
Alexander

run Groovy CLI from groovy jar placed in war

I know about Groovysh, but I need to know if it is possible to run groovy CLI directly from groovy.jar placed in deployed war servlet (using one command). I can simplify question. Is there possibility to run Groovy CLI like it works, for example, in Clojure?
java -cp clojure-1.4.0.jar clojure.main
And CLI appears in terminal. This is how things look in clojure. I am looking for one line command which will run groovy CLI in terminal (using only groovy library to run it). I was looking for help in javadoc, found classes which should help, but don't know how to run it. :f
http://groovy.codehaus.org/api/groovy/lang/GroovyShell.html
(If someone knows solution which doesn't meet all criterias, also please answer.)
//EDIT
It seems that it needs groovy.jar, commons-cli.jar, antlr.jar, asm-util.jar and jline.jar. So I've added those files in my war file in WEB-INF/lib directory. Maybe it's good solution to make my own jar which role will be to call Groovy CLI from other jars, but now the question is, how ro run jar placed in WEB-INF/lib directory inside deployed war application via command line?
Greets
Seems like groovysh depends on more libs than the embeddable version contains. I managed to do what you want by using the following command:
$ java -classpath '*' org.codehaus.groovy.tools.shell.Main
But the current directory had to be the dir where all the groovy libs are; i.e. $GROOVY_HOME/lib:
$ cd $GROOVY_HOME/lib
$ java -classpath '*' org.codehaus.groovy.tools.shell.Main
Groovy Shell (2.0.6, JVM: 1.6.0_24)
Type 'help' or '\h' for help.
------------------------------------------------------------------------------
groovy:000>

Why doesn't SBT 0.7.7 work correctly on my Linux system? (case details inside)

First of all, I'd like to ask to correct my question title if something better comes into your mind.
Let's take a Lift REST web service example from the Simply Lift book by David Pollak here.
If I open a Windows (Windows XP SP3, all the updates, Oracle JDK 7) console inside the directory and run "sbt" (sbt.bat), everything works just fine. But in case I try to do the same (but using "./sbt") in Linux (XUbuntu 11.10, OpenJDK 6, OpenJDK 7, Oracle JDK 7 (tried all of them)), SBT returns (instead of going to SBT console mode) immediately as it has done it's job. This means that may the command be just ./sbt it returns about immediately (after finishing the automatic project maintenance), or be it ./sbt jetty-run - it just starts the web server and shuts it down immediately.
Moreover, a web service I've developed for a project of mine compiles and works ok on Windows, but can't be compiled (using ./sbt compile) on Linux (by the same version of SBT). The error is "source file '/.../src/main/scala/code/lib/FooBar.scala;src/main/scala/bootstrap/liftweb/Boot.scala' could not be found", where "FooBar.scala" is an object where I do all the serves (directly called from Boot.scala).
Any ideas of what can be the reason and how to fix it?
UPDATE: The reason of the first problem (SBT returning to shell instead of offering SBT console) seems to be the file was checked out on Windows and had CR+LF instead of just LF line ending. The solution of source files not being found was in just using clean command to recompile from scratch.
The reason of the first problem (SBT returning to shell instead of offering SBT console) seems to be the file was checked out on Windows and had CR+LF instead of just LF line ending. The solution of source files not being found was in just using clean command to recompile from scratch.
First what happens when you simply type:
java -jar sbt-launch.jar
directly from the command line in the folder where the sbt-launch.jar is placed ?. If the sbt-launch.jar is in the same folder as the sbt script then you can edit the script to look like this:
#!/bin/sh
test -f ~/.sbtconfig && . ~/.sbtconfig
java -Xmx512M ${SBT_OPTS} -jar dirname $0/sbt-launch.jar "$#"
The dirname $0 construct returns the full path of the sbt script folder without the filename of the script. Using the $SBT_OPTS variable allows you to experiment with the various JVM options, like:
SBT_OPTS="-Xss2M -XX:+CMSClassUnloadingEnabled"
Although I would wait with these options as they are likely not the problem here (however be sure to add CMSClassUnloadingEnable later when SBT is working as it ensures that Scala class definitions generated dynamically when running SBT gets unloaded when they are unused, thus preventing memory errors - see more info here):
Also consider using one of
-Djline.terminal=scala.tools.jline.UnixTerminal
or even
-Djline.terminal=jline.UnsupportedTerminal
in your SBT_OPTS.
Finally what happens if you try a never version of SBT ? (you could try running the SBT 0.11 version of the lift example found here https://github.com/lacy/lift-quickstart).
Replace your Linux script by:
#!/bin/bash
java -Xmx512M -jar `dirname $0`/sbt-launch.jar "$#"
On your settings:
Your script sets Xss (the Thread stack size). In Linux you sometimes need to change (via ulimit) the settings for stack per thread (ulimit -s) as you may have conflicts at SO level which may be triggering the "kill" on your threads. Unless you have a very important reason to set this flag just remove it and let the JVM manage this.
It may also be you wanted to put Xms instead of Xss, although then 2M would make this flag irrelevant (heap too small to be practical)
The flag -XX:+CMSClassUnloadingEnabled allows GC to sweep the Perm space. It shouldn't be necessary for sbt. As you can read here the PermGen options will only pospone PermGen issues, so if you have problems with PermGen when running Jetty, just add a bigger PermGen via -XX:MaxPermSize

How do I pass an environment variable to a Netbeans Makefile on Ubuntu?

I'm using Netbeans on Linux (Ubuntu 9.04) to build a C project.
How do I pass in an environment variable so that's it's visible to the Makefile?
If I do a normal export MYVAR="xyz" and then run make from the command line this works fine of course.
But Netbeans doesn't seems to use the .bashrc environment, so if I click "build" in Netbeans, the make fails.
Interestingly, the problem doesn't seem to occur on MacOSX - I've added the variable to ~/.MacOSX/environment.plist, and that value is visible to Netbeans.
I found this post which suggested modifying ~/netbeans-6.8/etc/netbeans.conf. I've tried this, by adding -J-DMYVAR=xyz to the end of netbeans_default_options, ie:
netbeans_default_options="-J-client -J-Xverify:none -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-DMYVAR=xyz"
But this didn't seem to work.
Edit:
This answer is possibly not valid for Unity-based flavours of Ubuntu.
The issue is actually nothing to do with NetBeans - it's related to the Ubuntu (ie Gnome) Launcher.
As this blog post explains, you need to add variables to the rather obscure ~/.gnomerc (No Mercy? :) file in order for them to be passed to applications started with Launcher!
So just edit ~/.gnomerc and add the variables as you would to ~/.bashrc, eg:
export MYVAR="xyz"
and logout/login.

Resources