0

StrutsとSpringIOCの統合を使用Spring OXMしますが、使用しません。Struts 1これは、アプリケーションが古いものであり、XMLバインディングを含むモジュールを追加しているだけであり、アプリケーションのアーキテクチャを変更するつもりがないためです。

ClasspathXmlApplicationContextOXMのBeanインジェクションを求めるアクションクラスがあります。

これが私のSpringContextXMLです。

<?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:oxm="http://www.springframework.org/schema/oxm"
  xsi:schemaLocation="
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/oxm 
     http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">

    <bean id="xmlMapper" class="com.st.mas.wmr.utils.xml.stifbinconv.XmlMapper">
        <property name="marshaller" ref="jaxbMarshaller" />
        <property name="unmarshaller" ref="jaxbMarshaller" />
    </bean>
    <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="contextPath" value="com.st.mas.wmr.utils.xml.jaxb.stifbinconv"/>
        <property name="validating" value="true"/>
    </bean>
</beans>

アクションクラス:

public class StifBinConversionAction extends AnyDispatchAction {
    private IProcessStifOliBinConversion svc;

    public StifBinConversionAction() {
        super();
        svc = new ProcessStifOliBinConversion();
    }

サービスクラス:

public class ProcessStifOliBinConversion
    implements
        IProcessStifOliBinConversion {
    private BasicDataSource ds;

    private IAtomStifOliBinConversion dao;
    private ApplicationContext ctx;
    private XmlMapper xmlMapper;

    public ProcessStifOliBinConversion() {
        super();
        ds = new BasicDataSource();
        //TODO consts
        ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
        ds.setUrl("jdbc:oracle:thin:@sglx482:1521:wmr");
        ds.setUsername("wmr_online");
        ds.setPassword("wmr_online");

        dao = new AtomStifOliBinConversion(ds);
        ctx = new ClassPathXmlApplicationContext("com/st/mas/wmr/utils/xml/stifbinconv/oxm-context.xml");
        xmlMapper = ctx.getBean(XmlMapper.class);
    }

Webアプリケーションは、エラーメッセージやスタックトレースHTTP 500 なしで表示します。ただし、の構成場所をClasspathXmlApplicationContext無効な場所に変更すると、Springは例外をスローします。

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [classes/com/st/mas/wmr/utils/xml/stifbinconv/oxm-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [classes/com/st/mas/wmr/utils/xml/stifbinconv/oxm-context.xml] cannot be opened because it does not exist

問題はSpringインジェクションにあるようです。

エラーがあるとイライラしますが、エラーメッセージはありません。それはあなたを何日も立ち往生させます。

ありがとう

意思

4

1 に答える 1

1

エラーがあるとイライラしますが、エラーメッセージはありません。それはあなたを何日も立ち往生させます。

??? エラーメッセージがあります:あなたのXMLはこの場所で見つかりません:

classes/com/st/mas/wmr/utils/xml/stifbinconv/oxm-context.xml

に悪いパラメータを渡していると思いますApplicationContext4.7.1.1ClassPathXmlApplicationContextインスタンスの構築-ショートカットの例を見てください。

次のようなディレクトリレイアウトを考えてみましょう。

com/
  foo/
    services.xml
    daos.xml
    MessengerService.class

'services.xml'および'daos.xml'で定義されたBeanで構成されるClassPathXmlApplicationContextインスタンスは、次のようにインスタンス化できます...

ApplicationContext ctx = new ClassPathXmlApplicationContext(
    new String[] {"services.xml", "daos.xml"}, MessengerService.class

おそらく、このコンストラクターでもそのパターンを使用する必要があります。

ctx = new ClassPathXmlApplicationContext("oxm-context.xml", XmlMapper.class);
于 2011-05-27T08:52:18.843 に答える