I need inject my EJB service into Spring-WS Endpoint:
@Stateless
public class MeteringPointService {
private static final int LIMIT = 100;
public Integer getResponseStatus() {
return new Random().nextInt(LIMIT);
}
}
@Endpoint
public class CreateMeteringPointEndpoint {
private MeteringPointService meteringPointService;
@PayloadRoot(localPart = "CreateMeteringPointRequest", namespace = "...")
@ResponsePayload
public CreateMeteringPointResponse handleRequest(@RequestPayload CreateMeteringPointRequest request) {
CreateMeteringPointResponse response = new CreateMeteringPointResponse();
Integer status = meteringPointService.getResponseStatus();
response.setResponseStatus(status);
return response;
}
public MeteringPointService getMeteringPointService() {
return meteringPointService;
}
public void setMeteringPointService(MeteringPointService meteringPointService) {
this.meteringPointService = meteringPointService;
}
}
I tried Spring
<jee:local-slsb id="meteringPointService" jndi-name="ejb/meteringPointService"
business-interface="service.impl.MeteringPointService"/>
<bean id="createMeteringPointEndpoint" class="ws.endpoint.CreateMeteringPointEndpoint">
<property name="meteringPointService" ref="meteringPointService"/>
</bean>
I tried @EJB(mappedName="") StackOverflow, RedHat
And also tried CDI @Inject from Java EE6 StackOverflow
...but nothing works. Can you help me? GlassFish 4.
I'm still getting errors during deployment like:
remote failure: Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleExc
eption: org.apache.catalina.LifecycleException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [service.impl.MeteringPointService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.facto
ry.annotation.Autowired(required=true)}. Please see server.log for more details.
Command deploy failed.
remote failure: Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleExc
eption: org.apache.catalina.LifecycleException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [service.impl.MeteringPointService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.inject.Inject()}. Please
see server.log for more details.
Command deploy failed.