WildFly 10 Remote EJB invocation using JNDI ClassNotFoundException javax.ejb.EJBException

specialk1st

I have Java 8 & WildFly (JBoss) 10.0 installed. I have deployed the emsa.jar file with a remote EJB in it on the "remote" server.

I am attempting to use JNDI to invoke a method in the EJB from within a separate client app by running the client's main method as a Java App in Eclipse, but am getting the following error:

INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@61f8bee4, receiver=Remoting connection EJB receiver [connection=Remoting connection <545ebbdd>,channel=jboss.ejb,nodename=skb]} on channel Channel ID d234d46a (outbound) of Remoting connection 395b72b3 to localhost/127.0.0.1:8080
Exception in thread "naming-client-message-receiver-1-thread-1" java.lang.NoClassDefFoundError: javax/ejb/EJBException
    at org.jboss.ejb.client.SerializedEJBInvocationHandler.readResolve(SerializedEJBInvocationHandler.java:110)
    at org.jboss.ejb.client.SerializedEJBInvocationHandler.readResolve(SerializedEJBInvocationHandler.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.jboss.marshalling.reflect.SerializableClass.callReadResolve(SerializableClass.java:417)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1299)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:213)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNestedObject(RiverUnmarshaller.java:169)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1254)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:213)
    at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:45)
    at org.jboss.naming.remote.protocol.v1.Protocol$1$3.read(Protocol.java:156)
    at org.jboss.naming.remote.protocol.v1.Protocol$1$3.read(Protocol.java:149)
    at org.jboss.naming.remote.protocol.v1.BaseProtocolCommand.readResult(BaseProtocolCommand.java:59)
    at org.jboss.naming.remote.protocol.v1.Protocol$1.handleClientMessage(Protocol.java:149)
    at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1$MessageReceiver$1.run(RemoteNamingStoreV1.java:232)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: javax.ejb.EJBException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 23 more
javax.naming.NamingException: Unable to invoke lookup, status=WAITING
    at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:98)
    at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:95)
    at org.jboss.naming.remote.client.HaRemoteNamingStore$1.operation(HaRemoteNamingStore.java:276)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:132)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
    at org.jboss.naming.remote.client.RemoteContext.lookupInternal(RemoteContext.java:104)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:93)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:146)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at com.kelly_ann.employeemgmt.Main.main(Main.java:38)

The code in the client's Main class is:

package com.k_a.employeemgmt;

import java.util.List;
import java.util.Properties;

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

import com.k_a.employeemgmt.EmployeeMgmtService;
import com.k_a.employeemgmt.domain.Employee;

public class Main {

    // this remotely invokes the server's EmployeeMgmtService.getAllEmployees() method.
    public static void main(String[] args) {
        try {
            Properties jndiProperties = new Properties();
            jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
            jndiProperties.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
            jndiProperties.put("jboss.naming.client.ejb.context", true);
            System.out.println("MYTESTjndiProperties: " + jndiProperties); // gets here
            Context jndi = new InitialContext(jndiProperties);
            System.out.println("MYTESTjndi: " + jndi); // gets here

            EmployeeMgmtService service = (EmployeeMgmtService)jndi.lookup("emsa/EmployeeMgmtImpl!com.k_a.employeemgmt.EmployeeMgmtService");
            System.out.println("MYTESTservice: " + service); // doesn't get to here
            List<Employee> employees = service.getAllEmployees();
            for(Employee employee : employees) {
                System.out.println(employee);
            }
        }

My client application's Gradle build file (build.gradle) has the following dependencies in it:

apply plugin: 'java'

defaultTasks 'clean', 'compileJava', 'test', 'jar'

jar {
    archiveName = "emtc.jar"
}

test.useJUnit()

repositories {
    mavenCentral()
}

dependencies {
    compile 'jboss:jboss-client:4.0.2'
    compile 'org.jboss:jboss-remote-naming:2.0.4.Final'
    compile 'org.jboss.xnio:xnio-nio:3.3.6.Final'
    testCompile 'junit:junit:4.12'
}

I have tried following the WildFly/JBoss docs here for the last day but with no luck.

Any ideas?

specialk1st

Final solution:

The issue was my Gradle build.gradle file I needed to apply the 'application' plugin listed here and call the 'run' task. Once that was done it worked like a charm! Ended up using the maven repository BOM (from here) in Gradle build file too since that was the best way to ensure proper dependency management. Thanks for all the help! Much appreciated. :-)

Final code in the build.gradle file is below:

apply plugin: 'java'
apply plugin: 'application'

defaultTasks 'clean', 'compileJava', 'test', 'jar', 'run'

mainClassName = 'com.k_a.employeemgmt.Main'

jar {
    archiveName = "emtc.jar"
}

test.useJUnit()

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.wildfly:wildfly-ejb-client-bom:10.0.0.Final'
    testCompile 'junit:junit:4.12'
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Exception in thread "main" javax.ejb.EJBException: java.lang.ClassNotFoundException: javax.persistence.PersistenceException

From Dev

javax.ejb.EJBException after submitting form

From Dev

EJB3.1 System Exceptions vs javax.ejb.EJBException

From Dev

Wildfly10 - EJB-Remote Client - no response

From Dev

WildFly JNDI lookup for local EJB deployed in a WAR

From Dev

WildFly JNDI lookup for local EJB deployed in a WAR

From Dev

javax.ejb.EJBException: java.rmi.MarshalException

From Dev

EJB on Wildfly calling remote EJB from another Wildfly

From Dev

call remote ejb returns Invalid User using Wildfly 9.0.1

From Dev

Can't get Remote EJB to work with EJB Client API on Wildfly

From Dev

WildFly: EJB invocations from a remote client

From Dev

WildFly: EJB invocations from a remote client

From Dev

EJB wraps all Exceptions into EJBException

From Dev

JNDI Lookup of local EJB (no @EJB)

From Dev

JNDI Lookup of local EJB (no @EJB)

From Dev

javax.ejb.EJBException java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName

From Dev

javax.ejb.EJBException: Transaction aborted when trying to insert data to linked table

From Dev

WildFly: How to test EJB using embedded container?

From Dev

Java JNDI with EJB configuration

From Dev

Call remote ejb on wildfly 8.0 without jboss dependencies in classpath

From Dev

WildFly - EJB invocations from a remote client - Operation failed with status WAITING

From Dev

EJB remote client migration from JBoss AS 7.1 to Wildfly 8.1

From Dev

EJB self invocation and self inject

From Dev

Remote EJB return type

From Dev

Liberty Profile - Remote EJB

From Dev

Remote EJB return type

From Dev

Understanding of remote EJB

From Dev

How to cache the EJB remote interface in EJB 3.1?

From Dev

Hibernate EJB architecture - Model ClassNotFoundException

Related Related

  1. 1

    Exception in thread "main" javax.ejb.EJBException: java.lang.ClassNotFoundException: javax.persistence.PersistenceException

  2. 2

    javax.ejb.EJBException after submitting form

  3. 3

    EJB3.1 System Exceptions vs javax.ejb.EJBException

  4. 4

    Wildfly10 - EJB-Remote Client - no response

  5. 5

    WildFly JNDI lookup for local EJB deployed in a WAR

  6. 6

    WildFly JNDI lookup for local EJB deployed in a WAR

  7. 7

    javax.ejb.EJBException: java.rmi.MarshalException

  8. 8

    EJB on Wildfly calling remote EJB from another Wildfly

  9. 9

    call remote ejb returns Invalid User using Wildfly 9.0.1

  10. 10

    Can't get Remote EJB to work with EJB Client API on Wildfly

  11. 11

    WildFly: EJB invocations from a remote client

  12. 12

    WildFly: EJB invocations from a remote client

  13. 13

    EJB wraps all Exceptions into EJBException

  14. 14

    JNDI Lookup of local EJB (no @EJB)

  15. 15

    JNDI Lookup of local EJB (no @EJB)

  16. 16

    javax.ejb.EJBException java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName

  17. 17

    javax.ejb.EJBException: Transaction aborted when trying to insert data to linked table

  18. 18

    WildFly: How to test EJB using embedded container?

  19. 19

    Java JNDI with EJB configuration

  20. 20

    Call remote ejb on wildfly 8.0 without jboss dependencies in classpath

  21. 21

    WildFly - EJB invocations from a remote client - Operation failed with status WAITING

  22. 22

    EJB remote client migration from JBoss AS 7.1 to Wildfly 8.1

  23. 23

    EJB self invocation and self inject

  24. 24

    Remote EJB return type

  25. 25

    Liberty Profile - Remote EJB

  26. 26

    Remote EJB return type

  27. 27

    Understanding of remote EJB

  28. 28

    How to cache the EJB remote interface in EJB 3.1?

  29. 29

    Hibernate EJB architecture - Model ClassNotFoundException

HotTag

Archive