Search code examples
apache-camelapache-servicemix

Missing Camel-DNS


I am running on servicemix 4.4.1. I cannot locate the camel-dns module.

I have run features:list and osgi:list, and I do not see camel-dns. When I perform a

<to uri="dns:lookup"/>

I get a

org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint:
dns://lookup due to: No component found with scheme: dns

Any idea?


Solution

  • Okay it was a bit more tricky to get working out of the box with SMX, as the SMX does not expose a package from the JVM that the DNS bundle need. So you will get an error like this:

    ERROR: Error starting file:bundles/dnsjava_2.1.1.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle dnsjava [69]: Unable to resolve 69.0: missing requirement [69.0] package; (package=sun.net.spi.nameservice))
    org.osgi.framework.BundleException: Unresolved constraint in bundle dnsjava [69]: Unable to resolve 69.0: missing requirement [69.0] package; (package=sun.net.spi.nameservice)
        at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3404)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1714)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1143)
        at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
        at java.lang.Thread.run(Thread.java:680)
    

    So you need to adjust the configuration of the SMX, in the etc/jre.properties

    Add the following

    sun.net.spi.nameservice
    

    To the Java platform packages exported, for example my file now ends with

     org.xml.sax, \
     org.xml.sax.ext, \
     org.xml.sax.helpers, \
     sun.net.spi.nameservice
    

    You would need to restart the ESB to have this change take effect.

    To install the camel-dns, you need first to install its required dependencies which is junit also. Which is this bundle here: http://repo2.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.junit/4.10_1/

    On a basic Apache Karaf 2.2.5 I managed to get it installed

    karaf@root> osgi:list
    START LEVEL 100 , List Threshold: 50
       ID   State         Blueprint      Spring    Level  Name
    [  49] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: junit (4.10.0.1)
    [  50] [Active     ] [            ] [       ] [   60] dnsjava (2.1.1)
    [  65] [Active     ] [            ] [       ] [   50] camel-core (2.10.0.SNAPSHOT)
    [  66] [Active     ] [Created     ] [       ] [   50] camel-karaf-commands (2.10.0.SNAPSHOT)
    [  73] [Active     ] [            ] [       ] [   50] geronimo-jta_1.1_spec (1.1.1)
    [  74] [Active     ] [            ] [       ] [   50] camel-spring (2.10.0.SNAPSHOT)
    [  75] [Active     ] [            ] [       ] [   60] camel-dns (2.10.0.SNAPSHOT)
    [  76] [Active     ] [            ] [Started] [   60] IPCheck.xml (0.0.0)
    

    And I copied the IPCheck.xml Camel sample route, from here: https://svn.apache.org/repos/asf/camel/trunk/components/camel-dns/src/test/resources/ , to the deploy directory and have the Camel application startup:

    karaf@root> camel:context-list 
    Name                 Status               Uptime              
    [camel             ] [Started           ] [22.339 seconds    ]
    karaf@root> camel:context-info camel 
    Camel Context camel
        Name: camel
        Version: 2.10-SNAPSHOT
        Status: Started
        Uptime: 25.835 seconds
    
    Advanced
        Auto Startup: true
        Starting Routes: false
        Suspended: false
        Tracing: true
    
    Properties
    
    Components
        direct
        mock
        dns
        spring-event
    
    Endpoints
        direct://start
        dns://ip
        mock://result
        spring-event://default
    
    Routes
        IPCheck