Pages

Friday, May 9, 2014

JBoss Wildfly with Apache Camel: first unsuccessful test

Today, I tried to setup the Wildfly Camel integration. Unfortunately, I was not successful. Please see what I have tried.

For my tests I used Wildfly 8.0.0.Final and the Wildfly Camel integration installer 1.0.0.Alpha1.

Step 1: Download

Download the Wildfly Camel installer from http://sourceforge.net/projects/jboss/files/WildFly-Camel/1.0.0.Alpha1/

This will download the installer file wildfly-camel-installer-1.0.0.Alpha1.jar

Step 2: Install

> cd wildfly-8.0.0.Final/
> java -jar wildfly-camel-install-1.0.0.Alpha1.jar

This will install among others all necessary jars in the modules directory and the standalone camel configuration file standalone/configuration/standalone-camel.xml.

Step 3: Running

>  cd bin
> ./standalone.sh -c standalone-camel.xml

 This will produce following error:

[521]% ./standalone.sh -c standalone-camel.xml
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /Developer/Workspace/Java/containers/wildfly-8.0.0.Final

  JAVA: /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java

  JAVA_OPTS:  -server -XX:+UseCompressedOops -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

18:24:00,635 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.0.Final
18:24:02,615 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.0.Final
18:24:02,950 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.0.0.Final "WildFly" starting
18:24:05,915 ERROR [org.jboss.as.server] (Controller Boot Thread) JBAS015956: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration
    at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:112) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.server.ServerService.boot(ServerService.java:331) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:256) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[107,21]
Message: JBAS014788: Unexpected attribute 'host' encountered
    at org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute(ParseUtils.java:104) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.messaging.MessagingSubsystemParser.processConnectors(MessagingSubsystemParser.java:1102)
    at org.jboss.as.messaging.MessagingSubsystemParser.processHornetQServer(MessagingSubsystemParser.java:227)
    at org.jboss.as.messaging.Messaging13SubsystemParser.processHornetQServers(Messaging13SubsystemParser.java:212)
    at org.jboss.as.messaging.MessagingSubsystemParser.readElement(MessagingSubsystemParser.java:134)
    at org.jboss.as.messaging.MessagingSubsystemParser.readElement(MessagingSubsystemParser.java:93)
    at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
    at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
    at org.jboss.as.server.parsing.StandaloneXml.parseServerProfile(StandaloneXml.java:1131) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.server.parsing.StandaloneXml.readServerElement_1_4(StandaloneXml.java:458) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:145) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:107) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
    at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
    at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:104) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    ... 3 more

18:24:05,920 FATAL [org.jboss.as.server] (Controller Boot Thread) JBAS015957: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.
18:24:05,969 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015950: WildFly 8.0.0.Final "WildFly" stopped in 4ms


That's too bad.  Obviously, the XML configuration file standalone-camel.xml created by the installer meets not the schema expected by the final Wildfly 8.0.0 version. It turns out that the Netty connector definition is mal-configured.

Step 4: Extending standalone.xml

Try to fix the configuration starting with the default standalone.xml file.

Adding Camel extension:

<extension module="org.wildfly.camel" />

Adding subsystem with simple Camel context:

<subsystem xmlns="urn:jboss:domain:camel:1.0">
    <camelContext id="system-context-1">
         &lt;route&gt;
             &lt;from uri="direct:start"/&gt;
             &lt;transform&gt;
                 &lt;simple&gt;Hello #{body}&lt;/simple&gt;
             &lt;/transform&gt;
         &lt;/route&gt;      
    </camelContext>
 </subsystem>


Starting Wildfly as described in Step 3 leads to following error message in the console:

19:27:30,306 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 28) JBAS014612: Operation ("add") failed - address: ([("subsystem" => "camel")]): java.lang.NoSuchMethodError: org.jboss.as.naming.service.BinderService.getManagedObjectInjector()Lorg/jboss/msc/inject/Injector;
    at org.wildfly.camel.service.CamelContextFactoryBindingService.addService(CamelContextFactoryBindingService.java:66)
    at org.wildfly.camel.parser.CamelSubsystemAdd$1.execute(CamelSubsystemAdd.java:91)
    at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:591) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:469) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.controller.AbstractOperationContext.completeStepInternal(AbstractOperationContext.java:273) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:268) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:343) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_40]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_40]
    at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]


Step 5: Giving up...

The Wildfly Camel integration sounds interesting. However, it seems not really ready for use. To be continued...


Sunday, May 4, 2014

Using Hawtio to monitor Apache Camel route started as Java standalone process

Step 1: Gathering info

http://hawt.io/getstarted/index.html

Step 2: Download Jolokia Java Agent

Download Jolokia JARs from:

http://jolokia.org/dist/1.2.1/jolokia-1.2.1-bin.zip

Unzip the file.

Step 3: Add VM arguments to for enabling Jolokia Java Agent

Add following VM arguments when starting your Java standalone client:

-javaagent:/path/to/-javaagent:/Developer/Workspace/Java/libs/jolokia-1.2.1/agents/jolokia-jvm.jar


Step 4: Start the Camel route

You should see something similar in your console

I> No access restrictor found, access to all MBean is allowed
Jolokia: Agent started with URL http://127.0.0.1:8778/jolokia/


Step 5: Download and install Chrom Client

Download extension:

http://central.maven.org/maven2/io/hawt/hawtio-crx/1.3.1/hawtio-crx-1.3.1.crx

Start Chrom and open extension path at chrome://extensions/

Drop the downloaded CRX file onto the page

Open the app page, select Hawtio app and enter the URL that was shown on Step 4. In my case this was port 8778 and path jolokia.

You should see the Hawtio page with your Camel route:



I especially like the Diagram tab showing the route layout:


Friday, May 2, 2014

JBoss Wildfly with Apache Camel

Wildfly Camel Integration

This sounds interesting: Apache Camel integration with the WildFly Application Server:
There are two ways to deploy a Camel Context to WildFly
  1. As a single XMl file with a predefined -camel-context.xml file suffix
  2. As part of another WildFly supported deployment as META-INF/jboss-camel-context.xml file 

JBoss Modules

Alternatively, see http://sourcevirtues.wordpress.com/2013/11/25/add-apache-camel-and-spring-as-jboss-module-in-wildfly/ how Camel dependencies can be added to JBoss Wildfly using JBoss modules.

JBoss Wildfly in 5 minutes (or a little bit more, but not much)

Step 1: Gathering information

Access:

http://www.wildfly.org/

Step 2: Download the server

Download Wildfly v8.0.0:

http://download.jboss.org/wildfly/8.0.0.Final/wildfly-8.0.0.Final.zip

Step 3: Install the server

> unzip wildfly-8.0.0.Final.zip

Step 4: Start the server

> cd wildfly-8.0.0.Final
> cd bin
> ./standalone.sh

On my not so fast iMac, the first time the server was started it took about 20 seconds, the second time only about 4 seconds:

11:36:10,083 INFO  [org.jboss.ws.common.management] (MSC service thread 1-4) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.3.Final
11:36:10,153 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
11:36:10,154 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
11:36:10,154 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Final "WildFly" started in 4221ms - Started 183 of 232 services (80 services are lazy, passive or on-demand)


Check if the server is started on http://localhost:8080. You should see the Wildfly welcome page.

Step 5: Access Administration console

http://localhost:9990

This will not work... It states:
To add a new user execute the add-user.sh script within the bin folder of your WildFly installation and enter the requested information.
 Try that and answer the questions:

> ./add-user.sh

I added an admin user. Access http://localhost:9990 again, and voilĂ , the admin cosole is shown.

Step 6: Deploy the first application

Clone from GitHub

> git clone https://github.com/wildfly/quickstart.git

Build and deploy the project:

> cd quickstart/
> mvn wildfly:deploy

You should see the following log messages:

11:46:40,620 INFO  [org.jboss.as.repository] (management-handler-thread - 1) JBAS014900: Content added at location /Developer/Workspace/Java/containers/wildfly-8.0.0.Final/standalone/data/content/0b/37af36408419a89a9c1f015ea3570c87ced389/content
11:46:40,707 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "wildfly-helloworld.war" (runtime-name: "wildfly-helloworld.war")
11:46:42,141 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016002: Processing weld deployment wildfly-helloworld.war
11:46:42,468 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-7) HV000001: Hibernate Validator 5.0.3.Final
11:46:42,915 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016005: Starting Services for CDI deployment: wildfly-helloworld.war
11:46:43,031 INFO  [org.jboss.weld.Version] (MSC service thread 1-4) WELD-000900: 2.1.2 (Final)
11:46:43,207 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016008: Starting weld service for deployment wildfly-helloworld.war
11:46:45,711 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017534: Registered web context: /wildfly-helloworld
11:46:45,860 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "wildfly-helloworld.war" (runtime-name : "wildfly-helloworld.war")


Access the application:

http://localhost:8080/wildfly-helloworld/HelloWorld

You should see the "Hello World!" message.