Take the 2-minute tour ×

I have an EJB class, UserAccess, which uses the Shiro class org.apache.shiro.subject.Subject.

I also have Web class, LoginController which references the same Subject class.

The controller code looks likes this:

public String login() {
    // UserAccess.login() returns null if login unsuccessful
    Subject subject = userAccess.login(getEmail(), getPassword());

    return subject != null ? "home" : "welcome";

When stepping into UserAccess.login() the following exception occurs:

java.lang.LinkageError: loader constraint violation: when resolving method "myapp.UserAccess.login(Ljava/lang/String;Ljava/lang/String;)Lorg/apache/shiro/subject/Subject;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, myapp/LoginController, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, myapp/UserAccess, have different Class objects for the type org/apache/shiro/subject/Subject used in the signature

In my web.xml I am defining a custom Shiro environment class so that I can control Shiro object lifecycles (I do this because then I allow CDI to manage class instances and can use injection, etc...)



<!--  make sure this filter-mapping comes before any other filter mapping -->


I've seen similar LinkageError issues posted on SO and elsewhere. Based on what I've read it seems that it is likely that two different JBoss ModuleClassLoaders are loading the Shiro class org.apache.shiro.subject.Subject, thus creating a conflict.

I'm stuck in that I don't know what to do to resolve the way the Shiro Subject class is getting loaded, so that it gets loaded only once.

Any ideas?


share|improve this question
add comment


Your Answer



Browse other questions tagged or ask your own question.