2017-12-06 2 views
0

-であるように、元のコレクションを注入し、私はプログラムを持っている:(TypeConverterDelegate.java:529は) - [java.util.ArrayListの]コレクション型のコピーを作成できません -

public static void main(String[] args) 
    { 
     ApplicationContext ctx = ServiceLocator.getApplicationContext(); <-- error 
.......} 

それは、以下のエラーメッセージがあります。私は[DEBUG]でJAVAから来ているようなこのエラーを取り除きたい。しかし、プログラムは引き続き実行できます。私はgoogleで検索しましたが、運はありません。私はまた、コードがどこに間違っているのか分からない。これを解決することは可能ですか?

14 Nov 2017 16:50:48,288 [DEBUG] (TypeConverterDelegate.java:529) - Cannot create copy of Collection type [java.util.ArrayList] - injecting original Collection as-is 
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection 
    at org.springframework.beans.TypeConverterDelegate.convertToTypedCollection(TypeConverterDelegate.java:524) 
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:201) 
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:104) 
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:415) 
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:657) 
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:558) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:852) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:422) 
    at org.springframework.context.access.ContextSingletonBeanFactoryLocator.initializeDefinition(ContextSingletonBeanFactoryLocator.java:143) 
    at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:384) 
    at com.xxxx.ServiceLocator.getApplicationContext(ServiceLocator.java:24) 
    at com.xxxx.main(mcrpt.java:115) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) 
com.xxxx.ServiceLocator.getApplicationContextで

(ServiceLocator.java:24)

package com.xxxx; 
     import org.springframework.beans.factory.BeanFactory; 
     import org.springframework.beans.factory.access.BeanFactoryLocator; 
     import org.springframework.beans.factory.access.BeanFactoryReference; 
     import org.springframework.context.ApplicationContext; 
     import org.springframework.context.access.ContextSingletonBeanFactoryLocator; 
     public class ServiceLocator { 
      private static ApplicationContext applicationContext; 

      protected ServiceLocator() { 
      } 

      public static ApplicationContext getApplicationContext() { 
       if (applicationContext == null) { 

        BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance("ApplicationContext.xml"); 
        BeanFactoryReference bfr = locator.useBeanFactory("applicationContext"); 
        BeanFactory factory = bfr.getFactory(); 
        applicationContext = (ApplicationContext) factory; 
       } 
       return applicationContext; 
      } 

     } 

applicationContext.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" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> 

    <bean id="applicationContext" 
     class="org.springframework.context.support.ClassPathXmlApplicationContext"> 
     <constructor-arg> 
      <list> 
       <value>ApplicationContext-properties.xml</value> 
       <value>ApplicationContext-log4j.xml</value> 
       <value>ApplicationContext-datasource.xml</value> 
      </list> 
     </constructor-arg> 
    </bean> 

</beans>  

答えて

0

あなたのBean定義が正しくありません。

置き換える:

<bean id="applicationContext" class="org.springframework.context.support.ClassPathXmlApplicationContext"> 
    <constructor-arg value="ApplicationContext-properties.xml" /> 
    <constructor-arg value="ApplicationContext-log4j.xml" /> 
    <constructor-arg value="ApplicationContext-datasource.xml" /> 
</bean> 

<bean id="applicationContext" class="org.springframework.context.support.ClassPathXmlApplicationContext"> 
    <constructor-arg> 
     <list> 
      <value>ApplicationContext-properties.xml</value> 
      <value>ApplicationContext-log4j.xml</value> 
      <value>ApplicationContext-datasource.xml</value> 
     </list> 
    </constructor-arg> 
</bean> 

関連する問題