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

Unable to inject a URI with a fragment as a bean property value [SPR-7083] #11743

spring-projects-issues opened this issue Apr 8, 2010 · 1 comment
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug


Copy link

spring-projects-issues commented Apr 8, 2010

Olav Reinert opened SPR-7083 and commented

If I create a bean with a property of type, and try to initialize it in an XML bean definition file, I'm unable to define a URI instance with a fragment in it.

For example, consider the following bean definition

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

	<bean id="bean" class="TestInitURI">
		<property name="uriSpec" value="env://server#3" />
		<property name="uri" value="env://server#3" />

I apply this bean definition using the following test program:


import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;

public class TestInitURI {

    private String uriSpec;
    private URI uri;

    public void setUri(URI uri) { this.uri = uri; }
    public void setUriSpec(String uriSpec) { this.uriSpec = uriSpec; }

    public static void main(String[] args) {
        BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("beans.xml"));
        TestInitURI bean = beanFactory.getBean(TestInitURI.class);
        show("Bean property", bean.uri);
        show("Expected ", URI.create(bean.uriSpec));

    private static void show(String prefix, URI uri) {
        System.out.println(prefix + " URI " + uri + " (host=" + uri.getHost() + ", authority=" + uri.getAuthority() + ", path="
                + uri.getPath() + ", fragment=" + uri.getFragment() + ")");

The output is the following:

Bean property URI env://server%233 (host=null, authority=server#3, path=, fragment=null)
Expected  URI env://server#3 (host=server, authority=server, path=, fragment=3)

In other words, I would expect that defining a URI property in an XML bean definition file with a string constant is equivalent to initializing that property with a URI created by invoking URI.create(String) with the same string constant.

Affects: 3.0.2

Issue Links:

Referenced from: commits 03120b7

Copy link
Collaborator Author

spring-projects-issues commented Apr 9, 2010

Juergen Hoeller commented

Good catch - fixed for 3.0.3!

Will be available in tonight's 3.0.3 snapshot. Feel free to give it an early try...


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
None yet

No branches or pull requests

2 participants