Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


how to deploy EJB 3.1 session bean in a war on Websphere 8.5


I also want the restful web service has the EJB 3.1's capacity.
My restful web service code as follow:

@Stateless
@Path("/tagServiceRS/{tagid}")
@Interceptors(TestTagServiceInterceptor.class)
public class TagServiceRS implements Serializable{
    private static final long serialVersionUID = 5L;
    private static final Logger log = LoggerFactory.getLogger(TagServiceRS.class);


    @EJB
    private TagTestService tagTestService;

    @PersistenceContext(unitName = "tag-ejb")
    private EntityManager entityManager;


    @GET
    @Produces("text/plain")
    public String findTagById(@PathParam("tagid") String tagid) {
       return "TAG";
    }


    /**
     * @return the tagTestService
     */
    public TagTestService getTagTestService() {
        return tagTestService;
    }

    /**
     * @param tagTestService the tagTestService to set
     */
    public void setTagTestService(TagTestService tagTestService) {
        this.tagTestService = tagTestService;
    }

When I deploy the war on the Websphere 8.5. The TagServiceRS was successful deployed as a restful web service.And I test it. It's OK.
But the TagServiceRS was failed deploy as a EJB session bean.
The TagServiceRS's entityManager and tagTestService fields are all null.
I see the log, there is no error or warning log.
Below is my TagTestServiceBean code.

@Stateless
public class TagTestServiceBean implements TagTestService, Serializable {

    private static final long serialVersionUID = 5L;
    private static final Logger log = LoggerFactory.getLogger(TagTestServiceBean.class);


    @Override
    public Tag testFindTagById(Long id) {
        log.info("testFindTagById ++++++++++++++++++++++++++++++++++++++++ invoked for id: {}", id);
        return new Tag();
    }

}

    @Remote
public interface TagTestService extends Serializable {

    /**
     * @param id
     *            the ID from database
     * @return a tag, may null
     */
    Tag testFindTagById(Long id);

}

asked Sep 13, 2013 in Java Interview Questions by anonymous
edited Sep 12, 2013
0 votes
16 views



Related Hot Questions



Walkin Jobs Opening



Government Jobs Opening


...