2

Spring と Maven プロジェクトを使用しています。mit-parent の下にプロジェクト mit-webservices と mit-util プロジェクトがあります。

mit-webservices は mit-utils を使用しています。以下のように、mit-webservices の webapplicationContext.xml から mit-utils の applicationContext.xml をインポートしています。

<import resource="classpath:mit/utils/shared/applicationContext.xml" />

しかし、Eclipse で Tomcat の下で mit-webservices を実行すると、次のような例外が発生します。

Jun 23, 2012 2:35:50 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
Jun 23, 2012 2:35:50 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:vsm-webservices' did not find a matching property.
Jun 23, 2012 2:35:50 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 23, 2012 2:35:50 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 23, 2012 2:35:50 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 639 ms
Jun 23, 2012 2:35:50 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 23, 2012 2:35:50 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Jun 23, 2012 2:35:51 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jun 23, 2012 2:35:51 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Jun 23, 2012 2:35:51 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Sat Jun 23 14:35:51 PDT 2012]; root of context hierarchy
Jun 23, 2012 2:35:51 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [mit/webservices/webApplicationContext.xml]
Jun 23, 2012 2:35:51 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [mit/utils/shared/applicationContext.xml]
Jun 23, 2012 2:35:51 PM org.springframework.web.context.ContextLoader initWebApplicationContext
    SEVERE: Context initialization failed
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:mit/utils/shared/applicationContext.xml]
    Offending resource: class path resource [mit/webservices/webApplicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [mit/utils/shared/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [mit/utils/shared/applicationContext.xml] cannot be opened because it does not exist

私のmit-webservicesには、mit-webservices/webapplicationContextファイルをロードするjunitテストがあり、非常にうまく機能します。しかし、tomcat の下に mit-webservices をデプロイしようとすると、上記の例外がスローされます。

mit-utils.jar が存在する mit-webservices の /lib dire も確認しました。

展開する前に毎回 mvn clean install と mvn eclipse:eclipse を実行しました。Tomcat はデプロイ時にクラスパスで mit-util を見つけることができないと思いますが、なぜそれが起こっているのかわかりません。

私の WebApplicationContext.xml は

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util" xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">


    <import resource="classpath:mit/utils/shared/applicationContext.xml" />

    <context:component-scan base-package="mit" />

</beans>

そして、mit-webservicesの私のweb.xmlは

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <!-- Spring context -->

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:mit/webservices/webApplicationContext.xml </param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>ServletAdaptor</servlet-name>
        <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>mit.webservices.jaxrs</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>ServletAdaptor</servlet-name>
        <url-pattern>/resources/*</url-pattern>
    </servlet-mapping>

</web-app>

ありがとうございました

4

1 に答える 1

0

別の提案された解決策を試した後。Deployment Assembly の Eclipse で「エントリが見つかりませんでした: mit-jpa」が見つかりました。そこで、Eclipse WTP Eclipse プラグインをインストールします。次に、Tomcat を再デプロイすると、すべてが機能します。

于 2012-06-27T08:08:59.477 に答える