Quantcast

Message Resolver has not been initialized

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Message Resolver has not been initialized

mazzi
Defining more than one message resolver like this:

<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
        <property name="messageResolvers">
                <list >
                        <ref bean="messageResolver" />
                        <ref bean="externalMessageResolver"/>
                </list>
        </property>
</bean>

<bean id="messageResolver" class="org.thymeleaf.messageresolver.StandardMessageResolver">
        <property name="order" value="10" />
</bean>
<bean id="externalMessageResolver" class="org.mycompany.ExternalMessageResolver">
        <property name="order" value="20" />
</bean>

Always returns "Message Resolver has not been initialized" exception.

Reading org.thymeleaf.Configuration, it seems that something like this is missing in line 220 or so

            for (final IMessageResolver messageResolver : messageResolversList) {
                messageResolver.initialize();
            }

It's a bug? a feature? I'm doing something wrong? :)

Thanks in advance.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Message Resolver has not been initialized

danielfernandez
Administrator

Hi,

From the error message, I assume you are extending AbstractMessageResolver...

The "getter" methods in that class (for example, "getName()") are designed so that they return an error if the message resolver as not yet being initialized by calling "initialize()". This call to "initialize()" is made by the template engine --you shouldn't call it yourself--. Maybe you are calling a getter on your resolver before the template engine gets initialized?

It is a somewhat weird feature, this "initialize()" thing, I know... having a look at it in order to simplify it is in my TODO for next versions.

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Message Resolver has not been initialized

danielfernandez
Administrator
In reply to this post by mazzi

UPDATE: this was a bug. It's just been fixed, with good help from another user who was suffering exactly the same issue as you.

A new snapshot version (2.0.6-SNAPSHOT) has been uploaded to the maven repos fixing this. See http://www.thymeleaf.org/faq.html in order to learn how to use snapshots in your projects.

Thanks,
Daniel.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Message Resolver has not been initialized

mazzi
Thanks for the snapshot Daniel!

Yes, I was extending AbstractMessageResolver.
No, I wasn't calling getName().

I will try the snapshot and if something goes wrong I let you know.
Thanks again,
mazzi.
Loading...