Question

[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.

Was it helpful?

Solution 3

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.

OTHER TIPS

There's a bug in some JBoss versions that produce this error when using the @Local interface and the server is configured to pass values by reference. If this is the case, then simply using @Remote instead of @Local should work. See: https://access.redhat.com/site/solutions/28349

Is there a reason why you're doing the lookup manually? Can't you inject the EJB?

@EJB
private MockFinanceServiceLocal mockFinanceServiceLocal;

public void myAction() {
    // ...
    mockFinanceServiceLocal.createFinancialTransaction(mockFinanceTransactionParams);
}

Also, you tagged the question as jboss-seam related. There's nothing in your question, or the problem it relates to, that is Seam-related...

You error suggests that you have problem on this line

mockFinanceServiceLocal.createFinancialTransaction(mockFinanceTrasactionParam);

What is mockFinanceTrasactionParam ? Where is it defined ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top