2 Replies Latest reply on May 26, 2014 10:50 AM by inspector

    Weld ContextNotActiveException when accessing bean component

    inspector

      Hi everybody,

       

      I have a switchyard application that has a bean component which has one service which is promoted to a SOAP composite service. The (minimal example) project is attached to this post. When I access the service via soap-ui I get the following exception:

      Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped

        at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:590) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]

        at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:71) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]

        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]

        at de.akquinet.jbosscc.sy.order.management.OrderAcceptor$Proxy$_$$_WeldClientProxy.sendOrder(OrderAcceptor$Proxy$_$$_WeldClientProxy.java) [problem-minimal-0.0.1-SNAPSHOT.jar:]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_55]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_55]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_55]

        at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_55]

        at org.switchyard.component.bean.ServiceProxyHandler.handle(ServiceProxyHandler.java:163) [switchyard-component-bean-1.1.1-p5-redhat-1.jar:1.1.1-p5-redhat-1]

        ... 148 more

      I don't really get why. I compared my example application to another example application (that does work!) and still don't see the problem.

       

      Btw.: Just in case you try to open my project with eclipse: For some reason the switchyard editor shows some components which are not contained in the xml code. (That's another issue bugging me, because you basically have to use the eclipse SY-editor, as the schemas of switchyard.xml are somehow badly posed so that I somehow get validation errors for it in eclipse as well as in idea).

        • 1. Re: Weld ContextNotActiveException when accessing bean component
          kcbabo

          It's due to the fact that the service interface used in your CDI bean service has JAX-RS annotations.  I chased this down some time ago and Weld gets confused when this annotation is present for some reason - can't remember why.

           

          The duplicate component issue you mentioned is likely because you have a component definition for the bean service in src/main/resources/META-INF/switchyard.xml *and* you are using generated config.  This can be OK if the generated config and source config are identical, but in your case the generated component name is different from the source component name.  Easy enough to fix with an edit to switchyard.xml, but there's really no need to use generated config in this case - just drop the bean scanner from the list of scanners in switchyard-plugin definition in your pom.xml.


          The schema issue (at least in Eclipse), appears to have something to do with how Eclipse validates substitution groups across schema.  You can disable "Honour all schema locations" to remedy the situation as documented here:

          Installing Eclipse Tooling - SwitchYard - Project Documentation Editor

          • 2. Re: Weld ContextNotActiveException when accessing bean component
            inspector

            Hey thanks for your answer !

             

            It works! I would never have looked at that @Path annotation. I'm really happy 'cause that problem costed me more than a day.