2
votes

I need help in making a call to EJB remote interface from Spring.

I have a legacy EJB deployed in my JBoss.

Ejb-jar.xml islisted below.

<session>
    <display-name>ServiceBean</display-name>
    <ejb-name>ServiceBean</ejb-name>
    <home>com.ejbproject.ejb.ServiceHome</home>
    <remote>com.ejbproject.ejb.Service</remote>
    <ejb-class>com.ejbproject.ejb.impl.ServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
</session>

I have a web application which uses Spring.The spring application context contains the following entry:

<jee:remote-slsb id="myServiceBean" 
                 jndi-name="ejb/ServiceBean" 
                 business-interface="com.myproject.account.ejb.ServiceBean" 
                 resource-ref='true'></jee:remote-slsb>

I created the business interface ServiceBean in web project and added all methods defined in remote interface define in ejb-jar.xml.

The web application is deployed in the same JBoss server. But when I try to deploy I am getting a naming exception 'ServiceBean' not bound. Do I have to add environment entries in web.xml to access the EJB (even if both the EJB and web application are deployed in same JBoss)?

1

1 Answers

1
votes

First of all, check real jndi-name of your ejb component, usually application server print some information about it in the log files. Then try to define slsb like this

<jee:remote-slsb
        id="taskStarter"
        jndi-name="ejb/TaskStarterBean#ru.TaskStarterRemote"
        business-interface="ru.TaskStarter"
        lookup-home-on-startup="false"
    />

I show my realization of this structure:

@Remote(TaskStarterRemote.class)
@Local(TaskStarterLocal.class)
@Stateless
public class TaskStarterBean implements TaskStarter

@Remote
public interface TaskStarterRemote extends TaskStarter

public interface TaskStarter