2011-08-09 7 views
1

私のFlexアプリケーション内からgetBanks()(BankService内にある)というメソッドを呼び出しています。ここでBankServiceクラスは次のとおりです。ファイルが見つかりません例外

@org.springframework.stereotype.Service("com.apollo.counterpartcontacts.service.BankService") 
@org.springframework.flex.remoting.RemotingDestination("com.apollo.counterpartcontacts.service.IBankService") 
public class BankService extends _BankService { 

    private Logger logger = LoggerFactory.getLogger(getClass()); 
    private ApplicationContext applicationContext; 
    private List<String> configHostResources = new ArrayList<String>(); 
    private List<String> configResources = new ArrayList<String>(); 

    private PersistenceManager persistenceManager; 

    @BeforeClass 
    public void beforeClass() { 
     try { 
      addConfigResource("application.xml"); 
      addConfigHostResource("application.xml"); 
     } 
     catch (UnknownHostException e) { 
      logger.error("Error loading host specific resource", e); 
     } 
     List<String> aList = new ArrayList<String>(); 
     aList.addAll(configHostResources); 
     aList.addAll(configResources); 
     String[] aConfigArray = new String[aList.size()]; 
     aConfigArray = aList.toArray(aConfigArray); 
     applicationContext = new ClassPathXmlApplicationContext(aConfigArray); 

     persistenceManager = (PersistenceManager) applicationContext.getBean("persistenceManager"); 
    } 
     void addConfigResource(String aConfigName) { 
      logger.info("Adding a config: " + aConfigName); 
      configResources.add(aConfigName); 
     } 

     public void addConfigHostResource(final String theSuffix) throws UnknownHostException { 
      String aHostName = InetAddress.getLocalHost().getHostName(); 
      String aConfigName = aHostName.toLowerCase() + "." + theSuffix; 
      logger.info("Adding a host config: " + aConfigName); 
      configHostResources.add(aConfigName); 
     } 

    private org.springframework.orm.hibernate3.HibernateTemplate hibernateTemplate; 

    @org.springframework.beans.factory.annotation.Autowired 
    public void setHibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate hibernateTemplateValue) { 
     hibernateTemplate = hibernateTemplateValue; 
    } 

    public org.springframework.orm.hibernate3.HibernateTemplate getHibernateTemplate() { 
     return hibernateTemplate; 
    } 

    public List getBanks(){ 
     beforeClass(); 
     List allBanks = persistenceManager.getBanks(); 
     return allBanks; 
    } 

} 

問題がbeforeClass()の呼び出しが次のエラーを生成することである:

flex.messaging.MessageException: org.springframework.beans.factory.BeanDefinitionStoreException : IOException parsing XML document from class path resource [apnycdtg7qgcq1.application.xml]; nested exception is java.io.FileNotFoundException: class path resource [apnycdtg7qgcq1.application.xml] cannot be opened because it does not exist 

この好奇心事は、apnycdtg7qgcq1.application.xmlが私のsrcフォルダに配置されていることですエラーが表示されている場所と同じ場所です。誰でも問題はここにありますか?

答えて

0

addConfigResourceおよびaddConfigHostResourceのような「リソース」という単語は、通常、クラスパスリソースを意味します。同様に、ClassPathXmlApplicationContextはクラスパス上のSpringコンテキストファイルを期待しています。ファイルをクラスパス上に移動してみてください。そうすればうまくいくはずです。

Mavenユーザーの場合は、src/main/resourcesに移動することを意味します。何か他のものを使ってビルドする場合は、そのツールがリソースを常駐する場所にファイルを移動するか、コンパイル時にXMLファイルをクラスパス(通常は.classファイルが生成される場所)にコピーします。

関連する問題