[jboss-user] [EJB/JBoss] - Queer error: java.lang.LinkageError: loader constraints viol

Subhash.Bhushan do-not-reply at jboss.com
Tue Mar 4 04:54:45 EST 2008


Hi,

I faced a queer error with JBoss 4.2.2 GA, so thought of reporting it even though I managed to circumvent the problem.

I have a stateless EJB LoginBean, with remote interface Login:

Remote Interface:
package com.justbooks.security;
  | 
  | import javax.ejb.Remote;
  | 
  | import com.justbooks.entities.Profile;
  | 
  | @Remote
  | public interface Login {
  | 	public boolean signOn(Profile profile);
  | 	public boolean signOn(String loginName, String loginPassword);
  | }
  | 
Bean Class:

  | package com.justbooks.security;
  | 
  | import javax.ejb.Stateless;
  | 
  | import com.justbooks.entities.Profile;
  | import com.justbooks.security.Login;
  | import javax.persistence.*;
  | import com.justbooks.utility.*;
  | 
  | public @Stateless class LoginBean implements Login
  | 

I have a DAO Stateless EJB called ProfileDAOBean, with remote interface  ProfileDAO:

Remote Interface:
package com.justbooks.dao;
  | 
  | import javax.ejb.Remote;
  | 
  | import com.justbooks.entities.Profile;
  | 
  | @Remote
  | public interface ProfileDAO {
  | 	public Profile findProfile(String loginName);
  | 	public boolean authenticate(String loginName, String loginPassword);
  | 	public boolean changePassword(String loginName, String oldPassword,
  | 			String newPassword);
  | 
  | }
  | 
Bean Class:

  | package com.justbooks.dao;
  | 
  | import javax.naming.Context;
  | import javax.naming.NamingException;
  | import javax.persistence.EntityManager;
  | import javax.persistence.PersistenceContext;
  | import javax.persistence.Query;
  | import javax.ejb.Stateless;
  | 
  | import com.justbooks.utility.EJBFinder;
  | import com.justbooks.entities.Profile;
  | import com.justbooks.security.ChangePassword;
  | import com.justbooks.security.Login;
  | 
  | public @Stateless class ProfileDAOBean implements ProfileDAO
  | 

If I include the lookup code for LoginBean inside ProfileDAOBean, then the application works just fine. But if I use a helper class to find EJBs, my application throws up an error saying anonymous wrote : 15:01:57,890 ERROR [[default]] Servlet.service() for servlet default threw exception
  | java.lang.LinkageError: loader constraints violated when linking com/justbooks/security/Login class

EJBHelper:
package com.justbooks.utility;
  | 
  | import javax.naming.Context;
  | import javax.naming.NamingException;
  | 
  | import com.justbooks.security.ChangePassword;
  | import com.justbooks.security.Login;
  | 
  | public final class EJBHelper {
  | 	private static Context getInitialContext() 
  | 		throws javax.naming.NamingException 
  | 	{
  | 	    return new javax.naming.InitialContext();
  | 	}
  | 	
  | 	public static Login getLoginEJB() {
  | 		try {
  | 			Context jndiContext = getInitialContext();
  | 			//TODO put these lookup strings in properties file
  | 			Object ref = jndiContext.lookup("JustAutomate/LoginBean/remote");			
  | 			Login login = (Login)ref;
  | 			return login;
  | 		}catch (NamingException ne) {
  | 			ne.printStackTrace();
  | 			return null;
  | 		}		
  | 	}
  | 	
  | 	public static ChangePassword getChangePasswordEJB() {
  | 		try {
  | 			Context jndiContext = getInitialContext();
  | 			//TODO put these lookup strings in properties file
  | 			Object ref = jndiContext.lookup("JustAutomate/ChangePasswordBean/remote");			
  | 			ChangePassword changePassword = (ChangePassword)ref;
  | 			return changePassword;
  | 		}catch (NamingException ne) {
  | 			ne.printStackTrace();
  | 			return null;
  | 		}		
  | 	}
  | }

If I change the name of the class to EJBFinder, then everything starts working fine again. Not sure what the problem is.

As of now, I have circumvented the problem by renaming the class from EJBHelper to EJBFinder.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133816#4133816

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133816



More information about the jboss-user mailing list