Skip to content

<lang:groovy> tag in version 2.5 and higher doesn't work for refreshable Spring MVC endpoints [SPR-10689] #15317

@spring-projects-issues

Description

@spring-projects-issues

Dhaval Powar opened SPR-10689 and commented

THIS BUG LIES IN SPRING 2.5 AND HIGHER


Dynamic language support is added to Spring by using the <lang:> namespace.
For eg. for a groovy script, the following xml should handle dynamic language support in Spring.

<lang:groovy id="refreshableMessenger" 
    script-source="classpath:org/fw/scripting/groovy/Messenger.groovy"> 
    <lang:property name="message" value="Hello World!"/> 
</lang:groovy>

How this functions under the hood is:

  1. The <lang:groovy> instantiates the LangNamespaceHandler class which parses the xml and identifies the type of dynamic language ie. groovy, JRuby or BSH.

  2. LangNamespaceHandler then calls the registerScriptBeanDefinitionParser method which in turn, makes a call to registerBeanDefinitionParser to register the bean. The call to this method instantiates a ScriptBeanDefinitionParser object which does the following:

a. Resolve the script source
b. Set up infrastructure
c. Create script factory bean definition
d. and many more other specific functionalities....

In step (b.), to setup the architecture, the LangNamespaceUtils class sets up the scriptFactoryPostProcessor object. This object handles ScriptFactory definitions, replacing each factory with the actual scripted Java object generated by it.

The bug lies in the LangNamespaceUtils class due to an invalid variable initialization.

This class contains a variable name

SCRIPT_FACTORY_POST_PROCESSOR_BEAN_NAME="org.springframework.scripting.config.ScriptFactoryPostProcessor"

The value of this variable is invalid because the full qualified name of the ScriptFactoryPostProcessor class is org.springframework.scripting.support.ScriptFactoryPostProcessor.

This means that ScriptFactoryPostProcessor lies in the package org.springframework.scripting.support and NOT org.springframework.scripting.config. Due to this the ScriptFactoryPostProcessor bean does not get instantiated and the dynamic language support does not work.

However, this issue did not exist in Spring 2.0 & earlier since the <lang:grovy> xml namespace and tag were handled in a different way. Please fix the bug.


Affects: 3.1.2

Reference URL: http://grepcode.com/file/repo1.maven.org/maven2/org.springframework/spring-context/2.5/org/springframework/scripting/config/LangNamespaceUtils.java?av=f

Attachments:

Issue Links:

3 votes, 5 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: bulk-closedAn outdated, unresolved issue that's closed in bulk as part of a cleaning process

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions