tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: @WebService annotation & jpa remove
Date Tue, 21 Feb 2012 08:55:13 GMT
@LocalClient
public class CalculatorTest extends TestCase {
    @WebServiceRef(wsdlLocation = "
http://127.0.0.1:4204/webservice-security/CalculatorImpl?wsdl")
    private CalculatorWs ws;

    @EJB
    private AnEJb ejb;

    //START SNIPPET: setup
    private InitialContext initialContext;

    protected void setUp() throws Exception {
        Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
        properties.setProperty("openejb.embedded.remotable", "true");

        initialContext = new InitialContext(properties);
        initialContext.bind("inject", this);
    }
    //END SNIPPET: setup

    public void testInject() {
        assertEquals("ok", ejb.cst());
        assertEquals(3, ws.sum1(1, 2));
    }
}

worked fine for me
- Romain


2012/2/21 amber <amber63@hotmail.fr>

> A new question ...
>
> All tests are working well (Eclipse and Maven), now I want to add the
> @WebService annotation on my EJB.
>
> but at that point the EJBs are no more injected in my testing class (got a
> null pointer) :(
>
> /The interface :/
>
> @WebService(name = "IFooServiceBeanWS")
> public interface IFooServiceBeanWS {
>
>        @WebMethod(operationName = "listCategories")
>        List<Foo> loadAllCategories();
>
> }
>
>
> /the EJB/
>
> @WebService(endpointInterface = "org.foo.services.foo.IFooServiceBeanWS",
> serviceName = "FooWebService")
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
> @Stateless
> public class FooServiceBean {
>
>        ...
>
> }
>
>
> /The test class :/
>
> @ManagedBean
> class FooServiceBeanTest extends AbstractServiceTest {
>
>        @EJB
>        protected FooServiceBean catBean;
>
>        @WebServiceRef(
>            wsdlLocation = "http://127.0.0.1:4204/FooServiceBean?wsdl"
>    )
>    private IFooServiceBeanWS fooWs;
>
>    ...
> }
>
>
> /the catBen properties is not injected. At running i got thoses warnings :/
>
> ..
> 2012-02-20 17:12:43,587 WARN  [startup] Unresolved ejb reference
> "java:comp/env/org.foo.services.foo.FooServiceBeanTest/catBean" in bean
> "foo-services_test.Comp".  Will attempt resolution again at runtime.
> 2012-02-20 17:12:43,587 WARN  [startup] Unresolved ejb reference
> "java:comp/env/org.foo.services.foo.FooServiceBeanTest/catBean" in bean
> "FooServiceBeanTest".  Will attempt resolution again at runtime.
> ...
> 2012-02-20 17:12:46,408 WARN  [OpenEJB] Injection data not found in JNDI
> context:
> jndiName='comp/env/org.foo.services.foo.FooServiceBeanTest/catBean',
> target=org.foo.services.foo.FooServiceBeanTest/catBean
> ...
>
>
> Of course if I remove the @webService annotation (and @WebServiceRef) , all
> is working fine
>
> did I miss something?
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/WebService-annotation-jpa-remove-tp4406170p4406170.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message