Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running CDI-Uni t3.0.1 in Weld 2.2.1.Final #58

Closed
jack-jjy opened this issue Jul 15, 2014 · 13 comments
Closed

Error when running CDI-Uni t3.0.1 in Weld 2.2.1.Final #58

jack-jjy opened this issue Jul 15, 2014 · 13 comments

Comments

@jack-jjy
Copy link

         <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core</artifactId>
            <version>2.2.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jglue.cdi-unit</groupId>
            <artifactId>cdi-unit</artifactId>
            <version>3.0.1</version>
        </dependency> 

when running:

        09:50:08.338 [weld-worker-3] WARN  org.jboss.weld.Validator - WELD-001440: Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private org.jglue.cdiunit.ContextController.listener
        Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type WeldListener with qualifiers @Default
        at injection point [BackedAnnotatedField] @Inject @ApplicationScoped private org.jglue.cdiunit.ContextController.listener
        at org.jglue.cdiunit.ContextController.listener(ContextController.java:0)
        at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:370)
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:291)
        at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
        at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:165)
        at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:529)
        at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
        at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
@jack-jjy
Copy link
Author

also:

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type WeldListener with qualifiers @Default
    at injection point [BackedAnnotatedField] @Inject @ApplicationScoped private org.jglue.cdiunit.ContextController.listener
    at org.jglue.cdiunit.ContextController.listener(ContextController.java:0)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:368)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:289)
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:135)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:166)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:514)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

@BrynCooke
Copy link
Collaborator

Is this outside of a unit test?
Please put your CDI-Unit dependency in test scope:

            <groupId>org.jglue.cdi-unit</groupId>
            <artifactId>cdi-unit</artifactId>
            <version>3.0.1</version>
<scope>test</scope>
        </dependency> 

Also in HEAD the CDI-Unit dependency does not participate in bean discovery outside of a unit test.

@jack-jjy
Copy link
Author

I chanage like this

  <dependency>
        <groupId>org.jboss.weld.se</groupId>
        <artifactId>weld-se-core</artifactId>
        <version>2.1.2.Final</version>
    </dependency>
      <dependency>
        <groupId>org.jglue.cdi-unit</groupId>
        <artifactId>cdi-unit</artifactId>
        <version>3.0.1</version>
        <scope>test</scope>
    </dependency> 

when i do the test

        @RunWith(CdiRunner.class)
        public class CategoryManagerTest2 {

            @Inject
            Manager<Category> manager;

            @Test
            public void test(){
                Category data = new Category();
                data.name = "xx";
                manager.create(data);
            } 
        }

i will always get the failue Trace

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Manager<Category> with qualifiers @Default
at injection point [UnbackedAnnotatedField] @Inject cn.tt100.rms.impl.persistence.CategoryManagerTest2.manager
at cn.tt100.rms.impl.persistence.CategoryManagerTest2.manager(CategoryManagerTest2.java:0)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:368)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:289)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:135)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:166)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:514)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

I can not inject any Bean

@BrynCooke
Copy link
Collaborator

The strange thing is that your call stack doesn't have junit in it. Are you running this outside a test e.g. by starting weld manually?

@BrynCooke
Copy link
Collaborator

For that matter your call stack doesn't have CDI-Unit in it either....

@jack-jjy
Copy link
Author

No,I do not starting weld manually,I only running the @test,and if I do like this,it will be ok

        CategoryManager manager;

        @BeforeClass
        public static void setUpClass(){
            weld = new Weld();
            weldContainer = weld.initialize();
            System.out.println("weld init");
        }

        @AfterClass
        public static void teardownClass() {
            weld.shutdown();
            System.out.println("weld teardown");
        }

        @Override
        @Before
        public void init() {
            manager = weldContainer.instance().select(CategoryManager.class).get();
        }

        @Override
        @Test()
        public void test() {

            Category data1 = new Category();
            data1.name = "xx";
            manager.create(data1);

        }

@BrynCooke
Copy link
Collaborator

OK. Given your least stack trace I am guessing that Category is an interface or abstract class.
You will need to tell the container about the implementing class using one of the discovery annotations.

http://jglue.org/cdi-unit-user-guide/#controllingEnvironment

@jack-jjy
Copy link
Author

In addition to,when i do running @test,the weld not starting Seemingly!

    17:09:23.709 [main] DEBUG org.jboss.weld.Bootstrap - WELD-000100: Weld initialized. Validating beans
    17:09:23.716 [weld-worker-3] WARN  org.jboss.weld.Validator - WELD-001440: Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private org.jglue.cdiunit.ContextController.listener

yea,CategoryManager is a class implements interface Manager.I try like this

@RunWith(CdiRunner.class)
@AdditionalClasses(Manager.class) 
public class CategoryManagerTest2 {

    @Inject
    CategoryManager manager;

    @Test
    public void test(){
        Category data = new Category();
        data.name = "xx";
        manager.create(data);
    }
}

@BrynCooke
Copy link
Collaborator

17:09:23.716 [weld-worker-3] WARN org.jboss.weld.Validator - WELD-001440: Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private org.jglue.cdiunit.ContextController.listener

This is a warning, I've corrected the code but you can ignore it. Weld should still be starting fine.

@jack-jjy
Copy link
Author

Weld not starting after the warning,i did not kown why...

@BrynCooke
Copy link
Collaborator

Is there a stack trace?

@BrynCooke
Copy link
Collaborator

On 15/07/14 10:42, 蒋建洋 wrote:

no!when weld running to this warning,there will be nothing after.


Reply to this email directly or view it on GitHub
#58 (comment).

Is your test passing? CDI-Unit shuts down weld after each test.

Attached is what I can piece together from your test. It seems to work
for me

@jack-jjy
Copy link
Author

It really work!Ok!The cdi-unit work normally,there are some other problems about the EntityManager...so thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants