Search code examples
javaejbjboss-seam

Getting Wrong Target exception on EJB local call


[TxPolicy] javax.ejb.EJBTransactionRolledbackException: Wrong target. class com.sample.mock.service.MockFinanceService for public long com.sample.mock.service.MockFinanceService.createFinancialTransaction(com.sample.mock.service.params.MockFinanceTrasactionParam)

My Stateless bean class is:

@Stateless(mappedName = "MockFinanceService")
public class MockFinanceService implements MockFinanceServiceLocal {
....
}

Local interface is:

@Local
public interface MockFinanceServiceLocal {
    public long createFinancialTransaction(MockFinanceTrasactionParam mockFinanceTrasactionParam);
}

I'm calling the service as follows:

MockFinanceServiceLocal mockFinanceServiceLocal = (MockFinanceServiceLocal) new InitialContext().lookup("FinanceEAR/MockFinanceService/local");
......
mockFinanceServiceLocal.createFinancialTransaction(mockFinanceTrasactionParam);

Please help me to understand what is wrong.


Solution

  • The reason is my application have a Ear scoped class loader settings. Otherwise local reference should work even from different ear deployed on the same server.