简体   繁体   中英

Access EJB 3.0 as an EJB and as a web service on Websphere 7

I want to deploy an EJB 3.0 stateless bean to WAS7 so I can access it as an EJB through a local interface and also as a jax-ws web service.

My bean looks as following:

@Stateless
@WebService
public class UserManagerImpl implements UserManager {
    public UserManagerImpl() {
    }
    @WebMethod
    public String getName(){
        return "UserName";
    }
}

The problem is that if I package it into an EJB-JAR and deploy, it doesn't work as a web service on WAS-7.

The only working configuration for me is if I put the EJB-JAR into a EAR and put this EJB-JAR to a WAR that is also in the EAR, like this:

EAR/
   |--EJB-JAR
   |--WAR/
         |WEB-INF/lib/
                     |EJB-JAR 

So my bean is duplicated.

Is there any problem with this design? If so, is there a better solution?

If your application contains @WebService annotated EJBs, then you need to process the EAR with the endptEnabler tool shipped with WebSphere before deploying it. Note that this doesn't apply to @WebService annotated classes in Web modules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM