Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes not applied with version 1.3.0 for Grails 4 & 5 #235

Open
purpleraven opened this issue Mar 17, 2023 · 8 comments
Open

Changes not applied with version 1.3.0 for Grails 4 & 5 #235

purpleraven opened this issue Mar 17, 2023 · 8 comments

Comments

@purpleraven
Copy link

purpleraven commented Mar 17, 2023

For grails 4 I'm using version 1.2.8 of spring-loaded. It works well, except reloading of methods with @transactional
grails/grails-core#12630 (comment)

But during upgrade to grails 5.2.6 for one of my applications I got a jvm crash during application startup with for some GORM classes
grails/grails-core#11649 (comment)

With spring-loaded 1.3.0 (and also with springloaded-1.3.0.BUILD-20210404.024037-2.jar provided by @Dirk-27 grails/grails-core#11649 (comment)) application starting up well, but changes in a code not applied during reload:
I see recompilation in the log, but behaviour of application not changed.
For example I have added to a controller action logs, but don't see it during action execution (throwing exception too)

I have seen same problems with grails 4 and spring-loaded 1.3.0 before. Also I have checked this new version of library with another three grails 5* applications and see a same problem. Working well, but no result =)

Java corretto-1.8.0_362

build.gradle
configurations {
  agent // for hot reload
  developmentOnly
  runtimeClasspath {
    extendsFrom developmentOnly
  }
}

dependencies {
   agent files('lib/springloaded-1.3.0.BUILD-20210404.024037-2.jar')//"org.springframework:springloaded:1.3.0.RELEASE"
//  developmentOnly("org.springframework.boot:spring-boot-devtools")
....
}

application.groovy

...
spring.devtools.restart.enabled = false
...

and repeat it in application.yml (just for test)

spring:
    devtools:
        restart:
            enabled: false

What I'm duing wrong??

springloaded-1.3.0.BUILD-20210404.024037-2.zip

@purpleraven
Copy link
Author

purpleraven commented Mar 17, 2023

Test application. test-grails5.zip

After startup by run-app with open http://localhost:8080/test/index and see OK
Change TestController render "Ok" to render "NO"

Refresh page, see

Grails application running at http://localhost:8080 in environment: development
File /home/xxx/IdeaProjects/test-ppp/grails-app/controllers/test/ppp/TestController.groovy changed, recompiling...

But in browser the same responce Ok

@Dirk-27
Copy link

Dirk-27 commented Mar 20, 2023

Sorry, we don't tried grails 5 yet. And in grails 4 everything works well. We use openjdk version "1.8.0-292".

@purpleraven purpleraven changed the title Changes not applied with version 1.3.0 Changes not applied with version 1.3.0 for Grails 4 & 5 Mar 20, 2023
@purpleraven
Copy link
Author

purpleraven commented Mar 20, 2023

@Dirk-27 I have the same problem with grails 4.

test-grails4.zip

Probably I'm doing something wrong

@Dirk-27
Copy link

Dirk-27 commented Mar 20, 2023

Yes: you don't use the jar I mentioned but added a dependency 'agent...'. Then you get the wrong springloaded version. I get your test-xxx running by

  1. comment the agent line in dependency section
  2. add the jar line: jvmArgs('-javaagent:libs/springloaded-1.3.0.BUILD-20210404.024037-2.jar', ...

Download the file (exactly this one: springloaded-1.3.0.BUILD-20210404.024037-2.jar) and save it to (new folder) libs in your project before.

@purpleraven
Copy link
Author

purpleraven commented Mar 20, 2023

Update: java 11 has been used. Works with grails 4

@Dirk-27

I have added agent to bootRun

bootRun {
    ignoreExitValue true
    jvmArgs(
        '-Dspring.output.ansi.enabled=always', 
        '-noverify', 
        '-XX:TieredStopAtLevel=1',
        '-Xmx1024m',
        '-javaagent:libs/springloaded-1.3.0.BUILD-20210404.024037-2.jar')
    sourceResources sourceSets.main
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

But I'm getting error

Listening for transport dt_socket at address: 40979
java.lang.RuntimeException: Reloading agent exited via exception, please raise a jira
	at org.springsource.loaded.agent.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:110)
	at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:246)
	at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
	at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:563)
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:398)
	at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:791)
	at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:686)
Caused by: java.lang.IllegalArgumentException
	at sl.org.objectweb.asm.ClassReader.<init>(Unknown Source)
	at sl.org.objectweb.asm.ClassReader.<init>(Unknown Source)

test-grails4.zip

@Dirk-27
Copy link

Dirk-27 commented Mar 20, 2023

Here your sources work on my computer. When a 'grails clean' didn't work for you my only idea is the different JDK you use.

@purpleraven
Copy link
Author

@Dirk-27 everithing works with grails 5 too.

do I need the agent line in the configuration?

configurations {
    agent // for hot reload
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

What differrence between released 1.3.0 and springloaded-1.3.0.BUILD-20210404.024037-2.jar ?

After tersing I will ask grails team to update documentation.

@Dirk-27
Copy link

Dirk-27 commented Mar 20, 2023

The both lines I changed (commented agent line and added in the jvmargs) was all have changed. And I don't know what the different in the jar is, but this is the last build and it works. (- I'm out of office for today)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants