title: exception when connect between EJB module to MySQL database
body: <p>I am creating an EJB Module running on Wildfly 10 which include an remote Interface named SampleBeanRemote: </p>
  
  <pre><code>@Remote
  public interface SampleBeanRemote {
      public int echo(int id);
  
  }
  </code></pre>
  
  <p>and ist implementation named SampleBeanRemoteImpl which include <code>echo</code> method will take the responsibility for connecting with MySQL database to get the data when my remote Client request for it:</p>
  
  <pre><code>@Stateless
  @Remote(SampleBeanRemote.class) 
  public class SampleBeanRemoteImpl implements SampleBeanRemote {
  
      private Connection conn;
  
      /**
       * Default constructor. 
       * @throws ClassNotFoundException 
       */
      public SampleBeanRemoteImpl() throws ClassNotFoundException {
          this.conn = setUpConnection();
      }
  
  
  
      private Connection setUpConnection() throws ClassNotFoundException {
          String url = "jdbc:mysql://localhost:3306/testdb";
          String userName = "root";
          String password = "root";
  
          try {
              Class.forName("com.mysql.jdbc.Driver");
              System.out.println("Connecting to a selected database...");
              conn = DriverManager.getConnection(url, userName, password);
              System.out.println("Connected database successfully...");
  
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return conn;
  
      }
  
  
  
  
  
      @Override
      public int echo(int id) {
          // TODO Auto-generated method stub
          Statement stmt = null;
          String sql = "SELECT data FROM testdb.ejbdata WHERE id="+id;
          int data = 0;
          try {
              stmt = conn.createStatement();
  
              ResultSet rs = stmt.executeQuery(sql);
  
              rs.next();
              data = rs.getInt("data");
  
  
              rs.close();
  
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return data;
  
  
      }
  
  }
  </code></pre>
  
  <p>My Client EJB, named <code>RemoteEJBClient</code> can request for data by calling the echo method with the corresponding id, then it will look like: </p>
  
  <pre><code>public class RemoteEJBClient {
  
      public static void main(String[] args) throws Exception {
          testRemoteEJB();
  
      }
  
      private static void testRemoteEJB() throws NamingException {
  
          final SampleBeanRemote ejb = lookupRemoteEJB2();
          int s = ejb.echo(1);
          System.out.println(s);
      }
  
  
      private static SampleBeanRemote lookupRemoteEJB2() throws NamingException {
  
          Properties jndiProperties = new Properties();
          jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
          jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
          jndiProperties.put("jboss.naming.client.ejb.context", true);
          jndiProperties.put(Context.PROVIDER_URL, "http-remoting://localhost:8085");
  
  
          /**Context For JNDI**/
          InitialContext context = new InitialContext(jndiProperties);
  
          final String appName = "";
          final String moduleName = "ejb-remote-server";
          final String distinctName = "";
          final String beanName = SampleBeanRemoteImpl.class.getSimpleName();
  
          final String viewClassName = SampleBeanRemote.class.getName();
  
          /**The nameOfEJB appears on the console when it is starting up.**/
          String nameOfEJB = appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName;
          System.out.println("Looking EJB via JNDI ");
          System.out.println(nameOfEJB);
          /**The Method .lookup("") search for EJB by name**/
          return (SampleBeanRemote) context.lookup(nameOfEJB);
      }
  
  
  }
  </code></pre>
  
  <p>But then i got some exception as shown below. I think this Problem is caused by the connection between my EJB Modules to the MySQL database, not because the Connection between my Client to EJB Modules. Does anyone have an idea how to fix it? Thank you</p>
  
  <pre><code>Exception in thread "main" javax.ejb.EJBException: java.lang.ClassNotFoundException: javax.enterprise.inject.CreationException
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:238)
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)
          at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
          at com.sun.proxy.$Proxy2.echo(Unknown Source)
          at com.sample.client.RemoteEJBClient.testRemoteEJB(RemoteEJBClient.java:23)
          at com.sample.client.RemoteEJBClient.main(RemoteEJBClient.java:16)
      Caused by: java.lang.ClassNotFoundException: javax.enterprise.inject.CreationException
          at java.net.URLClassLoader.findClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Unknown Source)
          at org.jboss.marshalling.AbstractClassResolver.loadClass(AbstractClassResolver.java:131)
          at org.jboss.marshalling.AbstractClassResolver.resolveClass(AbstractClassResolver.java:112)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadClassDescriptor(RiverUnmarshaller.java:948)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1255)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
          at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
          at org.jboss.marshalling.river.RiverObjectInputStream.defaultReadObject(RiverObjectInputStream.java:81)
          at java.lang.Throwable.readObject(Unknown Source)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:309)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1637)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
          at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
          at org.jboss.marshalling.river.RiverObjectInputStream.defaultReadObject(RiverObjectInputStream.java:81)
          at java.lang.Throwable.readObject(Unknown Source)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:309)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1637)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:224)
          at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1745)
          at org.jboss.marshalling.river.RiverObjectInputStream.defaultReadObject(RiverObjectInputStream.java:81)
          at java.lang.Throwable.readObject(Unknown Source)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:309)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1637)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1606)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1285)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
          at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
          at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
          at org.jboss.ejb.client.remoting.InvocationExceptionResponseHandler$MethodInvocationExceptionResultProducer.getResult(InvocationExceptionResponseHandler.java:79)
          at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:276)
          at org.jboss.ejb.client.EJBObjectInterceptor.handleInvocationResult(EJBObjectInterceptor.java:64)
          at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:290)
          at org.jboss.ejb.client.EJBHomeInterceptor.handleInvocationResult(EJBHomeInterceptor.java:88)
          at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:290)
          at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:46)
          at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:290)
          at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:142)
          at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:265)
          at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:453)
          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:204)
          ... 5 more
  </code></pre>