java ee - CDI beans inside .jar are not found by the container (Unsatisfied dependencies) -


i have created java project serve lib other projects, reducing code duplication between projects. lib project exported jar included in web projects (war, not ear).

in web projects (where these classes being removed) worked usual while classes kept on them ─ injection of simple , complex objects (those producers , settings) working normally.

after removing these classes of web projects , add jar these same classes web projects (setting lib in pom.xml in maven projects) compiled normally, before too. on start server, classes (cdi beans) present in jar not found container during startup of cdi, generating (famous) error:

weld-001408: unsatisfied dependencies type session qualifiers (...) 

already added beans.xml in meta-inf folder both in src/main/resources (indicated in weld , cdi documentation) root folder of project.

enter image description here

below examples of beans (session, sessionfactory , examplelogger) presents in jar needs injected other projects (and have worked while class in web projects) not being discovered cdi:

public class hibernateconnectionfactory {      @produces     @applicationscoped @connectionbaseexample     public sessionfactory createsessionfactoryexample() {         configuration configuration = new configuration();         configurarsessionfactory(configuration, "baseexampleds");         serviceregistry registry = new standardserviceregistrybuilder().applysettings(configuration.getproperties()).build();          return configuration.buildsessionfactory(registry);     }      @produces     @requestscoped @connectionbaseexample     public session createsessionexample(@connectionbaseexample sessionfactory sessionfactory) {         return sessionfactory.opensession();     }      public void destruirsessionexemplo(@disposes @connectionbaseexample session session) {         if (session.isopen()) {             session.close();         }     } } 
public class exampleloggerproducer {      @produces     public examplelogger createlogger(injectionpoint injectionpoint) {         return new examplelogger(injectionpoint.getmember().getdeclaringclass());     } } 

the problem occurs in maven projects , non-maven projects well. has faced problem? did know solution beans present in jar found container? thank in advance , sorry bad english.

java ee7, cdi 1.1, weld 2.1, server wildfly 8.1

trying again little time ago i've found solution ─ placed beans.xml on meta-inf folder inside project root folder , worked! that's against description of how work cdi beans inside jars on weld documentation, says place put beans.xml inside src/main/resources/meta-inf, okay. maybe in maven projects, that's true.

[update] works because building jar using export jar wizard of eclipse instead of using maven this. using maven should works fine beans.xml in src/main/resources/meta-inf.

hope can others on situation too.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -