I start a grails application (3.2.8) with "grails run-app". It takes the defaults and start at "http://localhost:8080".
From IntelliJ, or even from the windows terminal I invoke "grails stop-app" and I get the following message:
| Application not found via JMX, attempting remote shutdown.
| Shutting down application...
| Error Application not running.
In application.groovy I added:
grails.project.fork.run = true
with no effect.
What is the right way to stop the server? I particularly need it when I set dbCreate = 'create-drop' to clean the database.
Do you have this in your build.gradle?
bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always')
addResources = true
}
Otherwise do you have a g:include? Could be this issue:
https://github.com/grails/grails-core/issues/10411
I see this with the simplest of apps in 3.3.3. I tracked it down to permissions on the Spring Boot "shutdown" endpoint. I fixed it by adding the following to grails-app/conf/application.yml:
management:
security:
enabled: false
Since this works, I assume "grails stop-app" is essentially doing this:
curl -X POST localhost:8080/shutdown
I'm new to Grails, so there may be a better solution that doesn't require dropping down to the Spring Boot level.
Related
If I create a new web profile app, and generate-all, it runs fine in my local and deploys without error to JBoss. But when I try to access the app all URLs return 404. I know the app started up successfully, because it created tables in the database.
Here's what I'm doing.
grails 3.1.4> create-app demo
create-domain-class Book
create-domain-class Author
Edit domain classes
generate-all *
change tomcat dependency from compile to provided in build.gradle
change dataSource in application.yml to use my JNDI Oracle connection
Add server: contextPath: /demo to application.yml
run-app -> Works
gradle war
Deploy to JBoss EAP 6.4.0.GA
JBoss says deployment and activation of the app was successful. There are no errors of any sort in any JBoss log file. And dbCreate: update made the DDL changes to my Oracle database, so I know it got that far. But all URLs for the app return 404.
This is a known bug: Issue-9481
It has been added to grails 3.1.5 milestone.
I have an app that runs in multiple production environments. In one environment we want to authenticate with LDAP, in the other we do not. If the Spring Security LDAP plugin is included in BuildConfig.groovy, the non-LDAP environment fails to authenticate because LDAP is not configured.
I tried
environments {
devldap {
plugins {
compile ":spring-security-ldap:2.0-RC2"
}
}
}
but the LDAP plugin still builds with the non-LDAP environment and causes the non-LDAP environment (in this case development) to fail to authenticate if I don't include the LDAP configuration because it can't connect to LDAP.
I've tried
grails clean
grails refresh-dependencies
but the LDAP plugin only uninstalls if I completely comment it out.
How can I conditionally include/exclude a plugin in my build?
I see this question is a bit old now, however I do a similar thing with the Melody plugin. There is no value in this being installed during TEST - and can get in the way - so I do the following:
plugins {
// other plugins ...
if( Environment.current != Environment.TEST )
compile ":grails-melody:1.56.0"
// other plugins ...
}
So when I run 'test-app' I see the plugin 'uninstalled' and then when I do 'run-app' I see it installed and it's available.
NOTE: I recently got caught out by forgetting to also do an import grails.util.Environment. If you do that, you'll find that Environment.current == [:] as does Environment.TEST etc. I believe this is due to the builder behind the config file.
i've just upgraded my app to grails 2.3.4 and i'm implementing Cucumber and Geb test in order to keep it all covered.
The problem is that one of the requirements of the application that should only listen secure connections (https) so i added in config groovy
grails.plugin.springsecurity.auth.forceHttps = "true"
grails.plugin.springsecurity.secureChannel.definition = [
'/**':'REQUIRES_SECURE_CHANNEL'
]
Now, the problem is when i run grails test-app -https, is not working the param -https and only starts the application in non-secure channel.
Any ideas to run test-app in https?
Thanks in advance
Seems to be a Grails bug. I have submitted a pull request and also added a comment to this question.
I'm trying to use Grails new forked mode. I enabled it in BuildConfig.groovy file using
grails.project.fork.run = true
and now the tomcat server starts in "detached mode" as expected, but my application is not deployed.
I also configured an external directory where I put the war of my application, like this:
grails.project.autodeploy.dir = "../mywar"
but nothing changed.
Is there anything else I should do to configure forked mode?
I have a grails 2.2.1 app with mail plugin 1.0.1.
Mail delivery via Gmail smtp server works fine when I run the app locally (grails dev run-app), but fails on the production server (which is on the Jelastic cloud platform), which I deploy as a war file.
Config.groovy:
// Mail
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "aut********#gmail.com" // *** = just blacked out
password = "sun1******" // *** = just blacked out
props = ["mail.smtp.auth":"true",
"mail.smtp.starttls.required": "false",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
But I only have one mail plugin configuration, and therefore assume that the config applies for both development and production environment.
In fact, when I unzip the war file and check the class (in my case: Config$_run_closure2_closure8_closure13.class) via Decompiler, I can see the correct config values in there:
Enlarged: http://i.troll.ws/638ef33d.png
Error message:
Caused by: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 d47sm23030880eem.9 - gsmtp
at grails.plugin.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:104)
at grails.plugin.mail.MailService.sendMail(MailService.groovy:41)
at MailGrailsPlugin$_configureSendMail_closure6.doCall(MailGrailsPlugin.groovy:170)
at com.oritrack.core.ApiController.register(ApiController.groovy:212)
... 5 more
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 d47sm23030880eem.9 - gsmtp
at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:648)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:583)
at javax.mail.Service.connect(Service.java:291)
... 9 more
It is so weird that the authentication fails; so it's at least trying to connect to the right server; and the username/password in the Config.groovy is the only set of mail plugin config that I have in there. If it runs locally, it gotta run elsewhere.
When something works in development and not in production the usual culprit (from my experience) is dependencies. Check your WAR for multiple version of the same jar e.g. java-mail-1.0.jar and java-mail-1.2.jar. Don't limit your search to java-mail.jar, that was just an example.
If you find multiple versions of one jar, try removing one and deploying your war and if it works... huzzah!
To find what plugin is bringing in the jar use "grails dependency-report". Once you find out what is bringing in the jar you can remove it by doing something like this in BuildConfig.groovy using the excludes syntax.
dependencies {
compile("org.apache.shiro:shiro-quartz:1.1.0") {
excludes("quartz")
}
runtime('org.codehaus.groovy.modules.http-builder:http-builder:0.5.0') {
excludes 'xalan'
excludes 'xml-apis'
excludes 'groovy'
}
}
I have solved some very strange errors like this, one of them including http authentication that was failing due to multiple http-client jars.