Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7068691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:21:17+00:00 2026-05-28T05:21:17+00:00

I have a small Spring (3.1.0.RELEASE) application, which was working just fine, until I

  • 0

I have a small Spring (3.1.0.RELEASE) application, which was working just fine, until I decided I need to have a Converter for converting stuff from Strings to other types.

My application context file includes another file, mvc-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:p="http://www.springframework.org/schema/p"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
   http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

    <mvc:annotation-driven />
    <mvc:view-controller path="/" view-name="index"/>
    <mvc:resources mapping="/resources/**" location="/resources/"/>

    <mvc:interceptors>
        <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
    </mvc:interceptors>

    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
       <property name="defaultLocale" ref="finnishLocale"/>
    </bean>
    <bean id="finnishLocale" class="java.util.Locale">
       <constructor-arg index="0" value="fi" />
    </bean>

   <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"
      p:definitions="/WEB-INF/config/tiles-config.xml"/>

   <bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
       <property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView"/>
   </bean>

</beans>

This works fine. The problem occurs, when I add the following bean definition to the above file:

<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
    <property name="converters">
        <list>
            <bean class="fi.mydomain.app.converter.StringToClassConverter"/>
        </list>
    </property>
</bean>

(Which, by the way, is exactly the same bean shown in Spring documentation, apart from the converter class). I’ve also modified the the annotation-driven line like this:

<mvc:annotation-driven conversion-service="conversionService"/>

(The problem occurs, though, by merely adding the conversionService bean).

(I also do have the fi.mydomain.app.converter.StringToClassConverter class written).

The problem is that now the application cannot be deployed anymore. The log file shows an error message:

2012-01-16 17:55:30,427 [http-8080-7] ERROR ContextLoader.initWebApplicationContext() - Context initialization failed
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'tilesViewResolver' defined in ServletContext resource [/WEB-INF/config/mvc-config.xml]:
Error setting property values; nested exception is  org.springframework.beans.PropertyBatchUpdateException;
nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
Property 'viewClass' threw exception; nested exception is java.lang.IllegalArgumentException:
Given view class [null] is not of type 
[org.springframework.web.servlet.view.AbstractUrlBasedView]

And when I remove the conversionService bean from the xml, everything works again, except of course, that I cannot use my own converters.

I’ve spent hours with this to no avail. Any help would be appreciated. Thanks.

—
Hannu

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:21:18+00:00Added an answer on May 28, 2026 at 5:21 am

    I found out that the problem emerges from my Converter. It was defined like this:

    final class StringToClassConverter implements Converter<String, Class>, InitializingBean {
    
        private Map<String, Class> map = new HashMap<String, Class>();
    
        public Class convert(String key) {
           return map.get(key);
        }
    
        public void afterPropertiesSet() throws Exception {
            map.put("organizations", Class.forName("fi.mydomain.app.domain.Organization"));
            map.put("invoices", Class.forName("fi.mydomain.app.domain.Invoice"));
        }
    }
    

    This gave me the symptoms described in the original question. When I changed the Converter to this:

    final class StringToClassConverter implements Converter<String, Object>, InitializingBean {
    
        private Map<String, Object> map = new HashMap<String, Object>();
    
        public Object convert(String key) {
           return map.get(key);
        }
    
        public void afterPropertiesSet() throws Exception {
            map.put("organizations", Class.forName("fi.mydomain.app.domain.Organization"));
            map.put("invoices", Class.forName("fi.mydomain.app.domain.Invoice"));
        }
    }
    

    That is, after I replaced Class with Object, the application started working again. I do not understand what’s wrong in the first Converter, though, and I’m not completely happy with the solution either, but I guess that will have to do now.

    — Hannu

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i have a small application with spring and i've been adding security which
I have a small application that doesn't use Spring container. Now there's a need
I am developing a small Spring application. I have to store the details of
I have a spring web application (currently packaged as a war file) which I
I have a small Spring MVC webapp (which embeds ActiveMQ) that is designed to
I have a small Spring based application and one of my classes needs additional
We have a small project with some heavy-weight dependencies (e.g. Spring) of which we
I have been working with a small project recently which involves Struts 2 and
I have a small algorithm which replaces the position of characters in a String:
I have small page which has label, DropDownList and a submit button. <div> <asp:label

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.