@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@hotm...>
> 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.
>
opensubscriber is not affiliated with the authors of this message nor responsible for its content.