Reputation: 13475
I'm trying to migrate from Glassfish+Jersey+Weld to Jetty.
I have such a setup: gist of pom.xml, web.xml and Java launcher.
Application seems to start fine, but when serving any request I see that the field that should be injected by Weld (logger
) is null.
@RequestScoped
@Path("/foobar")
@Consumes({ ExtendedMediaType.APPLICATION_JSON,
ExtendedMediaType.APPLICATION_JAVASCRIPT })
@Produces({ ExtendedMediaType.APPLICATION_JSON,
ExtendedMediaType.APPLICATION_JAVASCRIPT })
public class EmailResource extends {
@Inject
private Logger logger;
@Override @POST
public Response create(EmailJob document)
throws URISyntaxException, ResourceException
{
logger.debug("Hi there!");
}
}
What is the problem?
update: Logger producer looks dubious, but it doesn't even get called:
/** This class uses CDI to alias Java EE resources into CDI beans. **/
public class Resources {
@Produces
public Logger produceLog(InjectionPoint injectionPoint) {
return LoggerFactory.getLogger(
injectionPoint.getMember().getDeclaringClass().getName());
}
}
Upvotes: 3
Views: 2965
Reputation: 4116
Hi Victor my answer as requested, I've blogged about this with embedded jetty. I've also pushed a fully working example to github that you can clone.
I don't see anything wrong in your gist, however could you show your Logger producer?
UPDATE:
I see a typo "BeanMnanager" in your code, but not sure if it is the cause
new Resource("BeanManager", new Reference("javax.enterprise.inject.spi.BeanMnanager",
"org.jboss.weld.resources.ManagerObjectFactory", null));
Upvotes: 3