Announcement Announcement Module
Collapse
No announcement yet.
Resource path not resolved as ServletContext resource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resource path not resolved as ServletContext resource

    When I load the resource in Example 1, it loads as a ServletContext resource. When I load the same resource in Example 2, it appears to load as a class path resource (see Text 1). It's my understanding that within a WebApplicationContext (this is within the WebApplicationContext), resource paths are automatically resolved as ServletContext resources by the context implementation (http://www.springframework.org/docs/...rceLoader.html). So, why is Example 2 not loading as a ServletContext resource like Example 1?

    - Nick

    Example 1:
    <bean id="config" class="com.turner.ide.common.config.PropertiesConf ig">
    <constructor-arg type="java.net.URL" value="/WEB-INF/tnt/config/tnt.properties" />
    </bean>

    Example 2:
    <bean id="config-init" class="org.springframework.beans.factory.config.Me thodInvokingFactoryBean">
    <property name="targetClass" value="com.turner.ide.common.config.ConfigFactory" />
    <property name="targetMethod" value="createConfig" />
    <property name="arguments">
    <list>
    <value>tnt</value>
    <bean class="org.springframework.beans.factory.config.Fi eldRetrievingFactoryBean">
    <property name="staticField" value="com.turner.ide.common.config.ConfigType.PRO PERTIES" />
    </bean>
    <value type="java.net.URL">/WEB-INF/tnt/config/tnt.properties</value>
    </list>
    </property>
    </bean>

    Text 1:
    2005-06-28 23:31:37,760 DEBUG DefaultListableBeanFactory Invoking setBeanName on BeanNameAware bean 'org.springframework.beans.factory.config.FieldRet rievingFactoryBean'
    2005-06-28 23:31:37,760 DEBUG DefaultListableBeanFactory Invoking BeanPostProcessors before initialization of bean 'org.springframework.beans.factory.config.FieldRet rievingFactoryBean'
    2005-06-28 23:31:37,760 DEBUG DefaultListableBeanFactory Invoking afterPropertiesSet() on bean with name 'org.springframework.beans.factory.config.FieldRet rievingFactoryBean'
    2005-06-28 23:31:37,760 DEBUG DefaultListableBeanFactory Invoking BeanPostProcessors after initialization of bean 'org.springframework.beans.factory.config.FieldRet rievingFactoryBean'
    2005-06-28 23:31:37,760 DEBUG DefaultListableBeanFactory Bean with name 'org.springframework.beans.factory.config.FieldRet rievingFactoryBean' is a factory bean
    2005-06-28 23:31:37,760 DEBUG BeanWrapperImpl Converting String to [class java.net.URL] using property editor [org.springframework.beans.propertyeditors.URLEdito r@1c09624]
    2005-06-28 23:31:37,760 INFO DefaultListableBeanFactory Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [c-factory-init,config,cp-factory-init,dataSource,jdbcTemplate,userDao,userAttribute Dao,multimediaDao,jdbcDriver,tntScheduleDataSource ,tntScheduleQueryFactory,tntScheduleTvScheduleDao, tvScheduler]; root of BeanFactory hierarchy}
    2005-06-28 23:31:37,760 ERROR ContextLoader Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'c-factory-init' defined in ServletContext resource [/WEB-INF/tnt/applicationContext.xml]: Error converting typed String value for arguments[2]; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.net.URL]; nested exception is java.lang.IllegalArgumentException: Could not retrieve URL for class path resource [WEB-INF/tnt/config/tnt.properties]: class path resource [WEB-INF/tnt/config/tnt.properties] cannot be resolved to URL because it does not exist
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.net.URL]; nested exception is java.lang.IllegalArgumentException: Could not retrieve URL for class path resource [WEB-INF/tnt/config/tnt.properties]: class path resource [WEB-INF/tnt/config/tnt.properties] cannot be resolved to URL because it does not exist
    java.lang.IllegalArgumentException: Could not retrieve URL for class path resource [WEB-INF/tnt/config/tnt.properties]: class path resource [WEB-INF/tnt/config/tnt.properties] cannot be resolved to URL because it does not exist
    at org.springframework.beans.propertyeditors.URLEdito r.setAsText(URLEditor.java:67)
    at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:982)
    at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:912)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doTypeConversionIfNecessary(AbstractBe anFactory.java:606)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doTypeConversionIfNecessary(AbstractBe anFactory.java:586)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:123)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveManagedList(BeanDefinit ionValueResolver.java:193)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:109)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:916)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:727)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:336)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:223)

  • #2
    bump

    Can anyone help me?

    Comment


    • #3
      Are you use the latest Spring version? If not - update it!

      Comment

      Working...
      X