2 Replies Latest reply: May 29, 2012 8:52 AM by Łukasz Dywicki RSS

Weld and netty dependency

Łukasz Dywicki Novice

Hey,

During my work on camel-netty quickstart I decided to change quickstart to receive frames (ChannelBuffer instances) instead of String payload. I've changed interface of service to:

 

 

public interface GreetingService {
    void greet(ChannelBuffer name);
}

 

Tests works fine, but at the runtime I have few exceptions. First is thrown by Weld

 

07:22:10,751 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 1303ms - Started 141 of 218 services (74 services are passive or on-demand)
07:22:10,756 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-10) JBAS015876: Starting deployment of "switchyard-quickstart-camel-netty-binding.jar"
07:22:10,818 INFO  [org.jboss.weld.deployer] (MSC service thread 1-13) JBAS016002: Processing weld deployment switchyard-quickstart-camel-netty-binding.jar
07:22:10,842 INFO  [org.jboss.weld.deployer] (MSC service thread 1-9) JBAS016005: Starting Services for CDI deployment: switchyard-quickstart-camel-netty-binding.jar
07:22:10,888 INFO  [org.jboss.weld.Version] (MSC service thread 1-9) WELD-000900 1.1.6 (Final)
07:22:10,899 INFO  [org.switchyard] (MSC service thread 1-9) Deploying SwitchYard application 'switchyard-quickstart-camel-netty-binding.jar'
07:22:10,903 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016008: Starting weld service for deployment switchyard-quickstart-camel-netty-binding.jar
07:22:11,078 INFO  [org.jboss.weld.ClassLoading] (MSC service thread 1-7) WELD-000119 Not generating any bean definitions from org.switchyard.quickstarts.camel.netty.binding.GreetingServiceBean because of underlying class loading error
07:22:11,079 INFO  [org.jboss.weld.ClassLoading] (MSC service thread 1-7) catching: org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class org.switchyard.quickstarts.camel.netty.binding.GreetingServiceBean
          at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:167) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.BeanDeployer.loadWeldClass(BeanDeployer.java:108) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:79) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:123) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:349) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
          at org.jboss.as.weld.services.WeldService.start(WeldService.java:76) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_31]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_31]
          at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_31]
Caused by: java.lang.NoClassDefFoundError: org/jboss/netty/buffer/ChannelBuffer
          at java.lang.Class.getDeclaredMethods0(Native Method) [classes.jar:1.6.0_31]
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) [classes.jar:1.6.0_31]
          at java.lang.Class.getDeclaredMethods(Class.java:1791) [classes.jar:1.6.0_31]
          at org.jboss.weld.util.reflection.SecureReflections$8.work(SecureReflections.java:175) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.util.reflection.SecureReflections$8.work(SecureReflections.java:172) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:63) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.util.reflection.SecureReflections.getDeclaredMethods(SecureReflections.java:172) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:234) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:119) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:59) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:50) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:355)
          at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
          at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
          at com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
          at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:393)
          at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:163) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          ... 12 more
Caused by: java.lang.ClassNotFoundException: org.jboss.netty.buffer.ChannelBuffer from [Module "deployment.switchyard-quickstart-camel-netty-binding.jar:main" from Service Module Loader]
          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
          ... 30 more


07:22:11,091 INFO  [org.jboss.weld.ClassLoading] (MSC service thread 1-7) WELD-000119 Not generating any bean definitions from org.switchyard.quickstarts.camel.netty.binding.GreetingService because of underlying class loading error
07:22:11,091 INFO  [org.jboss.weld.ClassLoading] (MSC service thread 1-7) catching: org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class org.switchyard.quickstarts.camel.netty.binding.GreetingService
          at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:167) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.BeanDeployer.loadWeldClass(BeanDeployer.java:108) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:79) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:123) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:349) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
          at org.jboss.as.weld.services.WeldService.start(WeldService.java:76) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_31]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_31]
          at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_31]
Caused by: java.lang.NoClassDefFoundError: org/jboss/netty/buffer/ChannelBuffer
          at java.lang.Class.getDeclaredMethods0(Native Method) [classes.jar:1.6.0_31]
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) [classes.jar:1.6.0_31]
          at java.lang.Class.getDeclaredMethods(Class.java:1791) [classes.jar:1.6.0_31]
          at org.jboss.weld.util.reflection.SecureReflections$8.work(SecureReflections.java:175) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.util.reflection.SecureReflections$8.work(SecureReflections.java:172) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:63) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.util.reflection.SecureReflections.getDeclaredMethods(SecureReflections.java:172) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:234) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:119) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:59) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:50) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          at com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:355)
          at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
          at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
          at com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
          at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:393)
          at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:163) [weld-core-1.1.6.Final.jar:2012-03-21 18:52]
          ... 12 more
Caused by: java.lang.ClassNotFoundException: org.jboss.netty.buffer.ChannelBuffer from [Module "deployment.switchyard-quickstart-camel-netty-binding.jar:main" from Service Module Loader]
          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
          ... 30 more

 

Second exception is thrown because bean service is not bound:

 

07:22:11,182 INFO  [org.switchyard] (MSC service thread 1-13) Starting SwitchYard service
07:22:11,417 INFO  [org.apache.camel.impl.converter.AnnotationTypeConverterLoader] (MSC service thread 1-13) Found 3 packages with 15 @Converter classes to load
07:22:11,433 INFO  [org.apache.camel.impl.converter.DefaultTypeConverter] (MSC service thread 1-13) Loaded 170 core type converters (total 170 type converters)
07:22:11,436 INFO  [org.apache.camel.impl.converter.AnnotationTypeConverterLoader] (MSC service thread 1-13) Loaded 2 @Converter classes
07:22:11,440 INFO  [org.apache.camel.impl.converter.DefaultTypeConverter] (MSC service thread 1-13) Loaded additional 13 type converters (total 183 type converters) in 0.005 seconds
07:22:11,626 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-13) MSC00001: Failed to start service jboss.deployment.unit."switchyard-quickstart-camel-netty-binding.jar".SwitchYardService: org.jboss.msc.service.StartException in service jboss.deployment.unit."switchyard-quickstart-camel-netty-binding.jar".SwitchYardService: org.switchyard.exception.SwitchYardException: Unknown Service name '{urn:switchyard-quickstart:camel-netty-binding:0.1.0}GreetingService'.
          at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:79)
          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$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_31]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_31]
          at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_31]
Caused by: org.switchyard.exception.SwitchYardException: Unknown Service name '{urn:switchyard-quickstart:camel-netty-binding:0.1.0}GreetingService'.
          at org.switchyard.component.bean.deploy.BeanComponentActivator.activateService(BeanComponentActivator.java:82)
          at org.switchyard.deploy.internal.Deployment.deployImplementations(Deployment.java:392)
          at org.switchyard.deploy.internal.Deployment.start(Deployment.java:140)
          at org.switchyard.as7.extension.deployment.SwitchYardDeployment.start(SwitchYardDeployment.java:103)
          at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:72)
          ... 5 more


07:22:11,645 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "switchyard-quickstart-camel-netty-binding.jar" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"switchyard-quickstart-camel-netty-binding.jar\".SwitchYardService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"switchyard-quickstart-camel-netty-binding.jar\".SwitchYardService: org.switchyard.exception.SwitchYardException: Unknown Service name '{urn:switchyard-quickstart:camel-netty-binding:0.1.0}GreetingService'."}}
07:22:11,648 INFO  [org.jboss.weld.deployer] (MSC service thread 1-9) JBAS016009: Stopping weld service for deployment switchyard-quickstart-camel-netty-binding.jar
07:22:11,653 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Stopped deployment switchyard-quickstart-camel-netty-binding.jar in 7ms
07:22:11,654 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."switchyard-quickstart-camel-netty-binding.jar".SwitchYardService: org.jboss.msc.service.StartException in service jboss.deployment.unit."switchyard-quickstart-camel-netty-binding.jar".SwitchYardService: org.switchyard.exception.SwitchYardException: Unknown Service name '{urn:switchyard-quickstart:camel-netty-binding:0.1.0}GreetingService'.


07:22:11,656 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"switchyard-quickstart-camel-netty-binding.jar\".SwitchYardService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"switchyard-quickstart-camel-netty-binding.jar\".SwitchYardService: org.switchyard.exception.SwitchYardException: Unknown Service name '{urn:switchyard-quickstart:camel-netty-binding:0.1.0}GreetingService'."}}}}


 

What is strange for me - if I don't use netty in my jar directly - it works fine. Do you have any ideas how to make quickstart running with ChannelBuffer from netty? Otherwise it will show nasty result of ChannelBuffer.toString (eg. "BigEndianHeapChannelBuffer(ridx=0, widx=4, cap=4)" instead of payload sent to service.

  • 1. Re: Weld and netty dependency
    Keith Babo Master

    Instead of bundling Netty inside the application, you could declare a dependency in the app's manifest on the existing Netty module in AS7.  Info on how to do that can be found here:

     

    https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7

     

    The JAR manifest route is easy and works well.

     

    Another thing to consider in this case is whether you want to use a Netty-specific interface in your service contract.  There could always be situations where this is required/appropriate (e.g. low-level routing service), but in general I would stay away from transport-specific classes in service interfaces.  Netty is a somewhat exceptional case in that a ChannelBuffer can be mapped into any lower-level transport binding.

     

    hth,

    keith

     

    Łukasz Dywicki wrote:

     

    Hey,

    During my work on camel-netty quickstart I decided to change quickstart to receive frames (ChannelBuffer instances) instead of String payload. I've changed interface of service to:

     

     

    public interface GreetingService {
        void greet(ChannelBuffer name);
    }
     
    

     

    Tests works fine, but at the runtime I have few exceptions. First is thrown by Weld

     

     

    What is strange for me - if I don't use netty in my jar directly - it works fine. Do you have any ideas how to make quickstart running with ChannelBuffer from netty? Otherwise it will show nasty result of ChannelBuffer.toString (eg. "BigEndianHeapChannelBuffer(ridx=0, widx=4, cap=4)" instead of payload sent to service.

  • 2. Re: Weld and netty dependency
    Łukasz Dywicki Novice

    Hey Keith,

    Issue is fixed by small descriptor:

    <jboss-deployment-structure>
        <deployment>
            <dependencies>
                <module name="org.jboss.netty" />
            </dependencies>
        </deployment>
    </jboss-deployment-structure>
    

    This change is not commited to git yet. Anyway - we can provide both examples with low level api at the entry point and with implicit conversion to show how to match service contract with different kinds of gateways. Btw I need to debug CamelConverter because it doesn't catch ByteBuffer -> String conversion correctly.