I'm trying to evaluate CDI on Glassfish 3.1 and even though I have
accomplished to make it work well, when I'm trying to split my code in
separate deployment modules I get a weird error. More specifically:
1) I have two classes bundled in the same utility project (let's say the
CommonLib.jar); the classnames are *UserDatabase *and
*UserDatabaseEntityManager *and their definitions are as below (in the PS
at the end of this message).
2) I also have an EAR with an EJB3.1 module in it. In the EJB the
EntityManager is injected as below:
@Inject
@UserDatabase
EntityManager itemPersistenceEm;
* When I choose to deploy the *CommonLib.jar* as a "Bundled Library" of the
EAR, then I get the following error:
*/ Error occurred during deployment: Exception while loading the
app : WELD-001408 Unsatisfied dependencies for type [EntityManager] with
qualifiers [@UserDatabase] at injection point [[field] @UserDatabase @Inject
com.test.TestEJB./**/itemPersistenceEm]. Please see server.log for more
details. /*
* Same error as above I get also when I deploy the *CommonLib.jar *as a
shared library (jar file copied under
$glasshfish_installation_path/domains/domain1/lib)
* BUT, if I choose to just have the two classes (UserDatabase and
UserDatabaseEntityManager) in the EJB project (thus they are compiled
within the EJB module), then the injection works fine.
Am I facing a classloader issue? Any ideas how I can get past this issue?
Your help is greatly appreciated,
Alte
PS
Again the definitions of the two classes are:
*Qualifier UserDatabase as in Java EE 6 Tutorial:*
@Qualifier
@Retention(RUNTIME)
@Target({
METHOD,
FIELD,
PARAMETER,
TYPE
})
public @interface UserDatabase {
} *Producer for EntityManager*:
@Singleton
public class UserDatabaseEntityManager {
@Produces
@PersistenceContext (unitName="ItemPersistence")
@UserDatabase
private EntityManager itemPersistenceEm;
}
--
[Message sent by forum member 'altegama']
View Post: http://forums.java.net/node/789787