WELD-001408不满意的依赖项 [英] WELD-001408 Unsatisfied dependencies

查看:271
本文介绍了WELD-001408不满意的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常有名的错误,但我无法解决。
我正在为我的应用程序运行arqullian测试。
我已经按照正式文件完成了一切。
长期寻求解决问题的解决方案。

  16:49:42,713错误[org.jboss。 msc.service.fail](MSC服务线程1-4)MSC00001:无法启动服务jboss.deployment.unittest.war.WeldService:org.jboss.msc.service.StartException in service jboss.deployment.unit 。test.war.WeldService:org.jboss.weld.exceptions.DeploymentException:WELD-001408注入点[[field] @Inject com.test.test2中具有限定符[@Default]的类型[发件人]不满足的依赖关系。 ejb.AppManagerBean.sender] 
在org.jboss.as.weld.services.WeldService.start(WeldService.java:83)
在org.jboss.msc.service.ServiceControllerImpl $ StartTask.startService( ServiceControllerImpl.java:1811)[jboss-msc-1.0.2.GA.jar:1.0.2.GA]
在org.jboss.msc.service.ServiceControllerImpl $ StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[ rt.jar:1.7.0_13]
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)[rt.jar:1.7.0_13]
在java.lang.Thread .run(Thread.java:722)[rt.jar:1.7.0_13]
导致:org.jboss.weld.exceptions.DeploymentException:

WELD-001408类型不满足的依赖关系[发件人]与限定符[@Default]

在注入点[[field] @Inject com.test.test2.ejb.AppManagerBean.sender]
在org.jboss.weld.bootstrap .Validator.validateInjectionPoint(Validator.java:275)
在org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:244)
在org.jboss.weld.bootstrap.Validator.validateBean (Validator.java:107)
在org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:127)
在org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java :346)
在org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:331)
在org.jboss.weld.bootstrap.Weld Bootstrap.validateBeans(WeldBootstrap.java:366)
在org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)
在org.jboss.as.weld.services.WeldService。 start(WeldService.java:76)
... 5更多

我的测试类:

  package com.highstreetlabs.wlcome.rest; 

import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
import com.test.test2.ejb.AppManager;
import com.test.test2.ejb.Storage;
import com.test.test2model.Customer;
import com.test.test2.rest.model.ProximityModel;
import com.test.test2.util.EntityManagerProducer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.json.simple.parser.ParseException;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ejb.EJB;
import javax.inject.Inject;

@RunWith(Arquillian.class)
public class CustomerCollectionResourceTest {

@Deployment
public static WebArchive createTestArchive(){
return ShrinkWrap .create(WebArchive.class,test.war)
.addClasses(CustomerCollectionResource.class,EntityManagerProducer.class,
AppManager.class,Storage.class,
ParseException.class,Sender。类)
.addPackage(Customer.class.getPackage())
.addPackage(Result.class.getPackage())
.addPackage(NotFoundException.class.getPackage())
.addPackage(CustomerPhotoResource.class.getPackage())
.addPackage(ProximityModel.class.getPackage())
.addAsResource(import.sql)
.addAsManifestResource(EmptyAsset.INSTANCE ,META-INF / beans.xml)
.addAsManifestResource(test-ds.xml,test -ds.xml);
}

@Inject
CustomerCollectionResource资源;
@EJB
AppManager管理器;

@Test
public void testList()throws Exception {
resource = new CustomerCollectionResource();
resource.list(null);
}
}

AppManagerBean.java

  import com.google.android.gcm.server.Constants; 
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
import com.google.common.base.Strings;
import com.test.test2.json.JacksonObjectMapperProvider;
import com.test.test2.model。*;
import com.test.test2.rest.HttpStatusException;
import com.test.test2.rest.NotFoundException;
import com.test.test2.rest.model.ProximityModel;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ejb.Asynchronous;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence。*;
import javax.persistence.criteria。*;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.List;


/ **
*包含整个业务逻辑实现的无状态EJB bean
* /
@Local(AppManager.class)
@无状态
public class AppManagerBean实现AppManager {

public static final String
GCM_ENTER_ACTION =enter,
GCM_EXIT_ACTION =exit,
PARAM_DATA_JSON = nearModel,
PARAM_CUSTOMER_ID =customerId,
PARAM_ACTION =action;

@Inject
EntityManager em;

@Inject
发件人发件人;
....
}

最后一个类用于测试CustomerCollectionResource



  @Path(customer /)
@RequestScoped
public class CustomerCollectionResource {

final static int CACHEABLE_SECONDS = 0;私人AppManager经理
@EJB


@GET
@Produces(MediaType.APPLICATION_JSON)
public响应列表(@QueryParam(email)String email){

final List< ;客户和GT; entities = manager.listCustomers(email);

if(entities.size()== 0)
throw new NotFoundException(没有任何客户);

ListModel< ListItem> result = new ListModel< ListItem>(entities.size());
result.itemType = ListItem.MEDIA_TYPE;
final UriBuilder itemLink = UriBuilder.fromResource(CustomerResource.class); (客户实体:实体)
{
result.add(new ListItem(entity.getName(),itemLink.build(entity.getId())));
}
CacheControl cc = new CacheControl();
cc.setMaxAge(CACHEABLE_SECONDS);
cc.setPrivate(true);
return Response.ok(result).cacheControl(cc).build();
}


}

发件人制作人

  public class GcmSenderProducer {

@Resource String senderId;

@Produces public Sender getSender(){
return new Sender(senderId);
}

}


解决方案

是的,我也认为GcmSenderProducer丢失了,所以发送器类不能被强制注入,因为它看起来像没有无参数的构造函数,我猜这个构造函数。


I have a very famous error, but I can't solve it. I'm trying to run arqullian test for my application. I've done everything according to the official documentation. The long search for solution to the problem given nothing.

 16:49:42,713 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."test.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Sender] with qualifiers [@Default] at injection point [[field] @Inject com.test.test2.ejb.AppManagerBean.sender]
    at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_13]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_13]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_13]
Caused by: org.jboss.weld.exceptions.DeploymentException: 

    WELD-001408 Unsatisfied dependencies for type [Sender] with qualifiers [@Default] 

    at injection point [[field] @Inject com.test.test2.ejb.AppManagerBean.sender]
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:275)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:244)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:107)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:127)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:346)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:331)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)
    at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)
    at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
    ... 5 more

My test class:

package com.highstreetlabs.wlcome.rest;

import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
import com.test.test2.ejb.AppManager;
import com.test.test2.ejb.Storage;
import com.test.test2model.Customer;
import com.test.test2.rest.model.ProximityModel;
import com.test.test2.util.EntityManagerProducer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.json.simple.parser.ParseException;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ejb.EJB;
import javax.inject.Inject;

@RunWith(Arquillian.class)
public class CustomerCollectionResourceTest {

    @Deployment
    public static WebArchive createTestArchive() {
        return ShrinkWrap.create(WebArchive.class, "test.war")
                .addClasses(CustomerCollectionResource.class, EntityManagerProducer.class,
                        AppManager.class, Storage.class,
                        ParseException.class, Sender.class)
                .addPackage(Customer.class.getPackage())
                .addPackage(Result.class.getPackage())
                .addPackage(NotFoundException.class.getPackage())
                .addPackage(CustomerPhotoResource.class.getPackage())
                .addPackage(ProximityModel.class.getPackage())
                .addAsResource("import.sql")
                .addAsManifestResource(EmptyAsset.INSTANCE, "META-INF/beans.xml")
                .addAsManifestResource("test-ds.xml", "test-ds.xml");
    }

    @Inject
    CustomerCollectionResource resource;
    @EJB
    AppManager manager;

    @Test
    public void testList() throws Exception {
        resource = new CustomerCollectionResource();
        resource.list(null);
    }
}

AppManagerBean.java

import com.google.android.gcm.server.Constants;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
import com.google.common.base.Strings;
import com.test.test2.json.JacksonObjectMapperProvider;
import com.test.test2.model.*;
import com.test.test2.rest.HttpStatusException;
import com.test.test2.rest.NotFoundException;
import com.test.test2.rest.model.ProximityModel;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ejb.Asynchronous;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.*;
import javax.persistence.criteria.*;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.List;


/**
 * Stateless EJB bean containing entire business logic implementation
 */
@Local(AppManager.class)
@Stateless
public class AppManagerBean implements AppManager {

    public static final String
            GCM_ENTER_ACTION = "enter",
            GCM_EXIT_ACTION = "exit",
            PARAM_DATA_JSON = "proximityModel",
            PARAM_CUSTOMER_ID = "customerId",
            PARAM_ACTION = "action";

    @Inject
    EntityManager em;

    @Inject
    Sender sender;
....
}

And finally class for test CustomerCollectionResource

@Path("customer/")
@RequestScoped
public class CustomerCollectionResource {

    final static int CACHEABLE_SECONDS = 0;
    @EJB
    private AppManager manager;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response list(@QueryParam("email") String email) {

        final List<Customer> entities = manager.listCustomers(email);

        if(entities.size() == 0)
            throw new NotFoundException("There is no any customer");

        ListModel<ListItem> result = new ListModel<ListItem>(entities.size());
        result.itemType = ListItem.MEDIA_TYPE;
        final UriBuilder itemLink = UriBuilder.fromResource(CustomerResource.class);
        for (Customer entity : entities) {
            result.add(new ListItem(entity.getName(), itemLink.build(entity.getId())));
        }
        CacheControl cc = new CacheControl();
        cc.setMaxAge(CACHEABLE_SECONDS);
        cc.setPrivate(true);
        return Response.ok(result).cacheControl(cc).build();
    }


}

Sender Producer

public class GcmSenderProducer {

    @Resource String senderId;

    @Produces public Sender getSender() {
        return new Sender(senderId);
    }

}

解决方案

Yes, I also think the GcmSenderProducer is missing so the Sender class cannot be injected propperly since it looks like it has no no-arg constructor and I guess the constructor.

这篇关于WELD-001408不满意的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆