grails 3.0.1 proxy settings - grails

I am new to Grails 3.0.1 and wonder how and where to set the correct Proxy settings. I know what my proxy configuration is - IP and port, but don't know where to place.
I am getting errors like these when trying to run grails command within my helloworld project:
ivo#ivotrisquel:~/grails/projects/helloworld$ grails --stacktrace
| Error Problem updating profiles from origin git repository (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.eclipse.jgit.api.errors.TransportException: https://github.com/grails/grails-profile-repository: cannot open git-upload-pack
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:139)
at org.grails.cli.profile.git.GitProfileRepository.fetchAndRebaseIfExpired(GitProfileRepository.groovy:140)
at org.grails.cli.profile.git.GitProfileRepository.createOrUpdateRepository(GitProfileRepository.groovy:109)
at org.grails.cli.profile.git.GitProfileRepository.getProfile(GitProfileRepository.groovy:56)
at org.grails.cli.GrailsCli.initializeProfile(GrailsCli.groovy:347)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:192)
at org.grails.cli.GrailsCli.main(GrailsCli.groovy:99)
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/grails/grails-profile-repository: cannot open git-upload-pack
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:524)
at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:309)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1115)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130)
... 6 more
Caused by: java.net.ConnectException: Connection timed out github.com
at org.eclipse.jgit.util.HttpSupport.response(HttpSupport.java:175)
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:475)
... 11 more
| Error Problem updating profiles from origin git repository

I had the same problem and solved it adding the proxy configuration to the GRAILS_HOME/bin/grails.bat file in the following way:
>set GRAILS_OPTS=%GRAILS_OPTS% -Dhttp.proxyHost=myProxy -Dhttp.proxyPort=myPort -Dhttps.proxyHost=myProxy -Dhttps.proxyPort=myPort -Dhttp.proxyUser=bob -Dhttp.proxyPassword=theBuilder
I believe there must be another way to configure the proxy in Grails 3.0.x but I haven't found it so far.
Regards

In linux adding the configuration
export GRAILS_OPTS="-Dhttp.proxyHost=myProxy -Dhttp.proxyPort=myPort -Dhttps.proxyHost=myProxy -Dhttps.proxyPort=myPort"
in the GRAILS_HOME/bin/grails.sh file. Resolve my problem in Netbeans 8.1

I adedd the following to my ~/.grails/ProxySettings.groovy file.
client=['http.proxyHost':'myproxy', 'http.proxyPort':'myport', 'http.proxyUser':'myusername', 'http.proxyPassword':'mypass', 'http.nonProxyHosts':'localhost']
currentProxy='client'

For GRAILS3 there is now enough documentation on how to setup proxy.
As said by #campos, in Windows you must
set GRAILS_OPTS=-Dhttp.proxyHost=myProxy -Dhttp.proxyPort=myPort -Dhttps.proxyHost=myProxy -Dhttps.proxyPort=myPort
but that makes correction only for half the way, because you also have to correct gradle engine, inserting in its gradle.properties values as below
systemProp.http.proxyHost=proxy.yourdomain.com
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=yourpass
systemProp.http.nonProxyHosts=localhost
There is complete explanation here and here for gradle. With all that on my Windows10 I can correctly compile and build packages behind my corporate proxy.

After long struggle I found the solution for windows environment
The following worked for me
set GRAILS_OPTS=-Dhttp.proxyHost=myProxy -Dhttp.proxyPort=myPort -Dhttps.proxyHost=myProxy -Dhttps.proxyPort=myPort -Dhttp.proxyUser=bob -Dhttp.proxyPassword=theBuilder

Related

How to fix Jenkins java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded

I upgraded from jenkins 2.219 to 2.272 (latest version as of this writing) and now getting the stack trace below when Jenkins starts.
Jenkins docs says that this happens due to the Configuration as Code plugin and to set the jvm args as -Dio.jenkins.plugins.casc.ConfigurationAsCode.initialDelay=9000. The docs also say to increment the value until the error goes away but so far I'm at 480000 and still getting the error. I also don't see that I have the Configuration as Code plugin installed anyway.
How can this be fixed?
java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded
at jenkins.model.Jenkins.save(Jenkins.java:3379)
at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3398)
at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2637)
at jenkins.model.Jenkins$16.run(Jenkins.java:3342)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins$5.runTask(Jenkins.java:1129)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused: org.jvnet.hudson.reactor.ReactorException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:50)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1162)
at jenkins.model.Jenkins.<init>(Jenkins.java:962)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:295)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:312)
For anyone having this issue, yes downgrading to https://get.jenkins.io/war-stable/2.263.1/ first is required. Then restart the service, then upgrade all of your plugins, then try the LTS upgrade again, at least for me it worked just fine.
More details about the issue here:
https://www.jenkins.io/doc/upgrade-guide/2.204/
SEVERE jenkins.InitReactorRunner$1#onTaskFailed: Failed
ConfigurationAsCode.init java.lang.IllegalStateException: An attempt
to save the global configuration was made before it was loaded If
you encounter this, you can tell the plugin to delay configuration for
an amount of time to give Jenkins time to load the global
configuration before the configuration is applied by the plugin.
To enable this set the
io.jenkins.plugins.casc.ConfigurationAsCode.initialDelay system
property to a number of milliseconds to delay the initialisation. The
required value will be dependant on aspects of your system (cpu/disk)
and configuration, and how it can be found is mostly a trial and
error. A suggestion would be to start with 5000 (5 Seconds) and then
increment by 2000 (2 seconds) until you no longer exhibit the issue
and finally add 1000 (1 second) for some extra safety. For example, to
delay the configuration by 9 seconds you would use something like the
following command java
-Dio.jenkins.plugins.casc.ConfigurationAsCode.initialDelay=9000 -jar jenkins.war. Exactly how and where you specify this option depends on
the installation method used to install Jenkins
However for me the workaround didnt work without first downgrading, upgrading all plugins, then finally upgrading the core again.
To avoid this issue beforehand when you actually have not installed the Casc plugin:
Update to https://github.com/jenkinsci/role-strategy-plugin/releases/tag/role-strategy-3.1 and you should be OK.
When jenkins is already in the faulty state:
download the hpi and drop the hpi file into JENKINS_HOME/plugins folder.
https://updates.jenkins.io/download/plugins/role-strategy/
(information taken from: https://github.com/jenkinsci/configuration-as-code-plugin/issues/1531)
I faced the same issue. I have downloaded the jenkins.war , the earlier version (2.263.1) from https://www.jenkins.io/download/ . Stopped the jenkins and replaced the war with my install directory(C:\Program Files\Jenkins). And started the jenkins.This works like a charm.
You can download the hpi and drop the hpi file into JENKINS_HOME/plugins folder. Usually the jenkins plugin directory will be under - /var/lib/jenkins/plugins/.
The link to get Role strategy hpi plugin - https://updates.jenkins.io/latest/role-strategy.hpi. And restart Jenkins using this command: systemctl restart jenkins.
My scenario was to upgrade the Jenkins to the latest version and then restore the data in it to work like it was working before.
While upgrading from Jenkins v2.263 to v2.303, I had the same error. The only thing which worked for me was to upgrade my global plugin i.e Role-based authorization strategy first, and then Jenkins. It worked like a crisp.
We had the same issue after we upgraded to the latest version.
After some searching we decided to go with a lower version which has LTS support, 2.263.1 in this case.
That version worked instantly so I think this error is a bug.
we has similar issue, resolved by downgrading the jenkins.war file downloaded from URL: https://get.jenkins.io/war-stable/2.263.1/
I have faced similar issue, and found that we don't need to downgrade version.
Below are the steps I performed and it worked for me
upgrade global plugin i.e Role-based authorization strategy first from Jenkins Console.
Here are steps which I have performed:
#on ubuntu, in /usr/share/jenkins:
sudo service jenkins stop
sudo mv jenkins.war jenkins.war.old
sudo wget https://updates.jenkins-ci.org/latest/jenkins.war
sudo chown -R jenkins:jenkins jenkins.war
sudo service jenkins start
I have the same error on Jenkins 2.332.2 and updated plugin role-strategy v483.v17281966f5c3.
I had to download the version 3.2.0 of the plugin and put it directly in the jenkins plugins folder. (previously I remove the existing '.jpi' file)
Then restarting Jenkins /etc/init.d/jenkins restart, and the issue has gone.
Thank you for the intel!

Jenkins Master: Updating plugin data fails

On my Jenkins Master, versio 2.203, when I'm trying to update the plugins, I have this error:
java.security.cert.CertificateException: No subject alternative DNS name matching updates.jenkins.io found.
at java.base/sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:207)
at java.base/sun.security.util.HostnameChecker.match(HostnameChecker.java:98)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:429)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:129)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:625)
I have tried the option JENKINS_JAVA_OPTIONS ="(..) -Djsse.enableSNIExtension=false" but didn't work.
Any idea what I can do?
Thank you.
Removing -Djsse.enableSNIExtension=false from the Jenkins Java options fixed it for me. On Ubuntu, I went to the etc/default/jenkins file, located JAVA_ARGS and removed -Djsse.enableSNIExtension=false from this line. You need to reboot the mahcine after that for the new settings to get in effect before you try to update the plugins again on Jenkins.

"Error occurred running Grails CLI: null" when running grails 3.0 command line

I'm trying to run grails list-profiles, but receive the following error:
snowch#snowch-ws2:~/repos$ grails list-profiles --stacktrace
| Error Error occurred running Grails CLI: null (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NullPointerException
at org.grails.cli.profile.git.GitProfileRepository.getAllProfiles(GitProfileRepository.groovy:72)
at org.grails.cli.profile.commands.ListProfilesCommand.handle(ListProfilesCommand.groovy:43)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:173)
at org.grails.cli.GrailsCli.main(GrailsCli.groovy:99)
| Error Error occurred running Grails CLI: null
My versions are:
snowch#snowch-ws2:~/repos$ grails --version
| Grails Version: 3.0.1
| Groovy Version: 2.4.3
| JVM Version: 1.7.0_75
This was on a fresh install of grails and gvm.
The command grails create-app myapp works without error.
This question is similar to Grails 3.0 error, nullpointer, however, that question does not state what command is being run.
After searching online, I found that I needed to set my GRAILS_OPTS environment variable as follows before running the command:
export GRAILS_OPTS="-XX:-UseSplitVerifier -Xverify:none"
Source of fix: https://grails.org/news/1292028
I have not figured out, what is the exact cause of the error, but it seems to occur if you try to run grails 3 in the system where grails 2 is also installed.
What I did to get the command run - I created the project in a new directory. The directory for my old grails app was:
/home/me/projects/oldgrailsapp
when I tried to execute the grails command in /home/me/projects it failed, but when I tried this in another directory /home/me/projects_new, it succeeded. So I guess that the problem was that old grails configuration was somehow interfering with the new one.
I also removed references to old grails and groovy versions from the PATH variable by editing .bashrc file in my home directory (I really do not know if it was needed).
I had same experience when I was working on "Building an Andoird Client" guide, I got the following message whenever I try to create an app in the same folder where I've created the first app grails-app :
| Error Error occurred running Grails CLI: null (Use --stacktrace to see the ful
l trace)
So obviously, when you create a grails app in folder containing "grails-app" directory, grails will consider this folder as full grails application, hence cannot create-app in that directory.
I used:
Grails 3.1.15
Java 1.8.0.101
Hope this help.
It worked for me now.
this was my setting
GRAILS_HOME=C:\Users\murali.solayappan\apps\grails-3.1.11
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_102
I received the same error while launching "grails" for the first time
**Error occurred running Grails CLI: connect timed out**
After reading GRAILS_HOME\bin\grails.bat i found that executing "grails" while in GRAILS_HOME dir makes some difference. So I did the same
Now i received error stating that GRAILS couldn't find a particular maven package from my mirror repository - printed my private nexus repository url. I know that's my private repo and not connected to internet.
so I changed the MY_HOME_DIR.m2\"settings.xml" with the one came by default in Maven.
After that executed "grails" while in %GRAILS_HOME% dir.
It worked like breeze !!! I got grails prompt.
C:\Users\murali.solayappan\apps>grails
| Enter a command name to run. Use TAB for completion:
grails> exit
Somethimes it happens when you have wrong version of grails installed for the project you want to run it on
try to run it somewhere else and see if you get the same error
i had the same issue because i was using Grails 1.3.5 witj Java 8 which are incompatibles. I changed with Java 7 and it works fine.

Grails hangs on command line

I just downloaded Grails 2.0.1.
Created a new project and then tried adding the mysql connector as per the documentation but Grails hangs at command prompt without any message. I tried to execute in verbose and stacktrace mode but it prints nothing.
I tried cleaning and re-executing but all the grails commands are getting stuck.
They don't print anything beyond "configuring classpath" message .
Please help.
Thanks
Cleaning .ivy cache helps
$HOME/.grails/ivy-cache
Had the same problem on grails 2.0.4.
The cause was one of the repos not responding and grails waits for it to timeout.
Setting log "verbose" in BuildConfig.groovy helped me find which repository caused the problem.
Try to add --offline to te command
$ grails clean --offline
worked for me, as I was stuck on configuring classpath due to unresolved dependencies.

Grails: server crashes when I recompile a file (when using datasources)

I'm using datasources in my Grails project.
When I edit a groovy file with server running I get the following error:
Running Grails application.. java.lang.IllegalArgumentException: Must
supply a resource type for JNDI configuration
How can I configure grails.naming.entries in Config.groovy to fix this?
Note: I'm using grails 1.3.6
Tks
I'm using 1.3.7 and hit the same issue. There's a couple bugs in the JIRA about this, looks like they were finally fixed in 2.0-M1. There's a patch for 1.3.1+ versions here, but I haven't tested that yet.
Link to possible patch: http://jira.grails.org/browse/GRAILS-7021

Resources