Git Product home page Git Product logo

Comments (10)

BrynCooke avatar BrynCooke commented on July 20, 2024

Hi.
Can I ask what version of weld you are using?

from cdi-unit.

klindklind avatar klindklind commented on July 20, 2024

I'm using the one that comes with CDI-Unit (2.1.0.Beta2):

[INFO] +- org.jglue.cdi-unit:cdi-unit:jar:2.2.0:test
[INFO] |  +- org.jboss.weld.se:weld-se-core:jar:2.1.0.Beta2:test
[INFO] |  |  +- org.jboss.weld:weld-spi:jar:2.1.Beta2:test
[INFO] |  |  |  \- org.jboss.weld:weld-api:jar:2.1.Beta2:test
[INFO] |  |  +- org.jboss.weld:weld-core-impl:jar:2.1.0.Beta2:test
[INFO] |  |  |  +- org.jboss.classfilewriter:jboss-classfilewriter:jar:1.0.4.Final:test
[INFO] |  |  |  +- com.google.guava:guava:jar:13.0.1:test
[INFO] |  |  |  +- org.jboss.spec.javax.el:jboss-el-api_3.0_spec:jar:1.0.0.Alpha1:test
[INFO] |  |  |  \- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:jar:1.0.0.Alpha3:test
[INFO] |  |  +- javax.enterprise:cdi-api:jar:1.1:test
[INFO] |  |  |  \- javax.annotation:jsr250-api:jar:1.0:test
[INFO] |  |  \- org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:jar:1.0.0.Alpha1:test
[INFO] |  +- org.apache.deltaspike.core:deltaspike-core-impl:jar:0.5:test
[INFO] |  \- org.apache.deltaspike.core:deltaspike-core-api:jar:0.5:test

from cdi-unit.

BrynCooke avatar BrynCooke commented on July 20, 2024

Can I ask you to try HEAD and see if it is working for you. It could be a problem with the weld Beta.
If it is working I'll try and get a release out tonight,

from cdi-unit.

BrynCooke avatar BrynCooke commented on July 20, 2024

Your call stack seems to indicate that this issue is outside of CDI unit, so it the absence of more information I have released 2.2.1.
Please give it a go and reopen if you are still having problems.

from cdi-unit.

klindklind avatar klindklind commented on July 20, 2024

Thanks for really quick reply on my issue and sorry for not been able to respond since I've been on a vacation. I really appreciate that your being so active towards my problem.

I took your latest release into use

 org.jglue.cdi-unit:cdi-unit:jar:2.2.1:test
[INFO] |  +- org.jboss.weld.se:weld-se-core:jar:2.1.0.Final:test
[INFO] |  |  +- org.jboss.weld:weld-spi:jar:2.1.Final:test
[INFO] |  |  |  \- org.jboss.weld:weld-api:jar:2.1.Final:test
[INFO] |  |  +- org.jboss.weld:weld-core-impl:jar:2.1.0.Final:test
[INFO] |  |  |  +- org.jboss.classfilewriter:jboss-classfilewriter:jar:1.0.4.Final:test
[INFO] |  |  |  +- com.google.guava:guava:jar:13.0.1:test
[INFO] |  |  |  +- org.jboss.spec.javax.el:jboss-el-api_3.0_spec:jar:1.0.0.Alpha1:test
[INFO] |  |  |  \- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:jar:1.0.0.Alpha3:test
[INFO] |  |  +- javax.enterprise:cdi-api:jar:1.1:test
[INFO] |  |  \- org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:jar:1.0.0.Alpha1:test
[INFO] |  +- org.apache.deltaspike.core:deltaspike-core-impl:jar:0.5:test
[INFO] |  \- org.apache.deltaspike.core:deltaspike-core-api:jar:0.5:test

but the problem still remains:

Last logging:
10:03:06.675 [main] INFO  org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.

The stack:
org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
javax.enterprise.event.ObserverException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:374)
    at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:37)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:75)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:101)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:274)
    at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:121)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:261)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:240)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:170)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:129)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:103)
    at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:63)
    at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:35)
    at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:53)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:515)
    at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
    at org.jboss.weld.environment.se.Weld.initialize(Weld.java:143)
    at org.jglue.cdiunit.CdiRunner.createTest(CdiRunner.java:82)
    at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:227)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:224)
    at org.jglue.cdiunit.CdiRunner.methodBlock(CdiRunner.java:113)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NoSuchMethodError: org.jboss.weld.context.AbstractUnboundContext.<init>(Ljava/lang/String;Z)V
    at org.jboss.weld.environment.se.contexts.ThreadContext.<init>(ThreadContext.java:40)
    at org.jboss.weld.environment.se.WeldSEBeanRegistrant.registerWeldSEContexts(WeldSEBeanRegistrant.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
    ... 32 more

    at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:37)
    at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:53)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:515)
    at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)
    at org.jboss.weld.environment.se.Weld.initialize(Weld.java:143)
    at org.jglue.cdiunit.CdiRunner.createTest(CdiRunner.java:82)
    at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:227)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:224)
    at org.jglue.cdiunit.CdiRunner.methodBlock(CdiRunner.java:113)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

from cdi-unit.

BrynCooke avatar BrynCooke commented on July 20, 2024

Hmm. This really feels like a classpath issue, possibly multiple versions of Weld.
Can you try moving CDI unit to the top of your pom, and give it a go. Also grep for Weld in your effective pom.

If all else fails, can I ask you to produce a minimal test case.

from cdi-unit.

klindklind avatar klindklind commented on July 20, 2024

Ỳou were right, I had a glassfish-embedded-all artifact in my pom hierarchy which contained the incompatible weld-se version. Took me a while to figure that out. Now CDI-Unit 2.2.1 works with Eclipse again!

The problem which made me upgrade to CDI-Unit 2.2.0/.1 in the first place still remains. I cannot run the tests with Maven from command line. When I run the tests with Eclipse or deploy my application into GlassFish everything works.

There are two types of injection problems within the tests when executed with Maven.

MyClass is within the same project as MyTestClass:

public class MyClassProducer {
    @Produces
    public List<MyClass>produceMyClasses() {
        return Lists.asList(new MyClass());
    }
}

public class MyTestClass {

//This is needed in order to use produced beans
@Inject
MyClassProducer producer;

@Inject
List<MyClass> myClasses; //NOTE! Empty list is injected

...
}

ExternalClass comes from external jar and there isn't any classes extending it:

public class ExternalClass implements ExternalInterface { 
}

public class MyTestClass {

@Inject
ExternalClass externalClass; //NOTE! Fails: WELD-001408: Unsatisfied dependencies for type ExternalClass with qualifiers @Default

...
}

I'm not sure if I should create another issue for this since this is not the problem stated by the issue title?

from cdi-unit.

BrynCooke avatar BrynCooke commented on July 20, 2024

Just before you do does your external jar have a META-INF/beans.xml file?

from cdi-unit.

klindklind avatar klindklind commented on July 20, 2024

\o/ THAT WAS IT!

All my test pass now with Maven also when I added beans.xml into my external jar project. This is actually my first project with CDI and these are really amateur flaws :) I usually go with Spring so everything is new here.

There was a @singleton annotation in the ExternalClass and I'm not sure how Eclipse managed to inject this external bean without the beans.xml? Anyway thanks again for really great support and giving possibility to use something more light-weight than Arquillian. Keep up the good work!

from cdi-unit.

BrynCooke avatar BrynCooke commented on July 20, 2024

Eclipse classpath is only an approximation of Maven, so sometimes things don't work quite as expected.

from cdi-unit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.