Hot questions for Using Enterprise JavaBeans in maven

Question:

If you declare a dependency in Maven, you can add a type, like war, jar, ejb.

I understand that compiling a project with type ejb is different from compiling a project with type jar because it triggers a different lifecycle.

But what is the difference in declaring a dependency?

Maven dependency type ejb vs jar seems to ask the same question, but the accepted answer seems strange to me. I doubt that a type in a dependency can trigger a lifecycle. Actually, I would expect that type ejb and type jar do exactly the same thing. Can somebody shed light on this?


Answer:

I doubt that a type in a dependency can trigger a lifecycle

You are not alone to doubt.

When you declare a dependency with the ejb type, you benefit from some facilities provided by Maven related to ejb as :

  • the ability to add the declaration of the EJB in the application.xml. Since Java EE 5, it is not required any longer.

  • the check that the dependency is a EJB and not a simple JAR.

  • and probably some other minor things.

You would have not these facilities if you declare your dependency with the jar type.

As you can notice, it doesn't change at a lot of thing but anyway, in both cases, it is the same JAR which is used for the dependency.

You don't refer to the ejb-client type but it is often something of more interesting since contrary to the case of the dependency with the jar or ejb type which uses the same jar, when you declare ejb-client type in a dependency, you depend on a different jar that the classic jar since this jar should contain only API classes to call the ejb. Of course, if we want the version ejb-client of our ejb, we have to specify it in the artifact which produces the ejb.

Question:

I'm writing a standalone client for an ejb application deployed to jboss wildfly 9.0.1.Final. The documentation I've reviewed suggests there is a readme file (readme-ejb-jms.txt) in the wildfly directory. This file contained the following suggestion for the maven dependencies:

<dependencies>
    <dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-ejb-client-bom</artifactId>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-jms-client-bom</artifactId>
        <type>pom</type>
    </dependency>
</dependencies>

If I use this I get an error saying version is required so I modified the dependencies to look like this:

    <dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-ejb-client-bom</artifactId>
        <version>9.0.1.Final</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-jms-client-bom</artifactId>
        <version>9.0.1.Final</version>
        <type>pom</type>
    </dependency>

When I run mvn clean install with the above I get this error:

The following artifacts could not be resolved: 
org.jboss.as:jboss-as-ejb-client-bom:pom:9.0.1.Final, 
org.jboss.as:jboss-as-jms-client-bom:pom:9.0.1.Final: 
Failure to find org.jboss.as:jboss-as-ejb-client-bom:pom:9.0.1.Final 

The full output from mvn clean install is shown below:

C:\_WORKSPACE\workspace\_myapp\myappjbosswildflyclient>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myappjbosswildflyclient 4.3.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.jboss.as:jboss-as-ejb-client-bom:pom:9.0.1.Final is missing, no dependency information available
[WARNING] The POM for org.jboss.as:jboss-as-jms-client-bom:pom:9.0.1.Final is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.957s
[INFO] Finished at: Tue Aug 04 17:17:04 EDT 2015
[INFO] Final Memory: 5M/118M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project myappjbosswildflyclient: Could not resolve dependencies for project mycompany-myapp:myappjbosswildflyclient:jar:4.3.0-SNAPSHOT: The following artifacts could not be resolved: org.jboss.as:jboss-as-ejb-client-bom:pom:9.0.1.Final, org.jboss.as:jboss-as-jms-client-bom:pom:9.0.1.Final: Failure to find org.jboss.as:jboss-as-ejb-client-bom:pom:9.0.1.Final in http://downl
oad.java.net/maven/2 was cached in the local repository, resolution will not be reattempted until the update interval of java.net2 has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
C:\_WORKSPACE\workspace\_myapp\myappjbosswildflyclient>

What should I be using for these dependencies?


Answer:

This works fine for me:

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

Question:


Answer:

Here :

<dependency>
  <groupId>com.koinplus</groupId>  
   <artifactId>KoinPlusCommons</artifactId>  
   <version>1.0</version> 
   <scope>system</scope>
   <systemPath>C://Users/trbrewjars/KoinPlusCommons-1.0.jar</systemPath>
 </dependency>

<dependency>
  <groupId>com.trbrew.common</groupId>  
   <artifactId>TrBrewCommons</artifactId>  
   <version>1.0</version> 
   <scope>system</scope>
   <systemPath>C://Users/trbrewjars/TrendBrewCommons-1.0.jar</systemPath>
 </dependency>

you declare your dependencies with a system scope. It prevents you from having these dependencies in the resolution of the TrBrewCommerce artifact and so in your final EAR artifact. If you want that these jars to be included in your EAR, using tricks to keep system scope is not a clean build. A cleaner way of doing is installing these two jars in your maven repository. After, you could remove the scope system (in this case, scope runtime will be used by default) and the system path in the dependency declaration such as:

<dependency>
  <groupId>com.koinplus</groupId>  
   <artifactId>KoinPlusCommons</artifactId>  
   <version>1.0</version> 
 </dependency>

<dependency>
  <groupId>com.trbrew.common</groupId>  
   <artifactId>TrBrewCommons</artifactId>  
   <version>1.0</version> 
 </dependency>

To install a Maven artifact, you have the install-file goal :

https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Question:

I have two almost identical projects (both created with maven, both very simple) where one deploys without any problems, the other gives me a PersistenceException:

javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'com.objectdb.jpa.Provider' not found

And I just don't see what I am missing here.

The working project is web application. I got it from the JPA Java EE 6 Tutorial. I has a simple jsp page, servlet, a database entity and a stateless bean for the entity.

When I deploy it, I can call the jsp, enter some example data which will be passed to the servlet, which then again writes the data into the ObjectDB database using the bean and the corresponding entity. simple.

The not working project is supposed to be an ejb-module with only the entity and the stateless bean.

But when I try deploying it on my local WildFly server, I get the above error. I also noticed, that the compiled ejb.jar has only a few kilobytes while the web application war files uses 1.4 MB. So I guess that it includes the necessary objectdb.jar library. But I can get the ejb.jar to include the library.

Here is my maven pom.xml of the working web application (sorry it's long):

<groupId>com.me</groupId>
<artifactId>ObjectDBMavenTest</artifactId>
<version>2.01.1-00001</version>
<packaging>war</packaging>

<name>ObjectDBMavenTest</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>       
    <dependency>
        <groupId>com.objectdb</groupId>
        <artifactId>objectdb</artifactId>
        <version>2.6.1_06</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>objectdb</id>
        <name>ObjectDB Repository</name>
        <url>http://m2.objectdb.com</url>
    </repository>
</repositories>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

And as a comparison the pom.xml of the not working ejb project:

<groupId>com.me</groupId>
<artifactId>Database</artifactId>
<version>2.01.1-00001</version>
<packaging>ejb</packaging>

<name>Database</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies> 
    <dependency>
        <groupId>com.objectdb</groupId>
        <artifactId>objectdb</artifactId>
        <version>2.6.1_06</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>objectdb</id>
        <name>ObjectDB Repository</name>
        <url>http://m2.objectdb.com</url>
    </repository>
</repositories>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <ejbVersion>3.1</ejbVersion>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Frankly I don't see much of a difference, only that one is going to be a war file the other a jar.

If it makes any difference, here are my two persistence.xml files.

working

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="ObjectDBMavenTestPU" transaction-type="JTA">
        <provider>com.objectdb.jpa.Provider</provider>
        <properties>
            <property name="javax.persistence.jdbc.url" value="$objectdb/db/guests.odb"/>
            <property name="javax.persistence.jdbc.user" value="user"/>
            <property name="javax.persistence.jdbc.password" value="password"/>
        </properties>
    </persistence-unit>
</persistence>

and not working

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="MyDatabase" transaction-type="JTA">
    <provider>com.objectdb.jpa.Provider</provider>
    <properties>
      <property name="javax.persistence.jdbc.url" value="$objectdb/db/myDatabase.odb"/>
      <property name="javax.persistence.jdbc.user" value="user"/>
      <property name="javax.persistence.jdbc.password" value="password"/>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>
    </properties>
  </persistence-unit>
</persistence>

Can anyone see what I am doing wrong here?


Answer:

Wow just writing about it here on SO helped me find my error :) I just have to force maven to include all dependencies. This can be done by including the following plugin into the pom.xml:

<plugins>
 ...
 <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
  </plugin>
</plugins>

Now the needed objectdb.jar library is included as dependency to the ejb.jar and I finally can deploy it without errors. Thanks everyone for caring :)

Question:

I have deployed a session bean in jboss-eap-6.3 which returns an employee object when getEmployeeById(int) method is called.

And I am invoking this by a remote client (used dependency: jboss-as-ejb-client-bom). Though it returns the expected result, it gives the java.lang.NoSuchMethodError: exception just before the result. What can be the reason behind this exception.

Full console output:

 Looking EJB via JNDI 
    ejb:/OMS_POC_1//EmployeeManagerImpl!com.test.oms.facade.EmployeeManager
    log4j: reset attribute= "false".
    log4j: Threshold ="null".
    log4j: Level value for root is  [DEBUG].
    log4j: root level set to DEBUG
    log4j: Class name: [org.apache.log4j.ConsoleAppender]
    log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
    log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n].
    log4j: Adding appender named [console] to category [root].
    2015-02-09 09:53:31 DEBUG logging:48 - Logging Provider: org.jboss.logging.Log4jLoggerProvider
    2015-02-09 09:53:31 INFO  client:42 - JBoss EJB Client version 1.0.5.Final
    2015-02-09 09:53:31 DEBUG EJBClientPropertiesLoader:101 - Looking for jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoader@221a5d08
    2015-02-09 09:53:31 DEBUG EJBClientPropertiesLoader:105 - Found jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoader@221a5d08
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:177 - endpoint.create.options. has the following options {}
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:177 - remote.connectionprovider.create.options. has the following options {org.xnio.Options.SSL_ENABLED=>false}
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:177 - remote.connection.default.connect.options. has the following options {org.xnio.Options.SASL_POLICY_NOANONYMOUS=>false}
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:177 - remote.connection.default.channel.options. has the following options {}
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:412 - Connection org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration$RemotingConnectionConfigurationImpl@79929190 successfully created for connection named default
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:230 - No clusters configured in properties
    2015-02-09 09:53:31 DEBUG EJBClientContext:112 - EJB client context initializer org.jboss.ejb.client.TransactionRecoveryContextInitializer@6a3d899a failed to initialize context org.jboss.ejb.client.EJBClientContext@6e1513f3
    java.lang.NoSuchMethodError: org.jboss.ejb.client.EJBClientContext.registerEJBClientContextListener(Lorg/jboss/ejb/client/EJBClientContextListener;)Z
        at org.jboss.ejb.client.TransactionRecoveryContextInitializer.initialize(TransactionRecoveryContextInitializer.java:36)
        at org.jboss.ejb.client.EJBClientContext.init(EJBClientContext.java:110)
        at org.jboss.ejb.client.EJBClientContext.create(EJBClientContext.java:164)
        at org.jboss.ejb.client.EJBClientContext.create(EJBClientContext.java:145)
        at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.<init>(ConfigBasedEJBClientContextSelector.java:70)
        at org.jboss.ejb.client.EJBClientContext.<clinit>(EJBClientContext.java:77)
        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:120)
        at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
        at com.sun.proxy.$Proxy0.getEmployeeById(Unknown Source)
        at com.test.rmi.RMIClient.main(RMIClient.java:29)
    2015-02-09 09:53:31 INFO  xnio:63 - XNIO Version 3.0.3.GA
    2015-02-09 09:53:31 INFO  nio:55 - XNIO NIO Implementation Version 3.0.3.GA
    2015-02-09 09:53:31 INFO  remoting:70 - JBoss Remoting version 3.2.3.GA
    2015-02-09 09:53:31 DEBUG nio:88 - Started channel thread 'Remoting "client-endpoint" write-1', selector sun.nio.ch.WindowsSelectorImpl@3c41068b
    2015-02-09 09:53:31 DEBUG nio:88 - Started channel thread 'Remoting "client-endpoint" read-1', selector sun.nio.ch.WindowsSelectorImpl@5114ae94
    2015-02-09 09:53:32 DEBUG RemotingConnectionEJBReceiver:145 - Channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 opened for context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@6e1513f3, receiver=Remoting connection EJB receiver [connection=Remoting connection <7669929e>,channel=jboss.ejb,nodename=isurug]} Waiting for version handshake message from server
    2015-02-09 09:53:32 INFO  VersionReceiver:101 - Received server version 2 and marshalling strategies [river]
    2015-02-09 09:53:32 INFO  RemotingConnectionEJBReceiver:162 - Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@6e1513f3, receiver=Remoting connection EJB receiver [connection=Remoting connection <7669929e>,channel=jboss.ejb,nodename=isurug]} on channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447
    2015-02-09 09:53:32 DEBUG RemotingConnectionEJBReceiver:427 - Received module availability report for 1 modules
    2015-02-09 09:53:32 DEBUG RemotingConnectionEJBReceiver:429 - Registering module EJBModuleIdentifier{appName='', moduleName='OMS_POC_1', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@6e1513f3, receiver=Remoting connection EJB receiver [connection=Remoting connection <7669929e>,channel=jboss.ejb,nodename=isurug]}
    2015-02-09 09:53:32 DEBUG ConfigBasedEJBClientContextSelector:142 - Registered 1 remoting EJB receivers for EJB client context org.jboss.ejb.client.EJBClientContext@6e1513f3
    2015-02-09 09:53:32 WARN  ChannelAssociation:392 - Unsupported message received with header 0xffffffff
    2015-02-09 09:53:32 DEBUG EJBClientContext:557 - org.jboss.ejb.client.RandomDeploymentNodeSelector@6b29ca81 deployment node selector selected isurug node for appname=,modulename=OMS_POC_1,distinctname=
    _______[ {Name: test}, {Age: 87}, {Description: tesfgsgs} ]
    2015-02-09 09:53:32 DEBUG AutoConnectionCloser:91 - Closing Remoting connection <7669929e>
    2015-02-09 09:53:32 INFO  ChannelAssociation:370 - Channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 can no longer process messages
    2015-02-09 09:53:32 DEBUG ChannelAssociation:105 - Closing channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447
    2015-02-09 09:53:32 DEBUG ChannelAssociation:336 - Registering a re-connect handler org.jboss.ejb.client.remoting.EJBClientContextConnectionReconnectHandler@4a776482 for broken channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 in EJB client context org.jboss.ejb.client.EJBClientContext@6e1513f3
    2015-02-09 09:53:32 DEBUG RemotingConnectionEJBReceiver:141 - Closing channelChannel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447
    2015-02-09 09:53:32 DEBUG AutoConnectionCloser:91 - Closing endpoint "client-endpoint" <5a5dae04>

Following is remote client code:

/**
 *
 */
package com.test.rmi;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.test.oms.facade.EmployeeManager;
import com.test.oms.facade.EmployeeManagerImpl;

public class RMIClient {

    public static void main(String[] args) {

        try {
            EmployeeManager manager = lookupRemoteEJB();
            System.out.println("_______"
                    + manager.getEmployeeById(3).toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    private static EmployeeManager lookupRemoteEJB() throws NamingException {
        final Hashtable jndiProperties = new Hashtable();
        jndiProperties.put(Context.URL_PKG_PREFIXES,
                "org.jboss.ejb.client.naming");

        final Context context = new InitialContext(jndiProperties);

        final String appName = "";
        final String moduleName = "OMS_POC_1";
        final String distinctName = "";
        final String beanName = EmployeeManagerImpl.class.getSimpleName();
        final String viewClassName = EmployeeManager.class.getName();

        System.out.println("Looking EJB via JNDI ");
        System.out.println("ejb:" + appName + "/" + moduleName + "/"
                + distinctName + "/" + beanName + "!" + viewClassName);

        return (EmployeeManager) context.lookup("ejb:" + appName + "/"
                + moduleName + "/" + distinctName + "/" + beanName + "!"
                + viewClassName);

    }
}

Update:

Following is maven dependency for jboss-as-ejb-client-bom in my pom.xml

<dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-ejb-client-bom</artifactId>
        <version>7.1.1.Final</version>
        <type>pom</type>
</dependency>

Answer:

As Federico mentioned in the comments above, I followed the link and add the settings.xml to M2_HOME. But the version 7.1.1.Final-redhat-1 doesn't workout as it makes the build failed. Following dependency worked for me.

  <dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-ejb-client-bom</artifactId>
        <version>7.4.0.Final-redhat-19</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

Question:

I read this, but cannot fix my issue.

I have java module where all files are java interfaces (screenshot).

<build>
    <finalName>tsm-mno-external-services</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <configuration>
                <generateClient>true</generateClient>
                <clientIncludes>
                    <clientInclude>com/test/ExternalCustomerCareServicesRemote.java</clientInclude>
                </clientIncludes>
            </configuration>
        </plugin>
    </plugins>
</build>

When Im run maven goal, ejb *-client.jar is not generated (In other modules with contains classed ejb *-client.jar generated without problems).

So question is next: can i generate ejb client from interfaces?


Answer:

There as an error in my pom.xml, so *-client.jar is not generated at package phase.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <configuration>
                <goal>package</goal>
                <generateClient>true</generateClient>
                <clientIncludes>
                    <clientInclude>path/**</clientInclude>
                </clientIncludes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>ejb</goal>
                    </goals>
                    <phase>package</phase>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Question:

I have a webapp (jsf + hibernate) deployed on a tomcat 6 server and i went to communicate remotely with some ejb deployed in a jboss application server 6.1.0.Final.

Does any one know all maven dependencies i have to add to make that call?


Answer:

According to this jaikiran pai post, the dependency would be:

<dependency>  
    <groupId>org.jboss.jbossas</groupId>  
    <artifactId>jboss-as-client</artifactId>  
    <version>6.0.0.Final</version>  
    <type>pom</type>  
</dependency>