Grails 2.4.4 compatibility with Java 8 - grails

I am having a legacy grails application that uses Grails 2.4.4 & has a runtime of Java7 / Tomcat7. We are planning to take it to Azure app service but azure supports runtime starting from java 8 / tc 8.5.
We are looking to upgrade the application to grails 2.5 as that seems to be supporting jdk8. Are there any pointers on how a 2.4.4 application could be migrated to 2.5 ?

I have done this already. There were some issues i had to solve but the error-logs and stackoverflow were my friends. I cannot provide a howto but if you just try it and send the errors you get i would be pleased to help you.

I was able to successfully get the application with a stack of grails 2.2.4 , java 1.7 , tomcat 7 migrated to grails 2.5.6 , Java 1.8 (compile) , tomcat 9 ( runtime java 11). Some of the hurdles i encountered are:
If your app uses JAXB , make sure that is available in app's runtime. With java 8 runtimes, they were available by default.
mailService Bean creation issues - Ran to issues with instantiating the mailService Bean & was resolved by setting the poolSize to 1 in the configuration.
txManager , sessionFactory instantiating issues - those were are settled by having the runtime jars - JaxB , marshaller etc. Though the stacktrace was misleading.

Related

Is there a version of Grails targeted to run on Java 9?

I tried running my Grails 3.3.2 application on Java 9 and for the most part the application worked. Mail (using this plugin: org.grails.plugins:mail:2.0.0), however, doesn't work, so cannot reset password, for example.
Attempting to send mail results in this error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailService': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException
I believe the issue is with Spring Boot and not the plugin itself. It seems there is a problem with bean creation and Java 9 that Spring Boot addresses is their 2.x version (Grails 3.3.2 runs on Spring Boot 1.5.x).
Just wondering what the time frame is for Grails and Java 9. Thanks!
The roadmap is for forth quarter this year (2018). Grails 4 will support Spring Boot 2 (which has just been released) and is the first version of Spring Boot which will support Java 9.
https://www.grails3book.com/blog/2018/2018-03-29-grails-jdk-9.html

Spring security not working with Grails project on JBoss Application Server

I have a big(multiple custom plugin based) Grails project, which runs perfectly fine on Tomcat server.
Now for a new customer we need to deploy it on JBoss Application server. It seems to deploy fine without any error but when I try to login on the first page which is implemented using Spring Security plugin. It does not log me in. I have tried going to a valid URL to check if its a problem of redirecting but it is not the case.
Please note it is not showing any error on the log. And since it is not properly executable in development environment so each time I need to build a WAR file to test it.
Grails version: 2.4.4
Spring security version: ':spring-security-core:2.0-RC4'
JBoss version: wildfly-9.0.2.Final
I tried some setups, and they all worked as a simple new project.
I used grails 2.4.4 and spring-security 2.0-RC4.
Here are a few things you could try:
Use latest spring-security version 2.0.0
compile "org.grails.plugins:spring-security-core:2.0.0"
Add jboss plugin and generate deployment xmls (this is needed for grails 2.5.4)
build ':jbossas:1.0'
$grails generate-boss-deploy 6
Create a brand new Wildfly install and deploy your app.
I can only think about a infrastructure problem, since I got no problem with the same setup. I running on Mac, with java 8 and Wildfly 9.0.2 final. Tested grails 2.4.4 and 2.5.4, spring security 2.0-RC4 and 2.0.0.
Best,
Eder

Create Glassfish windows service error

I have created glassfish service on window but could not start the service. I have checked the domain service error log and getting the following errors:
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.8', but '1.7' is required.
could not find java.dll
Could not find Java SE Runtime Environment.
I have upgraded from Java 7 to Java 8 and after upgrading service could no be started. How can I solve this poroblem
Ok! I had to delete the following files: java.exe, javaw.exe and javaws.exe
from System32 in order to work. Its working fine now.
If you're using any version of GlassFish below 4.1, it won't run on Java 8. You need to upgrade your GlassFish as well or, if that's not an option, revert to Java 7.

MissingMethodException in Grails Bootstrap on Tomcat

after updating my grails app's security plugins, i get the following error when deploying to tomcat:
2012-01-17 09:13:04,970 [pool-2-thread-1] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: static org.example.SecRole.findByAuthority() is applicable for argument types: (java.lang.String) values: [ROLE_USER]
the app works fine when being tested via run-app.
the SecRole class has been automatically generated by the spring security plugin.
i had previously deployed the app on the same server without a problem when using an older version of the spring security plugin.
have been knocking my head against this for hours. ideas much appreciated.
This is a bug in v1.2.7 of the plugin. I released v1.2.7.1 to fix it; you can also downgrade to v1.2.6.
Are you using your own Spring Security's User and Role class?
Did you tried to create a fresh grails project and install it with vacation request sample app to test it out?
Lastly, may I know which Grails version and OS you use?
Cheers,
Chee Kin
My prod Env: Tomcat 7, Fedora, Grails 1.3.7, activiti-spring-security 0.4.6, spring-security-core 1.2.7 activiti 5.8.2
Dev Env: Mac OS 10.6, Grails 1.3.7, activiti-spring-security 0.4.6, spring-security-core 1.2.7, activiti 5.8.2
I have installed vacation request app on fresh grails project and that works fine when I run using grails run-app (both in dev and prod mode).
As per Peter's comment above, upgrading to Grails 2.0 solved the problem I described above. However, I had subsequently run into a host of upgrade issues with the app.

grails 2.0 - recommend using Jetty 7 or Jetty 8?

Jetty 8 is in stable release and is now using Servlet Version 3 (here). Grails 2.0 indicates it has been updated to support Servlets Version 3 as well, and indicates Jetty 7 works with Grails 2.0, but makes no reference to Jetty 8 as of yet. Note the Jetty version information indicates Jetty 7 is Servlets Version 2.5 (not Version 3).
Have you run Grails 2.0 on Jetty 8? Can you give a recommendation on which Jetty version to use with Grails 2.0?
Thanks
You are correct, Jetty 8 is using Servlet Version 3. To let Grails take advantage of it, you have to set
grails.servlet.version = "3.0"
in your BuildConfig.groovy. Go here.
Please note that your Servlet 3.0 compiled web application won't run in a servlet container not supporting Servlet Version 3.
To answer your question: Running Grails 2 on Jetty 8 is possible in both flavours - Servlet Version 3.0 or below. I recommend to using it.

Resources