CDI: Using Interceptors across different modules / bean archives

前端 未结 6 493
[愿得一人]
[愿得一人] 2021-02-05 11:18

My Java EE 6 application consists of a war and an ejb module packaged in ear file. I\'m using CDI for DI (i.e. I have a beans.xml file in both modules). I want to use a logging

6条回答
  •  无人共我
    2021-02-05 11:54

    I had exactly the same problem with my logging interceptor on JBoss 7 and fixed it by overlaying the complete interceptor's jar into the application.

    
        
            
                org.apache.maven.plugins
                maven-war-plugin
                2.4
                
                    
                        
                            com.github.t1
                            logging-interceptor
                            jar
                            WEB-INF/classes
                        
                    
                
            
        
    
    
    
        
            com.github.t1
            logging-interceptor
            1.1
            true
        
    
    

    You'll still have to activate the interceptor in the application's breans.xml.

    Not nice, but it works. In Java EE 7, it works without the activation by annotating the interceptor as @Priority.

提交回复
热议问题