3

I have two Wildfly servers. Server A connects to JMS topics and EJB's on Server B. They are both Wildfly 8.2.0.Final.

The client (a .war) on Server A has these maven dependencies:

  <dependency>
     <groupId>org.wildfly</groupId>
     <artifactId>wildfly-ejb-client-bom</artifactId>
     <version>8.2.0.Final</version>
     <type>pom</type>
  </dependency>
  <dependency>
     <groupId>org.wildfly</groupId>
     <artifactId>wildfly-jms-client-bom</artifactId>
     <version>8.2.0.Final</version>
     <type>pom</type>
  </dependency>

Is it possible to get rid of those, and just ask for specific Wildfly modules to be loaded in jboss-deployment-structure.xml instead? It seems like these Maven dependencies would increase the size of my .war.

Thanks!

Edit:

To look up EJB's on Server B, I'm using the "1. EJB client library" technique listed here: http://blog.akquinet.de/2014/09/26/jboss-eap-wildfly-three-ways-to-invoke-remote-ejbs/. My code is very similar to the example:

Properties prop = new Properties();
prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context context = new InitialContext(prop);

And:

remote.connections=default
remote.connection.default.host=127.0.0.1
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=${host.auth:JBOSS-LOCAL-USER}

remote.connection.default.username=${username}
remote.connection.default.password=${password}

And: context.lookup("ejb:/myapp/remote/calculator!de.akquinet.jbosscc.ejb.Calculator");

To connect to a JMS topic on Server B I'm using:

     final InitialContext initialContext = new InitialContext( m_jndiProperties );
     final ConnectionFactory connectionFactory = getConnectionFactory( initialContext );
     final Connection connection = connectionFactory.createConnection( m_clientKey.getUsername(), m_clientKey.getPassword() );

     try
     {
        final Topic updateTopic = getUpdateTopic( initialContext );
        final TopicSubscriber subscriber;

        if( m_isDurableSubscription )
        {
           connection.setClientID( m_clientKey.getJmsClientId() );
           connection.setExceptionListener( m_exceptionListener );
           final Session subscriberSession = connection.createSession( false, Session.AUTO_ACKNOWLEDGE );
           subscriber = subscriberSession.createDurableSubscriber( updateTopic, m_clientKey.getJmsSubscriptionId() );
        }
        else
        {
           connection.setExceptionListener( m_exceptionListener );
           final Session subscriberSession = connection.createSession( false, Session.AUTO_ACKNOWLEDGE );
           subscriber = ( (TopicSession)subscriberSession ).createSubscriber( updateTopic );
        }

        connection.stop();
        subscriber.setMessageListener( m_msgListener );

        m_connection = connection;

        maybeLogMessage( m_logger, GenericLogLevel.INFO, "Successfully subscribed to topic: '" + topicName + "'." );
     }
     catch( JMSException | NamingException e )
     {
        //noinspection ThrowableResultOfMethodCallIgnored
        JMSCloser.close( connection );
        throw e;
     }

The code to do these lookups is in a maven library that my .war uses. The library goes into WEB-INF/lib/ as usual.

3 Answers 3

1

You really shouldn't need either of those if you write standard EE code. If you use standard EJB or JMS, Wildfly will automatically detect it and load the modules for you.

Most projects should only need this:

<dependency>
    <groupId>org.jboss.spec</groupId>
    <artifactId>jboss-javaee-7.0</artifactId>
    <version>1.0.2.Final</version>
    <scope>provided</scope>
    <type>pom</type>
</dependency>
3
  • That's what I thought (and I have that dependency in provided scope), but I get an interesting vareity of ClassNotFound exceptions without these client bom's. I added some of the code I'm using. Jul 24, 2015 at 21:07
  • Since you aren't using @MessageDriven or other ejb3 annotations, the ejb3 subsystem may not be loading for your application. do you have an ejb-jar.xml file in your deployment?
    – Tea Curran
    Jul 25, 2015 at 18:10
  • I don't have an ejb-jar.xml file; I'll look into trying to get the ejb3 subsystem to load by using jboss-deployment-structure.xml. Jul 28, 2015 at 20:19
0

I was able to solve this by adding dependencies in jboss-deployment-structure.xml so that additional JBoss modules are loaded.

To be an EJB client: <module name="org.jboss.remote-naming"/> (your mileage may vary depending on how you are looking up EJB's).

To be a JMS client: <module name="org.hornetq"/>

0

this worked for me:

I replaced wildfly-jms-client-bom :

<dependency>
    <groupId>org.jboss.eap</groupId>
    <artifactId>wildfly-jms-client-bom</artifactId>
    <version>7.1.0.GA-redhat-11</version>
    <type>pom</type>
</dependency>

with javaee-api:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
    <scope>provided</scope>
</dependency>

and added an explicit dependency on module org.apache.activemq.artemis (the following ultimately adds Dependencies: org.apache.activemq.artemis in META-INF/MANIFEST.MF inside the war file):

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>3.2.3</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <archive>
            <manifestEntries>
                <Dependencies>org.apache.activemq.artemis</Dependencies>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.