I want to change the httpPort from the default of 8080 for the Jetty Grails plugin. I cannot set the Jetty httpPort property via a system property and/or Gradle property.
System property: gradle jettyRun -DjettyHttpPort=9090
Gradle property (gradle.properties): jettyHttpPort=9090
Right now you have to make a change to your Gradle build script (like adding a configuration task) to make this work. There are JettyPluginConventions with a function to setHttpPort(int) but I do not know how to implement it.
http://www.gradle.org/releases/1.0-milestone-3/docs/javadoc/org/gradle/api/plugins/jetty/JettyPluginConvention.html#setHttpPort(java.lang.Integer)
http://www.gradle.org/jetty_plugin.html
I had the same problem, and documentation for Gradle is very general and vague. I sometimes think that only Gradle developers are able to get full potential of this great tool :)
Right now the way is to add following to gradle build script:
jettyRun {
httpPort = 9000
}
It looks you cannot set this value in command line. There was an issue for that, GRADLE-1224, but it was closed as "Won't Fix" because
The Jetty plugin has been deprecated and is scheduled to be removed with Gradle 4.0. We are not going to work on this issue anymore.
You can set properties like httpPort via JettyPluginConvention
convention.plugins.jetty.httpPort = 9090
You can start with below command
gradle jettyRun -DhttpPort=9000
However, the task jettyRunWar doesn't seem to pick port 9000 and still uses default port. May be a bug in gradle jetty plug-in.
Have you tried -Djetty.port=9090 as a JVM parameter?
Related
We upgraded to Grails 4 / Java 11 and lost hot-swapping capabilities during development. I tried DCEVM but the application wouldn't start (errors on first withNewSession call).
Has anyone had success with getting Grails and DCEVM to work together?
I've got hotswap working with Grails 5.1.2 but the Hibernate plugin causes a
org.hibernate.HibernateException: No Session found for current thread
so I had to disable the plugin. This means any changes to domain classes will still need a restart.
You'll need a copy of groovyReset.jar to avoid random errors due to Groovy caching methods that have been replaced by hotswap.
sdk install java 11.0.9-trava
sdk use java 11.0.9-trava
Add a copy of groovyReset.jar to your project root
Add the following to the bootRun jvmArgs in build.gradle:
'-XX:HotswapAgent=fatjar',
'-javaagent:groovyReset.jar'
Create src/main/resources/hotswap-agent.properties containing:
disabledPlugins=Hibernate
autoHotswap=true
You should now be able to start Grails and any code changes will be picked up without restarting.
Recently I tried with Hybris2005 + Java 11 + Windows + Eclipse.
Follow below given steps and do modification as per your need.
DCEVM 11 Configuration Step.
Download and extract java11-openjdk-dcevm-windows.zip in your local machine
Set JAVA_HOME=D:\java11-openjdk\dcevm-11.0.10+3 (Adjust the path as per location in your system)
In eclipse go to windows->Preference->Installed JRE and set JRE home to D:\java11-openjdk\dcevm-11.0.10+3
4 In local.properties adjust the property tomcat.debugjavaoptions as below
tomcat.debugjavaoptions=-XX:HotswapAgent=core -javaagent:D:/java11-openjdk/dcevm-11.0.10+3/lib/hotswap/hotswap-agent.jar=disablePlugin=Log4j2,disablePlugin=Spring,disablePlugin=Proxy,disablePlugin=AnonymousClassPatch,disablePlugin=ZK,autoHotswap=true -Djava.locale.providers=COMPAT,CLDR -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n -Xmx4G -Xms2G
Also, please set ANT_HOME environemnt variable so that we don't to run setantenv.bat from \hybris\bin\platform and update the PATH variable accordingly.
Perform ant clean all and start hybris in debug mode.
Add System.out.println() statement in your code and then execute ant build command from that specific extension folder.
Verify if HOT swap is done.
I had a tough time to set the port of a Grails project to something other than 8080. The project was set up with Gradle. I tried all the ways I can think of and found on Google but it does not work. The methods I tried include
./gradlew run -PgrailsArgs="-Dgrails.server.port.http=9090"
./gradlew run-app -PgrailsArgs="-Dgrails.server.port.http=9090"
./gradlew grails-run-app -PgrailsArgs="-Dgrails.server.port.http=9090"
./gradlew run -Dgrails.server.port.http=9090
./gradlew -Dgrails.server.port.http=9090 run
./gradlew grails-run-app -PgrailsArgs="--port=9090"
as well as out the grails.server.port.http property in build.properties, Config.groovy and build.grade. None works. It is hard.
Probably grail run-app may work with one of the above option (also using BuildConfig.groovy). But "grails run-app" always resulted a resolving error for org.aspectj:aspectjweaver:1.8.5. I don't see how to get around this way either.
Any help will be greatly appreciated.
You can also set port like this
-Dgrails.server.port=9090
when you start server using Gradle. It works for me
You are using incorrect property name I guess i.e. grails.server.port.http. It should be server.port.Hence try ... -Dserver.port=8256 etc.
Also, you could specify it in your build.gradle task which you are using to run your application as below. For example you are doing it for springboot application using gradle bootRun.(I actually don't have much working experience in grails 3.0 but have in springboot)
bootRun {
systemProperty 'server.port', '8086'
}
This will run your application on 8086 port.
In general, you could try
gradle your_task_to_run_app -Dserver.port=your_port
Also, if you have application.yml in grails 3 app(as grails 3 uses gradle and springboot.If not present you should be able to create one) then do it like below:
app:
name:Springboot+Config+Yml+Demo
version:1.0.0
settings:
counter:1
---
spring:
profiles:development
server:
port: 9001
security:
user.name: 'default'
user.password: 'default'
Let me know it works or not as haven't tried but pretty sure that it will work.
Edit: More this should help!
Hope it helps!
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
Is there any "adequate" way to change system properties in Jenkins? What is the easiest/fastest way change them? For instance, I need to turn off the useless (in my case) pinging thread.
If you really want a quick and simple way to change a system property, you can use the script console
System.setProperty("hudson.remoting.Launcher.pingIntervalSec", 0)
But that won't survive a restart. To make it permanent, add the setting to the java args. For me (CentOS, Jenkins 2.7.1) that's a line about halfway down /etc/sysconfig/jenkins (for other distributions I believe it's /etc/default/jenkins) where you should add your option to the existing list like this:
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.remoting.Launcher.pingIntervalSec=0"
You'll have to restart Jenkins after you make that change (thanks Mark Tickner)
If you run Jenkins on windows as a service without tomcat, you can edit jenkins.xml. Add the property in <service><arguments> before the -jar.
Than restart the service.
<service>
<!-- ... -->
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dhudson.tasks.MailSender.SEND_TO_UNKNOWN_USERS=true -Dhudson.tasks.MailSender.SEND_TO_USERS_WITHOUT_READ=true -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
The system properties available and how to set them are listed on the wiki:
https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties
To disable slave pinging, you can set hudson.remoting.Launcher.pingIntervalSec to 0.
System properties can be set in the same way as with any other Java program, e.g.:
java -Dhudson.remoting.Launcher.pingIntervalSec=0 -jar jenkins.war
If you use Tomcat on Windows you can edit the File C:\apache-tomcat-7.0.67\conf\catalina.properties and simply add the Line
hudson.DNSMultiCast.disabled=true
at the End of the File. Then safe the File and restart Tomcat.
I have the similar problem: I need to disable DNSMultiCast (set hudson.DNSMultiCast.disabled = false) and I can't understand how to do it
for example, https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties - there is such advice "...pass all of these arguments before the -jar argument..." but I run jenkins under tomcat so I am not sure I can change startup parameters.
I tried to change /etc/tomcat6/Catalina/localhost/jenkins.xml to
<?xml version="1.0" encoding="UTF-8"?>
<Context >
<Environment name="JENKINS_HOME" value="/var/jenkins"
type="java.lang.String" override="false"/>
<Environment name="hudson.DNSMultiCast.disabled" value="true"
type="java.lang.Boolean" override="false"/>
</Context>
but I didn't help.
Can someone explain how to change jenkins system properties when tomcat is used.
Maybe it's a bad hack but I set it in the pipeline job that needs the setting.
Like this:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "") // allow formatted HTML pages to be published
It seems to work - as far as I can tell...
I followed each steps mentioned above but it fails.
So I did change the system time zone using timedatectl set-timezone Europe/London command and then I have restarted jenkins service service jenkins restart it worked.
I was using Rehdat 7.5
Jenkins version 2.168.
Jenkins Installed via yum install jenkins
I hope this will help some one.
Does anyone know how to beat such chars in Jenkins console output log?
Seems there is a problem with UTF-8.
The issue here is that the characters are not being output as UTF-8 to your console. I think the solution is to tell jenkins when you invoke it to write output as UTF-8. See this solution for a similar problem UTF-8 char encoding does not work on console (Linux)
Something like
java -Dfile.encoding=UTF-8 jenkins.war might do the trick
In Jenkins ver. 2.46.2, I just got this to work by going to Nodes, Advanced settings, JVM Options and putting -Dfile.encoding=UTF8 and then taking that node offline and online again. Hope this helps other people. It would be great if UTF8 support was default.
To give the the answer more complete.
If you use an tomcat container to run jenkins, then edit catalina.sh config file:
vim apache-tomcat-path/bin/catalina.sh
Add -Dfile.encoding=UTF-8 to the JAVA_OPTS var and restart tomcat will do the trick.
For those who are using a build-agent and a pipeline, add this to the agent's dockerfile, and no further jenkins settings are needed
ENV JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8
Try to change the encoding with you are opening your file to 'utf-8' and check your encoding saved for the script in vs code(whatever platform)
enter image description here
I've tried everything with file.encoding variable, but didn't work.
My solution was to check environment locale variables in Jenkins Controller and Agent node where job is actually runing, and make them match.
In my case, agent node running the job required environment variable "LC_ALL=C.UTF-8", which was already defined in controller node.
More details here: https://stackoverflow.com/a/68217405/3284482
Try using AnsiColor plugin in Jenkins. This worked for me. I had tried all the above solutions but nothing happened. As I downloaded AnsiColor plugin everything got fixed!