Over a million developers have joined DZone.

EJB Backend with NetBeans RCP Frontend on Maven

· Java Zone

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

"EJB Backend with NetBeans RCP Frontend" sounds fairly straightforward right? I also thought so initially. Unfortunately, there are a couple of nasty and not so little bumps that turn this from a trip to the shops to somewhere on the Roof of Africa Rally!

First step is easy, let’s use the bundled GlassFish App Server...

And there goes a frustrating couple of hours/days/weeks of your life. Let me explain.
 
GlassFish has a client JAR ($GLASSFISH_HOME/modules/gf-client.jar) that you are supposed to include with your application to connect to the EJB backend. This all works fine when you are testing with your public static void main tests, however there are a couple of things to note that will not be immediately apparent on your development machine:
 
  • gf-client.jar is just a meta-jar, all that it does is reference other JARs, which in turn can reference other JARs ad infinitum.
  • The moment you take your test application off your computer, it will fail. In all likelihood you have included gf-client.jar, but you haven’t included all of its references. What this means is that you have got to install GlassFish App Server on all of the computers that you want to install your software on, or figure out what the dependency tree is. (I’ll save you some time, it’s pretty much the same as installing. You get about every single jar that is included in the full install.)
  • After you’ve figured all of this out, your NetBeans application still will not run. Why? Read here and here to understand the problem.

Right, let’s get this show back on the road. What are we going to need in order to get this to work?

  1. NetBeans
  2. Maven
  3. JBoss
  4. Patience

Setting up the JBoss Client Libraries

First off, what you need to do is find all of the JBoss Client Dependencies and create a Maven artifact from them. Thankfully I didn’t need to do that, somebody had already figured it out for me.
 
Here’s the pom file:
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelversion>4.0.0</modelversion>
        <groupid>sparg.tim</groupid>
        <artifactid>JBossClientLibraries</artifactid>
        <packaging>jar</packaging>
        <version>5.10</version>
        <name>JBossClientLibraries</name>
        <url>http://maven.apache.org</url>
        <dependencies>
            <dependency>
                <groupid>org.jboss.javaee</groupid>
                <artifactid>jboss-javaee</artifactid>
                <version>5.0.1.GA</version>
            </dependency>
            <dependency>
                <groupid>org.hibernate</groupid>
                <artifactid>hibernate-annotations</artifactid>
                <version>3.4.0.GA</version>
                <exclusions>
                    <exclusion>
                        <groupid>org.hibernate</groupid>
                        <artifactid>hibernate-commons-annotations</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.hibernate</groupid>
                        <artifactid>hibernate-core</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>dom4j</groupid>
                        <artifactid>dom4j</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.naming</groupid>
                <artifactid>jnp-client</artifactid>
                <version>5.0.3.GA</version>
            </dependency>
            <dependency>
                <groupid>oswego-concurrent</groupid>
                <artifactid>concurrent</artifactid>
                <version>1.3.4-jboss-update1</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.ejb3</groupid>
                <artifactid>jboss-ejb3-proxy-clustered</artifactid>
                <version>1.0.1</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-proxy-impl</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-proxy-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cluster</groupid>
                        <artifactid>jboss-ha-server-api</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.ejb3</groupid>
                <artifactid>jboss-ejb3-proxy-spi</artifactid>
                <version>1.0.0</version>
                <classifier>client</classifier>
            </dependency>
            <dependency>
                <groupid>org.jboss.ejb3</groupid>
                <artifactid>jboss-ejb3-proxy-impl</artifactid>
                <version>1.0.2</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.aspects</groupid>
                        <artifactid>jboss-remoting-aspects</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-common</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-proxy-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-interceptors</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.metadata</groupid>
                        <artifactid>jboss-metadata</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.naming</groupid>
                        <artifactid>jnpserver</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.ejb3</groupid>
                <artifactid>jboss-ejb3-core</artifactid>
                <version>1.1.5</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>javassist</groupid>
                        <artifactid>javassist</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.hibernate</groupid>
                        <artifactid>hibernate</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.hibernate</groupid>
                        <artifactid>hibernate-entitymanager</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-jca-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss</groupid>
                        <artifactid>jboss-vfs</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.aop</groupid>
                        <artifactid>jboss-aop</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.aop</groupid>
                        <artifactid>jboss-aop-aspects</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cache</groupid>
                        <artifactid>jbosscache-core</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-cache</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-endpoint</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-security</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-timerservice-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-ext-api-impl</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-metadata</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-proxy-clustered</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-transactions</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-ejb-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jacc-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jca-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jms-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jpa</groupid>
                        <artifactid>jboss-jpa-deployers</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.metadata</groupid>
                        <artifactid>jboss-metadata</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.microcontainer</groupid>
                        <artifactid>jboss-kernel</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.security</groupid>
                        <artifactid>jbosssx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ws</groupid>
                        <artifactid>jbossws-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>quartz</groupid>
                        <artifactid>quartz</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>sun-jaxws</groupid>
                        <artifactid>jaxws-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>sun-jaxws</groupid>
                        <artifactid>jsr181-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.aspects</groupid>
                        <artifactid>jboss-remoting-aspects</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cluster</groupid>
                        <artifactid>jboss-ha-server-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-common</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-interceptors</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-proxy-impl</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-proxy-spi</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.remoting</groupid>
                <artifactid>jboss-remoting</artifactid>
                <version>2.5.1</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.deployers</groupid>
                <artifactid>jboss-deployers-core-spi</artifactid>
                <version>2.0.7.GA</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.deployers</groupid>
                <artifactid>jboss-deployers-core</artifactid>
                <version>2.0.7.GA</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.jbossas</groupid>
                <artifactid>jboss-as-main</artifactid>
                <version>5.1.0.GA</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.bootstrap</groupid>
                        <artifactid>jboss-bootstrap</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>gnu-getopt</groupid>
                        <artifactid>getopt</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>log4j</groupid>
                        <artifactid>log4j</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.logbridge</groupid>
                        <artifactid>jboss-logbridge</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.jbossas</groupid>
                <artifactid>jboss-as-j2se</artifactid>
                <version>5.1.0.GA</version>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-classloading-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>apache-xerces</groupid>
                        <artifactid>xml-apis</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.ejb3</groupid>
                <artifactid>jboss-ejb3-ext-api</artifactid>
                <version>1.0.0</version>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-ejb-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.metadata</groupid>
                        <artifactid>jboss-metadata</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.jbossas</groupid>
                <artifactid>jboss-as-server</artifactid>
                <version>5.1.0.GA</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>sun-jaxb</groupid>
                        <artifactid>jaxb-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-deployment</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.bootstrap</groupid>
                        <artifactid>jboss-bootstrap</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-deployment-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jpa</groupid>
                        <artifactid>jboss-jpa-deployers</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.security</groupid>
                        <artifactid>jbosssx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>log4j</groupid>
                        <artifactid>log4j</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system-jmx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-jmx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-transaction-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jacc-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jms-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ws.native</groupid>
                        <artifactid>jbossws-native-saaj</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ws.native</groupid>
                        <artifactid>jbossws-native-jaxws</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>javax.security</groupid>
                        <artifactid>jaas</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jca-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>bcel</groupid>
                        <artifactid>bcel</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>jpl-util</groupid>
                        <artifactid>jpl-util</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>jpl-pattern</groupid>
                        <artifactid>jpl-pattern</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss</groupid>
                        <artifactid>jbossxb</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.naming</groupid>
                        <artifactid>jnp-server</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>gnu-getopt</groupid>
                        <artifactid>getopt</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.metadata</groupid>
                        <artifactid>jboss-metadata</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-ejb-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.naming</groupid>
                        <artifactid>jnpserver</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.ejb3</groupid>
                <artifactid>jboss-ejb3-security</artifactid>
                <version>1.0.0</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.aspects</groupid>
                        <artifactid>jboss-current-invocation-aspects</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-interceptors</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.security</groupid>
                        <artifactid>jbosssx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jacc-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-ext-api-impl</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.aop</groupid>
                        <artifactid>jboss-aop</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ejb3</groupid>
                        <artifactid>jboss-ejb3-metadata</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.metadata</groupid>
                        <artifactid>jboss-metadata</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.security</groupid>
                <artifactid>jbosssx-client</artifactid>
                <version>2.0.3.SP1</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.deployers</groupid>
                <artifactid>jboss-deployers-client</artifactid>
                <version>2.0.7.GA</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.deployers</groupid>
                <artifactid>jboss-deployers-client-spi</artifactid>
                <version>2.0.7.GA</version>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.man</groupid>
                        <artifactid>jboss-managed</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.jbossas</groupid>
                <artifactid>jboss-as-system-jmx</artifactid>
                <version>5.1.0.GA</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>apache-xerces</groupid>
                        <artifactid>xml-apis</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss</groupid>
                        <artifactid>jboss-vfs</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss</groupid>
                        <artifactid>jbossxb</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.deployers</groupid>
                        <artifactid>jboss-deployers-impl</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.deployers</groupid>
                        <artifactid>jboss-deployers-structure-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.deployers</groupid>
                        <artifactid>jboss-deployers-vfs</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.deployers</groupid>
                        <artifactid>jboss-deployers-vfs-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.bootstrap</groupid>
                        <artifactid>jboss-bootstrap</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-jmx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.microcontainer</groupid>
                        <artifactid>jboss-dependency</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.microcontainer</groupid>
                        <artifactid>jboss-kernel</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.slf4j</groupid>
                <artifactid>slf4j-jboss-logging</artifactid>
                <version>1.0.2.GA</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.logging</groupid>
                <artifactid>jboss-logging-jdk</artifactid>
                <version>2.1.0.GA</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.logging</groupid>
                <artifactid>jboss-logging-log4j</artifactid>
                <version>2.1.0.GA</version>
                <exclusions>
                    <exclusion>
                        <groupid>log4j</groupid>
                        <artifactid>log4j</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.logging</groupid>
                <artifactid>jboss-logging-spi</artifactid>
                <version>2.1.0.GA</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.ejb3</groupid>
                <artifactid>jboss-ejb3-common</artifactid>
                <version>1.0.0</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.microcontainer</groupid>
                        <artifactid>jboss-kernel</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.metadata</groupid>
                        <artifactid>jboss-metadata</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.deployers</groupid>
                        <artifactid>jboss-deployers-spi</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.jbossas</groupid>
                <artifactid>jboss-as-server</artifactid>
                <version>5.1.0.GA</version>
                <classifier>jmx-invoker-adaptor-client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>sun-jaxb</groupid>
                        <artifactid>jabx-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-deployment</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.bootstrap</groupid>
                        <artifactid>jboss-bootstrap</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-deployment-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jpa</groupid>
                        <artifactid>jbopss-jpa-deployers</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.security</groupid>
                        <artifactid>jbosssx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.metadata</groupid>
                        <artifactid>jboss-metadata</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>log4j</groupid>
                        <artifactid>log4j</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system-jmx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-jmx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-ejb-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-security</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-transaction-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jacc-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-jms-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ws.native</groupid>
                        <artifactid>jbossws-native-saaj</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.ws.native</groupid>
                        <artifactid>jbossws-native-jaxws</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>javax.security</groupid>
                        <artifactid>jaas</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jca-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>bcel</groupid>
                        <artifactid>bcel</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>jpl-util</groupid>
                        <artifactid>jpl-util</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>jpl-pattern</groupid>
                        <artifactid>jpl-pattern</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss</groupid>
                        <artifactid>jbossxb</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.naming</groupid>
                        <artifactid>jnpserver</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>gnu-getopt</groupid>
                        <artifactid>getopt</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>sun-jaxb</groupid>
                        <artifactid>jaxb-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jpa</groupid>
                        <artifactid>jboss-jpa-deployers</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-jms-api</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.jbossas</groupid>
                <artifactid>jboss-as-management</artifactid>
                <version>5.1.0.GA</version>
                <classifier>jsr77-client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.deployers</groupid>
                        <artifactid>jboss-deployers-vfs</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.microcontainer</groupid>
                        <artifactid>jboss-kernel</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cl</groupid>
                        <artifactid>jboss-classloading-vfs</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-server</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cluster</groupid>
                        <artifactid>jboss-ha-server-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.bootstrap</groupid>
                        <artifactid>jboss-bootstrap</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-connector</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-cluster</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>apache-xerces</groupid>
                        <artifactid>xml-apis</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.jbossas</groupid>
                <artifactid>jboss-as-iiop</artifactid>
                <version>5.1.0.GA</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>apache-avalon</groupid>
                        <artifactid>avalon-framework</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>apache-xerces</groupid>
                        <artifactid>xml-apis</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>jacorb</groupid>
                        <artifactid>jacorb</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>javax.security</groupid>
                        <artifactid>jaas</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>javax.transcation</groupid>
                        <artifactid>jta</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>log4j</groupid>
                        <artifactid>log4j</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-classloading-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-corba-ots-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.integration</groupid>
                        <artifactid>jboss-transaction-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.javaee</groupid>
                        <artifactid>jboss-ejb-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-main</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-server</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-security</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system-jmx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.metadata</groupid>
                        <artifactid>jboss-metadata</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>javax.transaction</groupid>
                        <artifactid>jta</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.cluster</groupid>
                <artifactid>jboss-ha-client</artifactid>
                <version>1.1.1.GA</version>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.aspects</groupid>
                        <artifactid>jboss-remoting-aspects</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.jbossas</groupid>
                <artifactid>jboss-as-cluster</artifactid>
                <version>5.1.0.GA</version>
                <classifier>jboss-ha-legacy-client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>log4j</groupid>
                        <artifactid>log4j</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-server</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>jgroups</groupid>
                        <artifactid>jgroups</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cluster</groupid>
                        <artifactid>jboss-ha-server-api</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cluster</groupid>
                        <artifactid>jboss-ha-server-cache-spi</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cluster</groupid>
                        <artifactid>jboss-ha-server-jbc</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.cluster</groupid>
                        <artifactid>jboss-ha-server-cache-jbc</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system-jmx</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.jbossas</groupid>
                        <artifactid>jboss-as-system</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.bootstrap</groupid>
                        <artifactid>jboss-bootstrap</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>javax.transaction</groupid>
                        <artifactid>jta</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.slf4j</groupid>
                <artifactid>slf4j-api</artifactid>
                <version>1.5.6</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.aop</groupid>
                <artifactid>jboss-aop</artifactid>
                <version>2.1.1.GA</version>
                <classifier>client</classifier>
                <exclusions>
                    <exclusion>
                        <groupid>apache-xerces</groupid>
                        <artifactid>xml-apis</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.apache.ant</groupid>
                        <artifactid>ant</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>javassist</groupid>
                        <artifactid>javassist</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss</groupid>
                        <artifactid>jboss-reflect</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>qdox</groupid>
                        <artifactid>qdox</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>trove</groupid>
                        <artifactid>trove</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>log4j</groupid>
                        <artifactid>log4j</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss</groupid>
                <artifactid>jboss-common-core</artifactid>
                <version>2.2.14.GA</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.security</groupid>
                <artifactid>jboss-security-spi</artifactid>
                <version>2.0.3.SP1</version>
            </dependency>
            <dependency>
                <groupid>org.jboss</groupid>
                <artifactid>jboss-mdr</artifactid>
                <version>2.0.1.GA</version>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss</groupid>
                        <artifactid>jboss-reflect</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>org.jboss.client</groupid>
                <artifactid>jboss-client</artifactid>
                <version>5.1.0.CR1</version>
            </dependency>
            <dependency>
                <groupid>org.apache</groupid>
                <artifactid>xmlsec</artifactid>
                <version>1.4.2</version>
            </dependency>
            <dependency>
                <groupid>commons-logging</groupid>
                <artifactid>commons-logging</artifactid>
                <version>1.1.0.jboss</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.integration</groupid>
                <artifactid>jboss-integration</artifactid>
                <version>5.1.0.GA</version>
            </dependency>
            <dependency>
                <groupid>jboss.messaging</groupid>
                <artifactid>jboss-messaging</artifactid>
                <version>1.4.3.GA</version>
            </dependency>
            <dependency>
                <groupid>jboss</groupid>
                <artifactid>jboss-serialization</artifactid>
                <version>1.0.3.GA</version>
            </dependency>
            <dependency>
                <groupid>org.hibernate</groupid>
                <artifactid>ejb3-persistence</artifactid>
                <version>1.0.2.GA</version>
            </dependency>
            <dependency>
                <groupid>org.jboss.aspects</groupid>
                <artifactid>jboss-remoting-aspects</artifactid>
                <version>1.0.2</version>
                <exclusions>
                    <exclusion>
                        <groupid>org.jboss.aop</groupid>
                        <artifactid>jboss-aop</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.microcontainer</groupid>
                        <artifactid>jboss-kernel</artifactid>
                    </exclusion>
                    <exclusion>
                        <groupid>org.jboss.security</groupid>
                        <artifactid>jbosssx</artifactid>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupid>javassist</groupid>
                <artifactid>javassist</artifactid>
                <version>3.10.0.GA</version>
            </dependency>
        </dependencies>
         
        <build>
            <plugins>
                <plugin>
                    <artifactid>maven-assembly-plugin</artifactid>
                    <configuration>
                        <descriptorrefs>
                            <descriptorref>jar-with-dependencies</descriptorref>
                        </descriptorrefs>
                        <appendassemblyid>false</appendassemblyid>
                        <finalname>JBossClientLibraries-5.10-full</finalname>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-my-jar-with-dependencies</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
Even here things are not straightforward. (If somebody knows of a better way of doing the following section please tell me.)
 
We need to take the "JBossClientLibraries-5.10-full.jar" and edit it to remove everything out of the "META-INF/maven" folder except your artifact details. So in my example, everything will be deleted except the "sparg.tim" folder and its contents.
 
We can now install this to a repository as an artifact.

Create the Maven EJB Project

After that initial setup, things become much the way they should be – simple!


New Project -> Maven EJB Module:



Don’t forget to set your Java EE Version to 5, as JBoss does not yet have support for EE 6.

Go File -> new -> Session Bean:



Create a business method:


HelloBean class:
package sparg.tim.simpleejb;
 
import javax.ejb.Stateless;
 
/**
 *
 * @author tsparg
 */
@Stateless
public class HelloBean implements HelloBeanRemote {
 
    public String getMessage() {
        return "Hello Netbeans";
    }
}
 
HelloBeanRemote class:
package sparg.tim.simpleejb;
 
import javax.ejb.Remote;
 
/**
 *
 * @author tsparg
 */
@Remote
public interface HelloBeanRemote {
 
    String getMessage();
     
}

Right click on your project -> properties -> run and select the JBoss app server.
 
You can now run the EJB project.

Create NetBeans Platform Application

File -> New Project -> Maven -> Maven NetBeans Application:


Create the module project with the application (JBossClient-core in my example).
Navigate to your core module and add a dependency – this will be the artifact that we created right in the beginning.



Do the same procedure with the EJB Module you’ve just created, this time you should just be able to click the ‘Open Projects’ tab and select it from there.



Create a new TopComponent, new -> Window.
 
Make it "Open on Application Start", in the Editor Position:



I called mine HelloTopComponent.

Drag a Button and label onto the screen


Double click the button to get its ActionHandler.

The pertinent code is as follows:
   private void btnGetMessageActionPerformed(java.awt.event.ActionEvent evt) {
        Properties props = new Properties();
        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
        properties.put(Context.PROVIDER_URL, "127.0.0.1:1099");
        InitialContext ctx;
        try {
            ctx = new InitialContext(properties);
            HelloBeanRemote remote = (HelloBeanRemote) ctx.lookup("HelloBean/remote-sparg.tim.simplejb.HelloBeanRemote");
            lblOutput.setText(remote.getMessage());
            System.out.println(remote.getMessage());
        } catch (NamingException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

It is important to note that this line:
HelloBeanRemote remote =         
    (HelloBeanRemote) ctx.lookup( 
     "HelloBean/remote-sparg.tim.simplejb.HelloBeanRemote");
...will more than likely look different on your system.

Now if you’ve managed to get this right, and exercised large amounts of patience – when you click the "getMessage" button you will get this oh so sweet screen:




Although this has taken me a lot longer to figure out than I ever would have guessed, I'm pretty happy just to have the stuff up and running.
 
It would have been nice for GlassFish to have worked in the role that I have JBoss fulfilling currently - purely because of the tighter integration between GlassFish and the NetBeans communities.
 

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}