Showing posts with label JBoss. Show all posts
Showing posts with label JBoss. Show all posts

Saturday, November 28, 2015

I Took the Red Pill; Setting Up Development Environment to Contribute Wildfly (1)

I have been working with JBoss EAP and Wildfly  for almost 2 years and the experiences is quite interesting. Inside JBoss EAP it uses Wildfly as its core JEE server. What I like most in Wildfly  are its easy configuration and management interface, modular design and indeed fast startup.


There were times I had to extensively investigate class loading mechanisms and dependency management with related to Wildfly, which gave me sort of a high confidence about its runtime environment. Its just crazy and made me to dig deep. Here I’m explaining steps required to setup your development environment to start Wildfly contribution.

Prerequisites,
  • Java 8
  • Mavan 3
  • GitHub account 

Setting up a personal repository to work,

1. Fork Wildfly repository into your personal account.
2. Clone your newly forked repository to local workspace.  

$ cd wildfly

3. Add a remote reference to upstream, for pulling future updates .

$ git remote add upstream git://github.com/wildfly/wildfly.git

4. Disable merge commits to your master.

$ git config branch.master.mergeoptions –ff-only

Build the Source Code,

Building WildFly 9 requires Java 8 or newer, make sure you have JAVA_HOME set to point to the JDK8 installation. Build uses Maven 3.

1. Run build.sh script.

$ ./build.sh

but,
Basically all you do is run

$ mvn clean install

or if your don’t want to wait for default testsuites you can do

$ mvn install -Dmaven.test.skip=true

Hakuna matata!


Launch Wildfly,

Built Wildfly zip file can be find in [repository_location]\build\target\

1. Navigate to above mentioned directory.

$ cd build\target\wildfly-10.0.0.CR5-SNAPSHOT\bin

Wildfly supports comes with two operation modes; standalone and domain.
To run Wildfly in standalone mode,

2. Execute standalone.sh script.

$ ./standalone.sh



From another post I’ll explain how to load Wildfly source to IntelliJ Idea and start debugging.



Saturday, October 24, 2015

Solving "org.jboss.as.cli.CliInitializationException: Failed to connect to the controller" Exception

I had a requirement of deploying an application to a JBoss Wildfly server via its command line tool, which is known as "jboss-cli". I executed below command to deploy the war file, which gave me a "CliInitializationException".
jboss-cli.bat --connect --command="deploy --force E:\Projects\CD&CI\portal.war"

The exception thrown from the jboss-cli tool:

org.jboss.as.cli.CliInitializationException: Failed to connect to the controller
        at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:278)
        at org.jboss.as.cli.impl.CliLauncher.main(CliLauncher.java:253)
        at org.jboss.as.cli.CommandLineMain.main(CommandLineMain.java:34)
        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.modules.Module.run(Module.java:292)
        at org.jboss.modules.Main.main(Main.java:455)
Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at localhost:9990
        at org.jboss.as.cli.impl.CommandContextImpl.tryConnection(CommandContextImpl.java:1020)
        at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:832)
        at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:811)
        at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:276)
        ... 8 more
Caused by: java.io.IOException: java.net.ConnectException: JBAS012144: Could not connect to http-remoting://localhost:9990. The connection timed out
        at org.jboss.as.controller.client.impl.AbstractModelControllerClient.executeForResult(AbstractModelControllerClient.java:129)
        at org.jboss.as.controller.client.impl.AbstractModelControllerClient.execute(AbstractModelControllerClient.java:71)
        at org.jboss.as.cli.impl.CommandContextImpl.tryConnection(CommandContextImpl.java:997)
        ... 11 more
Caused by: java.net.ConnectException: JBAS012144: Could not connect to http-remoting://localhost:9990. The connection timed out
        at org.jboss.as.protocol.ProtocolConnectionUtils.connectSync(ProtocolConnectionUtils.java:120)
        at org.jboss.as.protocol.ProtocolConnectionManager$EstablishingConnection.connect(ProtocolConnectionManager.java:256)
        at org.jboss.as.protocol.ProtocolConnectionManager.connect(ProtocolConnectionManager.java:70)
        at org.jboss.as.protocol.mgmt.FutureManagementChannel$Establishing.getChannel(FutureManagementChannel.java:204)
        at org.jboss.as.cli.impl.CLIModelControllerClient.getOrCreateChannel(CLIModelControllerClient.java:169)
        at org.jboss.as.cli.impl.CLIModelControllerClient$2.getChannel(CLIModelControllerClient.java:129)
        at org.jboss.as.protocol.mgmt.ManagementChannelHandler.executeRequest(ManagementChannelHandler.java:117)
        at org.jboss.as.protocol.mgmt.ManagementChannelHandler.executeRequest(ManagementChannelHandler.java:92)
        at org.jboss.as.controller.client.impl.AbstractModelControllerClient.executeRequest(AbstractModelControllerClient.java:236)
        at org.jboss.as.controller.client.impl.AbstractModelControllerClient.execute(AbstractModelControllerClient.java:141)
        at org.jboss.as.controller.client.impl.AbstractModelControllerClient.executeForResult(AbstractModelControllerClient.java:127)
        ... 13 more

Problem is, I was using a native-interface instead of a http-interface so it won't use the correct protocol.

Solution is simple, I had to change the standalone-full.xml file as below to specify the correct interface.

<management-interfaces>
    <!--<http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
        <socket-binding http="management-http" />
    </http-interface>-->
    <http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
        <socket interface="management" port="${jboss.management.http.port:9990}" secure-port="${jboss.management.http.port:9993}"/>
    </http-interface>
</management-interfaces>

So that, jboss-cli tool will select the correct protocol in order to initialize it's execution.

Wednesday, May 6, 2015

JBoss EPA 6.1 : javax.persistence.PersistenceException PersistenceProvider in org.apache.openjpa.persistence.PersistenceProviderImpl not found

This is an issue I was having few weeks back and solved by creating a module inside the JBoss EPA. The issue came because of missing a class which should be available inside the EPA, and raised the above exception during the deployment. I’m still hesitating about the root cause, whether this requirement came with a Spring dependency I had or due to MS SQL Server driver I used. Somehow I managed to solve this issue by creating an OpenJPA module inside the JBOSS_HOME>\modules\org\apache\openjpa directory.
First of all we need to download the OpenJPA from this link. Then extract the content to above mentioned directory and the create the module.xml file as follows.

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.jboss.as.jpa.openjpa">
    <properties>
        <property name="jboss.api" value="private"/>
    </properties>
    <resources>
        <resource-root path="jboss-as-jpa-openjpa-7.1.1.Final.jar"/>
    </resources>
    <dependencies>
        <module name="javax.annotation.api"/>
        <module name="javax.persistence.api"/>
        <module name="javax.transaction.api"/>
        <module name="org.jboss.as.jpa.spi"/>
        <module name="org.jboss.logging"/>
        <module name="org.jboss.jandex"/>
        <module name="org.apache.openjpa" optional="true"/>
    </dependencies>

</module>