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

Java 8 introspection causes breakage with FreeMarker Configuration bean [SPR-12448] #17053

Closed
spring-projects-issues opened this issue Nov 17, 2014 · 6 comments
Assignees
Labels
in: core status: backported type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Nov 17, 2014

George Turner Jr opened SPR-12448 and commented

When using the following configuration for a Freemarker template in Java 8, Spring throws a java.beans.IntrospectionException. This configuration works fine with Java 7.

<bean class="freemarker.template.Configuration">
            <property name="templateLoader">
                <bean class="org.springframework.ui.freemarker.SpringTemplateLoader">
                    <constructor-arg>
                        <bean class="org.springframework.core.io.DefaultResourceLoader"/>
                    </constructor-arg>
                    <constructor-arg value="/freemarker"/>
                </bean>
            </property>
        </bean>

Affects: 4.0.5

Issue Links:

  • #16801 Java 8 bridge method handling can lead to false positive detection of autowired annotations

Referenced from: commits 282aded, 1f45dd2

Backported to: 4.0.8

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 18, 2014

Juergen Hoeller commented

I'm afraid I can't reproduce this: It works fine against Spring 4.1.2 on JDK 8u20 at least. Could you please specify your JDK version and your Spring version, and post the actual IntrospectionException that you're getting?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 18, 2014

George Turner Jr commented

We're able to reproduce with JDK 8u25, Spring 4.0.5.RELEASE. Here's the full stack trace:
Cannot create inner bean 'freemarker.template.Configuration#3105691e' of type [freemarker.template.Configuration] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'freemarker.template.Configuration#3105691e' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.FatalBeanException: Failed to obtain BeanInfo for class [freemarker.template.Configuration]; nested exception is java.beans.IntrospectionException: type mismatch between read and write methods
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
... 30 more

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 18, 2014

Juergen Hoeller commented

I'm afraid this works for me on JDK 8u25 as well. Any chance you could run your local setup against Spring 4.1.2 and/or 4.0.8? BTW, which FreeMarker version are you using there?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 19, 2014

George Turner Jr commented

I'm using Freemarker 2.3.20. It looks like this is resolved by moving to a later Spring version, 4.1.2 was successful for me. Thanks for the help.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 19, 2014

Juergen Hoeller commented

Alright, I'll assume that this has been fixed through other recent changes in both the 4.1.x and the 4.0.x line then. I'll add corresponding unit tests to both branches to be on the safe side and to avoid regressions in the future.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 27, 2015

Aaron Digulla commented

The underlying issue is that Java 8 enforces that a getter and a setter in a class have to have the same type. So you can't do this anymore:

public void setValue( String data ) { ... }
public Object getValue() { ... }

It has to be String or Object on both sides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: backported type: bug
Projects
None yet
Development

No branches or pull requests

2 participants