2016-05-04 23 views
0

私は多くのWARファイルで構成されたマルチモジュールプロジェクトに取り組んでいます。プロジェクトでは、依存関係を管理するためにSpring 4.0.5を使用し、AOPをサポートするためにロード時間織りでAspectJ 1.8.5を使用します(Spring基本AOPサポートはこのプロジェクトではenoghではありません)。AspectJの読み込み時間EARのデプロイされたクラス内で正常に動作しません

<aspectj> 
    <aspects> 
    <!--No need to specify any aspect here--> 
    </aspects> 
    <weaver options="-XnoInline -verbose"> 
    <include within="com.myproject..*" /> 
    </weaver> 
</aspectj> 

AOPは、様々なサービスやDAOにトランザクションの動作と(@Serviceと@Repositoryでanotated)を提供するために主に使用されている(と:また、非常にシンプルな構成でMETA-INFディレクトリ内aop.xmlがあります春の@トランザクションアノテーション)。たとえば:

@Service(value = "alertService") 
public class AlertServiceImpl implements IAlertService, Serializable { 
    ... 
    @Transactional(rollbackFor = Exception.class) 
    @Override 
    public Alert createAlert(Alert alert) { 
    alertDAO.create(alert); 
    return alert; 
    } 
    ... 
} 

または抽象基本DAOそこからアプリケーションのDAOにの残りの部分は

@Repository 
public abstract class BaseDAO<E extends IBusinessObject, PK extends Serializable> { 
    ... 
    @Transactional(readOnly = true) 
    public <C extends E> C findFirstByFields(Class<C> type, String[] fields, Object[] values, String[] dependencies) 
     throws ModelException { 
    List<C> list = findAllByFields(type, fields, values, null, null, 1, null); 
    if (list.isEmpty()) { 
     return null; 
    } else { 
     C obj = list.get(0); 
     loadDependencies(obj, dependencies); 
     return obj; 
    } 
    } 
    ... 
} 

が最後にプロジェクトが建物のためにMavenを使用したJBoss EAP 6.1上で実行されます継承します。

この構成では、WARファイルのビルドとデプロイ時にすべてがうまく動作します。しかし、私が内部にそれらのWARファイルの1つのみで単純なEARファイルを構築すると、読み込み時間はすべてのクラスを作成しますが、1つはBaseDAOです。

私はこれまで何度も苦労してきましたが、アプリケーション起動時には、EAR内でBaseDAOが織り込まれていないことを除けば、両方のケースでほとんど同じになります。なぜ私は理解できません。なぜこれが起きているのか?

PD:

... 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure1' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure3' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure5' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.subproject.services.Repository$AjcClosure1' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.model.dao.BaseDAO$AjcClosure1' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.model.dao.BaseDAO$AjcClosure3' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.model.dao.BaseDAO$AjcClosure5' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.model.dao.BaseDAO$AjcClosure7' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.subproject.model.dao.LastDocumentNumberDAO$AjcClosure1' 
... 

しかし、内部のこの戦争とEARの起動時に、BaseDAOクラスが完全に無視されています:AspectJの織りログを有効にすると、WARからアプリケーションを起動するときにこれを示して最後に

... 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure1' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure3' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure5' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.subproject.services.Repository$AjcClosure1' 
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.subproject.model.dao.LastDocumentNumberDAO$AjcClosure1' 
... 

答えて

0

私たちは問題がどこにあるかを見つけました。これはjboss-deployment-structure.xmlにあります。 プロジェクト内のすべての戦争一部の除外を持つ独自のJBoss-展開するstructure.xmlを持っていた:

<jboss-deployment-structure> 
    <deployment> 
    <!-- Exclusions allow you to prevent the server from automatically adding some dependencies --> 
    <exclusions> 
     <module name="org.apache.log4j" /> 
     <module name="org.slf4j" /> 
     <module name="org.apache.commons.logging" /> 
     <module name="org.log4j" /> 
     <module name="org.jboss.logging" /> 
     <module name="org.javassist" /> 
     <module name="org.hibernate.validator" /> 
     <module name="org.jboss.ws.cxf" /> 
    </exclusions> 
    <exclude-subsystems> 
     <subsystem name="webservices" /> 
    </exclude-subsystems> 
    </deployment> 
</jboss-deployment-structure> 

しかし、EARの展開にEARの特定のJBoss-展開するstructure.xmlは、クラスローダがで働いていたので、行方不明になりました私の質問に投稿する問題を作成する、非常に異なる方法です。 EARのMETA-INFにjboss-deployment-structure.xml(EARの1つ、つまりWARの組み合わせ)を入れるだけで問題は解決されました。

これは、同様の問題を抱えている人に役立ちます。

関連する問題