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
GroovyDynamicElementReader tries to read a Groovy script as XML and fails [SPR-11627] #16250
Comments
Abhijit Sarkar commented Curious, how's this an "improvement"? A bare bone context loader handles the file just fine, seems more like a bug.
|
Sam Brannen commented Abhijit Sarkar, you may be interested in watching #15858, since it will add explicit support for loading contexts from Groovy scripts in the testing framework. |
Juergen Hoeller commented I suppose I'm missing something here: In regular operations, we're setting GroovyBeanDefinitionReader's internal XmlBeanDefinitionReader to non-validating, which means you'd never run into that validation mode exception to begin with. So I assumed that you're invoking GroovyDynamicElementReader using a different code path, which we could make more defensive (and that'd be an improvement)... Or are we talking about Boot calling into this in some custom way? Juergen |
Abhijit Sarkar commented I'm not invoking groovyDynamicElementReader directly all and I don't think I'm doing anything special. Please see my configuration below: client-config.groovy
MovieDatabaseRESTClientIntegrationTest.groovy
MovieDatabaseApplication.groovy
The PatchedSpringApplicationContextLoader is needed because of this bug #16251. It is really SpringApplicationContextLoader with a bugfix (spring-boot-603), as the name suggests. SpringApplicationContextLoader is the loader used by SpringApplicationConfiguration. |
Sam Brannen commented FYI: I see several issues with your configuration.
Note that
In general, you need to select "one entry point" into your configuration. This is how production code works, and this is how test code works. You can always import other styles. For example, JavaConfig can import XML; XML can import JavaConfig; Groovy can import XML; etc. Hope this helps clarify things a bit for you. Regards, Sam |
Abhijit Sarkar commented I understand the points you brought up; let me explain why I chose that configuration and you can tell me if I'm doing something wrong (which's possible).
That's why I use
To your last point, I don't want to use any XML or Java |
Dave Syer commented To your point (2), I see no reason why I think you are mistaken in point (1) (also not related to the current issue): I'm not even sure why you would use The code you posted in the link on Stackoverflow (https://github.com/abhijitsarkar/groovy/tree/master/movie-database) might reveal more about your intentions, so I'll have a look. |
Dave Syer commented Maybe the original issue here is just that the Spring |
Abhijit Sarkar commented I've more clarification to make but first I'd like to know how to do inline code blocks? That'd help the readability; I already tried with backquotes once, it didn't work, don't want to do it again. |
Dave Syer commented It's Textile markup so double-braces is inline code (e.g. |
Abhijit Sarkar commented Thanks Dave. So what I wanted to clarify is that is to your point earlier that there's no test case to prove AbstractSpringIntegrationTest.groovy
GenericGroovyContextLoader.java
|
Abhijit Sarkar commented Tested today with 4.0.4.BUILD-SNAPSHOT and the following works. I wanted to confirm that if I specify the
or the other way around:
|
Abhijit Sarkar commented I'm not sure why one works and the other doesn't. I wanted to put the information out hoping that it might give a clue to someone who knows the code more than me. |
Sam Brannen commented Hi guys, I'm following up on Juergen's initial comments...
Abhijit's custom
This constructor creates its own
The difference is that Spring Boot's
And this constructor does not disable validation for the supplied So I guess one solution would be for Spring Boot's Of course, I haven't tested it, but it's a thought... ;) Regards, Sam |
Abhijit Sarkar commented Actually just setting the |
Sam Brannen commented I don't think it's a good idea to set the Keep in mind that the That's why I recommended using the Regards, Sam |
Abhijit Sarkar opened SPR-11627 and commented
GroovyDynamicElementReader tries to read a Groovy script as XML and fails.
Affects: 4.0.3
Reference URL: http://forum.spring.io/forum/spring-projects/boot/746962-groovydynamicelementreader-tries-to-read-a-groovy-script-as-xml-and-fails
Issue Links:
The text was updated successfully, but these errors were encountered: