Problem To Make REST And SOAP Webservice Work In A Simlpe Web Application (Doc ID 1989407.1)

Last updated on MAY 24, 2017

Applies to:

Oracle WebLogic Server - Version 12.1.3.0.0 and later
Information in this document applies to any platform.

Symptoms

Simple web application which exposes both a REST Service and a SOAP Webservice could be packaged in a WAR file.

 

The 2 Service class are :
- TESTMediaLibraryREST for the REST service
- TESTMediaLibraryWS for the SOAP Webservice

TESTMediaLibraryREST.java

-------------------------------------
@WebService
@Stateless
public class TESTMediaLibraryWS
{
   @WebMethod(operationName = "trouverCD")
   @OperationSLD
   public CompactDisc findCD(@WebParam(name = "id") final String p_identifiant)
   {
   
      final CompactDisc cd = new CompactDisc();
      cd.setTitle("Titre = " + p_identifiant);
      return cd;
   }

}

TESTMediaLibraryREST.java

-----------------------------------
//@Stateless
@Path("/items")
public class TESTMediaLibraryREST
{
   @GET
   @Path("book/{id}")
   @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
   @OperationSLD
   public Book findBook(@PathParam("id") final Long p_identifiant)
   {
      final Book book = new Book();
      book.setTitle("Titre " + p_identifiant);
      return book;
   }

}

- TESTMediaLibraryWS works fine when declared @Stateless and @WebService AND TESTMediaLibraryREST is not declared @Stateless.

- TESTMediaLibraryREST fails when @Stateless annotation is enabled.

Ex:
----
@Stateless
@Path("/items")
public class TESTMediaLibraryREST  {}

@Stateless
@WebService
public class TESTMediaLibraryWS {}
----

Example application :
1/ is based upon Oracle's Java EE 6 example application
2/ deploys fine with just two EJBs within a war (not exposed with jax-ws or jax-rs).
3/ crashes as soon as exposed EJBs with jax-ws and jax-rs, as reported.

Throws below Exception:

AVERTISSEMENT: An instance of EJB class fr.pe.sldng.itest.rest.service.TESTMediaLibraryREST could not be looked up using simple form name. Attempting
to look up using the fully-qualified form name.
javax.naming.NameNotFoundException: While trying to look up comp/env/TESTMediaLibraryREST in /app/webapp/test-exposition-rest-ws.war/2746819.; remaining name 'comp/env/TESTMediaLibraryREST'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1180)
        at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:143)
        at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:253)
        at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:426)
        at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)
        at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
        at javax.naming.InitialContext.lookup(InitialContext.java:411)
        at weblogic.jaxrs.onwls.deploy.ejb.provider.EJBComponentProviderFactory.lookupSimpleForm(EJBComponentProviderFactory.java:98)
        at weblogic.jaxrs.onwls.deploy.ejb.provider.EJBComponentProviderFactory.lookup(EJBComponentProviderFactory.java:70)
        at weblogic.jaxrs.onwls.deploy.ejb.provider.EJBComponentProviderFactory.getComponentProvider(EJBComponentProviderFactory.java:50)

 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms