2011-11-11 47 views
8

我試圖建立春天3.0.6庫作爲一個模塊中的JBoss 7彈簧組件7

我把所有模塊/組織/ springframework的/主以及以下模塊的罐子.XML

<module xmlns:"urn:jboss:module:1.0" name="org.springframework"> 
    <resources> 
      <resource-root path="org.springframework.beans-3.0.6.RELEASE.jar"/> 
      ... 
    </resources> 

    <dependencies> 
     <module name="javax.api"/> 
     <module name="javax.servlet.api"/> 
     <module name="org.apache.commons.logging"/> 
    </dependencies> 
</module> 

我加org.springframework的依賴線在我的MANIFEST.MF

當我部署的應用程序,同時解析我spring-servlet.xml文件(對不起,這是一個系統,是下面的異常被拋出沒有聯網)

SAXParseException: ... Cannot find the declaration of element 'beans' 

我首先想到的是,在不使用的模塊,但如果我從我的依賴關係刪除org.springframework排隊它未能找到org.springframework.web.context.ContextLoaderListener

一切工作正常,如果我把罐子放在WEB-INF/lib目錄,而不是使用該模塊。

spring-servlet.xml包含以下模式引用

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 

所以我把spring-beans-3.0.xsd在同一目錄spring-servlet.xml和修改XML以

http://www.springframework.org/schema/beans spring-beans-3.0.xsd 

但仍沒有運氣。

任何人都有一個想法,爲什麼類文件被發現,但XSD文件不是?

+0

是這樣命名的JAR:org.springframework.beans-3.0.6.RELEASE.jar或者beans-3.0.6.RELEASE.jar? –

+0

這個jar被命名爲org.springframework.beans-3.0.6.RELEASE.jar,其他人的命名方式類似於他們來自Spring發行版。當掃描模塊時,由於存在.index文件用於模塊中的每個罐子。 – Thevenin

+0

順便提一下,我在JBoss 7.0.2上嘗試了這個。 – Thevenin

回答

5

以防萬一,這是在評論中給出的鏈接消失,問題是

問題:

的命名空間的配置文件在META-INF,但該目錄 不可見的(也不是通過配置 JBoss的部署,structure.xml)

解決方案:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> 
     <deployment> 
      <dependencies> 
       <module name="org.apache.commons.logging"/> 
       <module name="org.springframework" > 
        <imports> 
         <include path="META-INF**"/> 
         <include path="org**"/> 
        </imports> 
       </module> 
      </dependencies> 
    </jboss-deployment-structure> 
+3

只是爲了澄清:該評論「也不能通過jboss-deployment-structure.xml配置」是來自以前版本的舊信息。現在它是可配置的,就像這個答案中的例子所示。 – eis

0

正面臨完全相同的問題。已經設立了一個彈簧組件在JBoss 7,然後部署我的應用程序時,面臨以下警告:

無法讀取模式文檔 「http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

我明白了Spring上下文文件是在閱讀上面評論中的鏈接後,無法訪問Spring Jars的模式定義。因此,應用程序沒有得到部署。但是那裏給出的解決方案並不適合我。但是jboss-deployment-structure.xml中的下面的代碼解決了這個問題。

解決方案

<module name="org.springframework.spring" meta-inf="export" export="true" /> 

新增meta-inf="export"屬性。