0

Blockquote

I am trying to make a REST application with Seam 3. Hello world works nice. But I tried to use injection within the Rest Application with the annotation @Inject but the object is still null.

Does someone has a piece of code that initialize a component called within a REST Class ?

thanks a lot. web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<servlet>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <load-on-startup>1</load-on-startup>
    </servlet>
</web-app>

REST Application

@ApplicationPath("object")
@Path("creation")
@RequestScoped
public class ObjectApplication extends javax.ws.rs.core.Application {

@Inject   
ObjectManager objectManager;
....

@POST
@GET
@Path("create")
@Produces(MediaType.APPLICATION_XML)
@Consumes(MediaType.APPLICATION_XML)
public String createObject(ObjectType objectType) {
...
}
}

and Object Manager

@Stateless
public class ObjectManager {
}

.

20:30:50,362 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016008: Starting weld service for deployment ObjectRest.war
20:30:50,420 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deployment.unit."ObjectRest.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."ObjectRest.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ObjectManager] with qualifiers [@Default] at injection point [[field] @Inject com.qc.api.rest.ObjectApplication.objectManager]
Jan Groth
  • 14,039
  • 5
  • 40
  • 55
Antoine O
  • 171
  • 13

1 Answers1

0

How I succeed : Put all in the same project in eclipse. And remove :

<servlet-name>javax.ws.rs.core.Application</servlet-name>
    <load-on-startup>1</load-on-startup>
</servlet>

It seems that the problem was that there was two project :

XXXRest
 +--XXXCore

and the injection was not done...

Antoine O
  • 171
  • 13