How to create EJB3 JPA Project in Eclipse (JBoss AS 7.1)

15 February 2012 By Praveen Macherla 54,684 views 75 Comments
63 Flares Twitter 8 Facebook 35 Google+ 20 63 Flares ×

Environment Used

  • JDK 6 (Java SE 6)
  • EJB 3.0 (stateless session bean)
  • EJB 3.0 Java Persistence API (JPA)
  • Eclipse Indigo IDE for Java EE Developers (3.7.1)
  • JBoss Tools – Core 3.3.0 M5 for Eclipse Indigo (3.7.1)
  • JBoss Application Server (AS) 7.1.0.CR1b / Final
  • MySQL 5.5 (To install MySQL refer this page)
  • MySQL Connector/J 5.1

Setting up development environment:

Read this page for installing and setting up the environment for developing and deploying EJB 3.0 on JBoss application server.

Project Description:

  • We are going to create a simple EJB 3 JPA project and a remote Java application client which will call/invoke the bean.
  • We create a JPA entity and a stateless session bean to perform operations on the entity.
  • For testing this JPA example we write a remote Java Application Client (main() method).
  • For simplicity, the entity, session bean and the client are created in the same project.

Steps

  1. Create Database Table
  2. Create JPA Entity
    • POJO class with @Entity annotation
    • persistence.xml
    • [optional] orm.xml if object relational mapping is defined in XML
  3. Create Stateless Session Bean
    • Bean interface
    • Bean Implementation class
  4. Create Client
    • Client Class with main() method
    • jboss-ejb-client.properties for defining JBoss specific client context in JBoss AS7
    • JAR files for accessing Session Bean
    • MySQL connector JAR file
  5. Adding MySQL data source in JBoss AS

Creating Database and table in MySQL

JPA is all about data persistence, so let’s examine how it works with the data store design. Assume you have a PROJECT table, as shown below.

FieldTypeKeyExtra
pnamevarchar(255)
pnumberintPrimary Keyauto_increment
plocationvarchar(255)
dept_no
  • Open command prompt (Windows) or Terminal(Linux) and type
    mysql –u [your-username] –p
    and press enter and type the password.
  • If you are using Windows, you can also use MySQL command line client which will be available in All programs menu.
  • For creating a new database, refer this page.
  • After creating the database type the command “use <database_name>;”
  • For creating a new table, refer this page.

Creating New EJB Project

  • Open Eclipse IDE and create a new EJB project which can be done in three ways,
    • Right click on Project Explorer -> New -> EJB Project
    • File menu -> New -> EJB Project
    • Click on the down arrow on New icon on toolbar -> EJB Project

  • Enter the project name as “FirstJPAProject” and make sure the JBoss 7.1 Runtime has been selected with the EJB 3.0 Module version.

  • Click Next -> Next -> and Finish.
  • You will see an EJB project in the Project Explorer view.

Creating JPA Entity

This is a very simple example that uses only one entity – “Project” which is a Plain Old Java Object class (POJO). This class, as well as the code that manipulates POJO instances, can be used without any changes in Java SE or Java EE environment. In this example we have used Java EE environment.

We will persist and find “project” entity using EntityManager API and retrieve all “projects” using Query interface.

Right click on ejbModule -> New -> Class

  • Enter the Java package name as “com.ibytecode.entities”
  • Enter the Class name as “Project”
  • Click “Finish”

Type the following code:

package com.ibytecode.entities;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Column;

@Entity(name = "project")
public class Project implements Serializable {
	private static final long serialVersionUID = 1L;

	public Project() {
		super();
	}
   
	@Id
	private int pnumber;
	private String pname;
	private String plocation;

	@Column(name = "dept_no")
	private int deptNo;

	public int getPnumber() {
		return pnumber;
	}
	public void setPnumber(int pnumber) {
		this.pnumber = pnumber;
	}
	public String getPname() {
		return pname;
	}
	public void setPname(String pname) {
		this.pname = pname;
	}
	public String getPlocation() {
		return plocation;
	}
	public void setPlocation(String plocation) {
		this.plocation = plocation;
	}
	public int getDeptNo() {
		return deptNo;
	}
	public void setDeptNo(int deptNo) {
		this.deptNo = deptNo;
	}
	@Override
	public String toString() {
		return "Project [pnumber=" + pnumber + ", pname=" + pname
				+ ", plocation=" + plocation + ", deptNo=" + deptNo + "]";
	}
}

Note that there is no @Table annotation. This is possible because the persistence provider will use the default rules to calculate the values for you. The name attribute in @Entity annotation defines the table name. Similarly if an instance variable name matches the column name in the table then there is no need to specify the @Column annotation.

Creating Session Bean and Bean Interface

  • Right click on ejbModule -> New -> Session Bean (EJB 3.x)
  • Enter the Java package name as com.ibytecode.businesslogic
  • Enter the Class name as ProjectBean
  • Select the State type as Stateless
  • Check the Remote Business Interface and enter the name as com.ibytecode.business.IProject.
  • The business interface will be created in different package (com.ibytecode.business)
  • Click Finish

Coding Bean and the Interface

  • Open Bean Interface and type the following code and save the file (Ctrl+s).
  • Interface can be either @Remote or @Local. In this example we have used @Remote.
package com.ibytecode.business;
import java.util.List;
import javax.ejb.Remote;

import com.ibytecode.entities.Project;

@Remote
public interface IProject {
	void saveProject(Project project);
	Project findProject(Project project);
	List<Project> retrieveAllProjects();
}
  • Open Bean and type the following code and save the file.
  • Bean type can either be @Stateful or @Stateless. In this example we have used @Stateless.
package com.ibytecode.businesslogic;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.ibytecode.business.IProject;
import com.ibytecode.entities.Project;

@Stateless
public class ProjectBean implements IProject {

	@PersistenceContext(unitName = "JPADB")
	private EntityManager entityManager;
	
    public ProjectBean() {   }

	@Override
	public void saveProject(Project project) {
		entityManager.persist(project);
	}

	@Override
	public Project findProject(Project project) {
		Project p = entityManager.find(Project.class, project.getPnumber());
		return p;
	}

	@Override
	public List<Project> retrieveAllProjects() {
		
		String q = "SELECT p from " + Project.class.getName() + " p";
		Query query = entityManager.createQuery(q);
		List<Project> projects = query.getResultList();
		return projects;
	}
}

Now the Stateless Session Bean has been created. The next step is to configure the datasource.

persistence.xml

How does the server know which database the EntityManager API should use to save / update / query the entity objects? The persistence.xml file gives you complete flexibility to configure the EntityManager.

The persistence.xml file is a standard configuration file in JPA which should be placed in META-INF directory inside the JAR file that contains the entities. The persistence.xml file must define a persistence-unit with a unique name which is used by EntityManager.

Right click on META-INF folder -> New -> Other -> XML -> XML file. Enter the file name as persistence.xml and type the following.

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
	<persistence-unit name="JPADB">
	<jta-data-source>java:/MySQLDS</jta-data-source>
		<properties>
			<property name="showSql" value="true"/>
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
		</properties>
	</persistence-unit>
</persistence>

In JBoss AS, the default JPA provider is Hibernate. The jta-data-source points to the JNDI name of the database this persistence unit maps to. The java:/MySQLDS points to the MySQL DB datasource in the JBoss AS. In the next step we setup this datasource.

Configuring MySQL Datasource in JBoss AS 7

Download MySQL connector

The connector can be downloaded from this link. This tutorial uses 5.1 version. Unzip the connector to a safe location on your computer which contains MySQL Connector J JAR.

Add a Module to AS 7

AS 7 uses a module system to provide isolation in class loading. We need to create a new module which contains the MySQL Connector J JAR.

In your JBoss AS 7 root folder, create folders in following hierarchy, modules/com/mysql/main.

If “modules” and “com” folders are already present then just create “mysql” and “main” folders.
Copy the MySQL Connector J JAR and paste in the “main” folder.

Now define the module in XML. Create a new module.xml file in “main” folder and paste the following lines.

<?xml version="1.0" encoding="UTF-8"?>
 
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
  <resources>
    <resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
  </dependencies>
</module>

The new module directory should have the following contents.

  • module.xml
  • mysql-connector-java-5.1.18-bin.jar

Create a Driver Reference

Now we need to make a reference to the module from the main application server configuration file (standalone.xml) which is found in JBossAS_Home/standalone/configuration

Find the ‘<drivers>’ element and add a new driver to it:

<drivers>
	<driver name="h2" module="com.h2database.h2">
		<xa-datasource-class>
			org.h2.jdbcx.JdbcDataSource
		</xa-datasource-class>
	</driver>
	<driver name="mysqlDriver" module="com.mysql">
		<xa-datasource-class>
			com.mysql.jdbc.Driver
		</xa-datasource-class>
	</driver>
</drivers>

Add the Datasource for the driver

Open the application server configuration file (standalone.xml) which is found in JBossAS_Home/standalone/configuration. Find the ‘<datasources>’ element and add a new datasource.

<datasource jndi-name="java:/MySQLDS" 
	pool-name="MySQLDS" enabled="true" use-java-context="true">
	<connection-url>
		jdbc:mysql://localhost:3306/YOUR-DATABASE-NAME
	</connection-url>
	<driver>mysqlDriver</driver>
	<security>
		<user-name>YOUR-MYSQL-USERNAME</user-name>
		<password>YOUR-MYSQL-PASSWORD</password>
	</security>
</datasource>

In the above code, use your database name, MySQL username and password in the highlighted lines.

In datasource element, the jndi-name=”java:/MySQLDS” should match the java:/MySQLDS in persistence.xml.
The value for <driver>mysqlDriver</driver> element should match the <drivers><driver name=”mysqlDriver” …>…</driver></drivers>

Deploying EJB JPA project

  • Now we need to deploy the project “FirstJPAProject” on server.
  • Deploying the project can be done in two ways,
    • Right click on the EJB project -> Run As -> Run On Server. Select the existing “JBoss 7.1 Runtime Server” and click Finish.
    • Right click on “JBoss 7.1 Runtime Server” available in Servers view -> Add and Remove… -> Select the EJB JAR file from the left pane and click Add-> and then Finish.

Start/Restart the Server

Right click on “JBoss 7.1 Runtime Server” from Servers view and click on Start if it has not yet been started. If the project is deployed properly with global JNDI mapping then you will see the following message in the console.

Deployed “FirstJPAProject.jar”

Creating Client

  • The next step is to write a remote Java client application (with main()) for accessing and invoking the bean deployed on the server
  • Client uses JNDI to lookup for a proxy of your bean and invokes method on that proxy.

Creating JNDI InitialContext

Obtaining a Context using InitialContext

  • All naming service operations are performed on some implementation of the javax.naming.Context interface. Therefore, the starting point of interacting with the naming service is to obtain a Context by providing the properties specific to the server implementation being used. In our case it is, JBoss Application Server.
  • To create a javax.naming.InitialContext, we need to initialize it with properties from the environment. JNDI verifies each property’s value by merging the values from the following two sources,
    • Using parameterized constructor of InitialContext which takes properties of supplied environment
    • jndi.properties resource files found on the classpath.

NOTE:We will use parameterized constructor for initializing the InitialContext.

For JBoss AS 7 we need to set the Context.URL_PKG_PREFIXES property with value “org.jboss.ejb.client.naming” to obtain the InitialContext.

The following utility class is used to create InitialContext for JBoss AS and can be reused in all applications. Otherwise the code written in this class should be repeated in all clients.

  • Right click on ejbModule -> New -> Class
  • Enter the package name as com.ibytecode.clientutility
  • Enter the Class name as JNDILookupClass
  • Click on Finish

Type the following code.

package com.ibytecode.clientutility;

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class JNDILookupClass {

	private static Context initialContext;

	private static final String PKG_INTERFACES = "org.jboss.ejb.client.naming";

	public static Context getInitialContext() throws NamingException {
		if (initialContext == null) {
			Properties properties = new Properties();
			properties.put(Context.URL_PKG_PREFIXES, PKG_INTERFACES);

			initialContext = new InitialContext(properties);
		}
		return initialContext;
	}
}

Creating client class

  • Right click on ejbModule -> New -> Class
  • Enter the package name as com.ibytecode.client
  • Enter the Class name as EJBApplicationClient
  • Check the main() method option
  • Click on Finish

Type the following code:


package com.ibytecode.client;

import java.util.List;

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

import com.ibytecode.business.IProject;
import com.ibytecode.businesslogic.ProjectBean;
import com.ibytecode.clientutility.JNDILookupClass;
import com.ibytecode.entities.Project;

public class EJBApplicationClient {
	
	public static void main(String[] args) {
		IProject bean = doLookup();
		
		Project p1 = new Project();
		p1.setPname("Banking App");
		p1.setPlocation("Town City");
		p1.setDeptNo(1);
		
		Project p2 = new Project();
		p2.setPname("Office Automation");
		p2.setPlocation("Downtown");
		p2.setDeptNo(2);

		// 4. Call business logic
		//Saving new Projects
		bean.saveProject(p1);
		bean.saveProject(p2);
		
		//Find a Project
		p1.setPnumber(1);
		Project p3 = bean.findProject(p1);
		System.out.println(p3);
		
		//Retrieve all projects
       System.out.println("List of Projects:");
		List<Project> projects = bean.retrieveAllProjects();
		for(Project project : projects)
			System.out.println(project);
		
		
	}

	private static IProject doLookup() {
		Context context = null;
		IProject bean = null;
		try {
			// 1. Obtaining Context
			context = JNDILookupClass.getInitialContext();
			// 2. Generate JNDI Lookup name
			String lookupName = getLookupName();
			// 3. Lookup and cast
			bean = (IProject) context.lookup(lookupName);

		} catch (NamingException e) {
			e.printStackTrace();
		}
		return bean;
	}

	private static String getLookupName() {
		/*The app name is the EAR name of the deployed EJB without .ear 
		suffix. Since we haven't deployed the application as a .ear, the app 
		name for us will be an empty string */
		String appName = "";

		/* The module name is the JAR name of the deployed EJB without the 
		.jar suffix.*/
		String moduleName = "FirstJPAProject";

		/* AS7 allows each deployment to have an (optional) distinct name. 
		This can be an empty string if distinct name is not specified.*/
		String distinctName = "";

		// The EJB bean implementation class name
		String beanName = ProjectBean.class.getSimpleName();

		// Fully qualified remote interface name
		final String interfaceName = IProject.class.getName();

		// Create a look up string name
		String name = "ejb:" + appName + "/" + moduleName + "/" + 
				distinctName 	+ "/" + beanName + "!" + interfaceName;
		return name;
	}
}

Setting up EJB client context properties

An EJB client context is a context which contains contextual information for carrying out remote invocations on EJBs. This is a JBoss AS specific API. The EJB client context can be associated with multiple EJB receivers. Each EJB receiver is capable of handling invocations on different EJBs.
For example, an EJB receiver “ClientA” might be able to handle invocation on a bean identified by app-A/module-A/distinctinctName-A/BeanA!com.ibc.RemoteBeanA, app-B/module-B/distinctName-B/BeanB!RemoteBeanB, etc. Each such EJB receiver knows about what set of EJBs it can handle and each of the EJB receiver knows which server target to use for handling the invocations on the bean. The server IP address and its remoting port should be specified in the properties file placed in the client classpath. This properties file (EJB client context) will then be used internally by the JNDI implementation to handle invocations on the bean proxy.

Create a file “jboss-ejb-client.properties” in the classpath of the application. We can place it in ejbModule folder of our application. The jboss-ejb-client.properties contains the following properties:

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

remote.connections=default

remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

Adding JAR files required for the client to run the client application

  • Open Run Configurations… in Run menu or Run Configurations in Run icon.
  • Select the client application (EJBApplicationClient) under Java Application from left pane and open the Classpath tab from right side pane. If you don’t see your client application, run it once. Select “User Entries” and click on “Add External JARs”.
  • Add the following JAR files.
    JAR nameLocation
    jboss-transaction-api_1.1_spec-1.0.0.Final.jarAS7_HOME/modules/javax/transaction/api/main/
    jboss-ejb-api_3.1_spec-1.0.1.Final.jarAS7_HOME/modules/javax/ejb/api/main/
    jboss-ejb-client-1.0.0.Beta10.jarAS7_HOME/modules/org/jboss/ejb-client/main/
    jboss-marshalling-1.3.0.GA.jarAS7_HOME/modules/org/jboss/marshalling/main/
    xnio-api-3.0.0.CR5.jarAS7_HOME/modules/org/jboss/xnio/main/
    jboss-remoting-3.2.0.CR6.jarAS7_HOME/modules/org/jboss/remoting3/main/
    jboss-logging-3.1.0.Beta3.jarAS7_HOME/modules/org/jboss/logging/main/
    xnio-nio-3.0.0.CR5.jarAS7_HOME/modules/org/jboss/xnio/nio/main/
    jboss-sasl-1.0.0.Beta9.jarAS7_HOME/modules/org/jboss/sasl/main/
    jboss-marshalling-river-1.3.0.GA.jarAS7_HOME/modules/org/jboss/marshalling/river/main/

    You can also add it in Build path (Right click on your EJB Project->Properties, select Java Build Path from left side pane and select Libraries from right side and click on Add External JARs)

If you are using JBoss Application Server (AS) 7.1.0 Final version then it is sufficient to add only one client JAR file (jboss-client-7.1.0.Final.jar) which is located in AS7_HOME/bin/client

The figure below shows the final directory structure of this example.

Run the client

Use Ctrl + F11 to run the client.

Project [pnumber=1, pname=Banking App, plocation=Town City, deptNo=1]
List of Projects:
Project [pnumber=1, pname=Banking App, plocation=Town City, deptNo=1]
Project [pnumber=2, pname=Office Automation, plocation=Downtown, deptNo=2]

Tags: , , , , , , , , , ,

  • Bogdan

    Hi,
    I tried your example and I came up with this error when I want to run the client:

    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at com.scriptenginedb.client.EJBApplicationClient.doLookup(EJBApplicationClient.java:55)
    at com.scriptenginedb.client.EJBApplicationClient.main(EJBApplicationClient.java:18)

    I think you forgot something in “JNDILookupClass”.
    I am new to this so I can’t correct you, but I am waiting for your errata :)

    Great work by the way!

  • Bogdan

    Solved the problem importing the dependecies in the client. Now I have another problem:
    Exception in thread “main” javax.ejb.NoSuchEJBException: No such EJB[appname=, modulename=DatabaseSE, distinctname=, beanname=ProjectBean, viewclassname=null]
    at org.jboss.ejb.client.remoting.GeneralInvocationFailureResponseHandler.processMessage(GeneralInvocationFailureResponseHandler.java:75)
    at org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver.handleMessage(ChannelAssociation.java:297)
    at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:409)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

  • http://theopentutorials.com nithya

    May be you might have missed the ejb client jar file in your classpath and that is why you got that NoInitialContextException.

    And for the NoSuchEJBException, make sure you have the bean deployed successfully on the server. See the jboss log/console for any errors.

    I see the viewclassname is null which should not be. So in the client, check the lookup name String name = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + interfaceName;

    We deployed the bean as jar, so no appName and the moduleName is the deployed jar file name (in our case it is the project name). Also check the interfaceName is given properly or not.

  • Bogdan

    Hi nithya,

    Thanks! The jar was not deployed… stupid me. I can’t explain why I didn’t realized that.
    It is working now.

    You were right regarding the first error, I forgot to import the jars.

    Have a nice day and keep up the good work :)

  • http://theopentutorials.com nithya

    Glad to know it is working :-). Thank You

  • wadios

    hi when i come to step 10 it finished whith this error

    14:45:05,691 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of “FirstJPAProject.jar”
    14:45:05,730 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named ProjectBean in deployment unit deployment “FirstJPAProject.jar” are as follows:

    java:global/FirstJPAProject/ProjectBean!com.ibytecode.business.IProject
    java:app/FirstJPAProject/ProjectBean!com.ibytecode.business.IProject
    java:module/ProjectBean!com.ibytecode.business.IProject
    java:jboss/exported/FirstJPAProject/ProjectBean!com.ibytecode.business.IProject
    java:global/FirstJPAProject/ProjectBean
    java:app/FirstJPAProject/ProjectBean
    java:module/ProjectBean

    14:45:05,753 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: Failed to process phase INSTALL of deployment “FirstJPAProject.jar”
    at

    pleaaaaaaaaaase i need help !!!

    • http://theopentutorials.com Praveen

      wadios,
      There should be failure messages displayed in the console. Without that it is hard to help. See the full log in console.

  • wadios

    thank you
    the problem was that when i created the project I included some librairy , i made a new project and it work correctly ,
    thank you sir for your answer

  • Pingback: Move thirty six software - How to create EJB3 JPA Project in Eclipse

  • Manish

    Thanks for providing us a excellent tutorials on EJB with JBoss on Eclipse.

    I want to bifurcate the EJB module and Client code. How to create a Java Project which access the EJB, which EJB files are required to put into this project.

    Thanks
    Manish

    • http://theopentutorials.com Nithya

      Thanks.
      Create a JAR file with bean interface and Entities, you can do it in Eclipse. Select bean interface, Entities and Right click -> export -> Java-> JAR file.

      • If you are using Java project then you need to add this JAR file and also JBoss EJB client JAR file (jboss-client-7.1.0.Final.jar which is located in AS7_HOME/bin/client) in either Client’s BuildPath or Classpath. Right click on client’s project -> Properties -> Buildpath -> Libraries -> Add External JAR. Deploy bean project on Server and run the client code
      • If you are using Dynamic Web project (Servlet/JSP) then you have to place this JAR file in lib folder of this project. Web Content/WEB-INF/lib. Deploy Servlet project on server and run the Servlet.
  • Ataullah

    hai, its really a nice tutorial. plz… try to help me with this error

    when i try to deploy the Bean into the Jboss server at step 10 i am getting this following error plz… correct me with this mistake.

    01:23:13,295 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: Failed to process phase INSTALL of deployment “FirstJPAProject.jar”
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_22]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_22]
    at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_22]
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class com.ibytecode.businesslogic.ProjectBean for component ProjectBean has errors:
    JBAS011440: Can’t find a persistence unit named JPADB in deployment “FirstJPAProject.jar”
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:169)
    at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:162)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:155)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
    … 5 more

    01:23:13,512 INFO [org.jboss.as.server] (DeploymentScanner-threads – 2) JBAS015870: Deploy of deployment “FirstJPAProject.jar” was rolled back with failure message {“JBAS014671: Failed services” => {“jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL” => “org.jboss.msc.service.StartException in service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: Failed to process phase INSTALL of deployment “FirstJPAProject.jar”"},”JBAS014771: Services with missing/unavailable dependencies” => ["jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.ValidatorFactoryjboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBeanMissing[jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.ValidatorFactoryjboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean]“,”jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.Validatorjboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBeanMissing[jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.Validatorjboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean]“]}
    01:23:13,522 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment FirstJPAProject.jar in 12ms
    01:23:13,524 INFO [org.jboss.as.controller] (DeploymentScanner-threads – 2) JBAS014774: Service status report
    JBAS014775: New missing/unsatisfied dependencies:
    service jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean (missing) dependents: [service jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.Validator, service jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.ValidatorFactory]
    JBAS014777: Services which failed to start: service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: Failed to process phase INSTALL of deployment “FirstJPAProject.jar”

    01:23:13,528 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) {“JBAS014653: Composite operation failed and was rolled back. Steps that failed:” => {“Operation step-2″ => {“JBAS014671: Failed services” => {“jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL” => “org.jboss.msc.service.StartException in service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: Failed to process phase INSTALL of deployment “FirstJPAProject.jar”"},”JBAS014771: Services with missing/unavailable dependencies” => ["jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.ValidatorFactoryjboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBeanMissing[jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.ValidatorFactoryjboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean]“,”jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.Validatorjboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBeanMissing[jboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean.Validatorjboss.naming.context.java.comp.FirstJPAProject.FirstJPAProject.ProjectBean]“]}}}

    • http://theopentutorials.com Nithya

      Skip step 10 and follow steps 11 and 12 and then redo the step 10. I modified the post to reflect the same.

  • Carlos

    Hi,

    First, thank you for a great tutorial! Very easy to follow along with.
    I got all the way up to Step 12 and received this error below when I deployed the EJB project to JBoss 7.1

    Please assist.Any help would be greatly appreciated! Thank you so much in advance guys!

    15:57:40,790 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of “FirstJPAProject.jar”
    15:57:40,930 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named ProjectBean in deployment unit deployment “FirstJPAProject.jar” are as follows:

    java:global/FirstJPAProject/ProjectBean!com.ibytecode.business.IProject
    java:app/FirstJPAProject/ProjectBean!com.ibytecode.business.IProject
    java:module/ProjectBean!com.ibytecode.business.IProject
    java:jboss/exported/FirstJPAProject/ProjectBean!com.ibytecode.business.IProject
    java:global/FirstJPAProject/ProjectBean
    java:app/FirstJPAProject/ProjectBean
    java:module/ProjectBean

    15:57:41,165 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit.”FirstJPAProject.jar”.INSTALL: Failed to process phase INSTALL of deployment “FirstJPAProject.jar”
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class com.ibytecode.businessLogic.ProjectBean for component ProjectBean has errors:
    JBAS011440: Can't find a persistence unit named JPADB in deployment "FirstJPAProject.jar"
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:169)
    at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:162)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:155)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
    … 5 more

    • http://theopentutorials.com Praveen Macherla

      @PersistenceContext(unitName = “JPADB”) in bean class should match with the in META-INF/persistence.xml.

      • Carlos

        Wow thanks for the speedy response!

        I thought that I completed that part correctly.

        My persistence.xml is located in:
        C:\workspace\FirstJPAProject\ejbModule\META-INF\persitence.xml

        And the entire content of the xml is below:

        java:/MySQLDS

        Please, advise. Thank you so much!

        • http://theopentutorials.com Nithya Vasudevan

          Please use the <code> tag to post the xml code.

      • Carlos

        Praveen, Well i tried to paste the code in the xml but i couldnt. log story short, the name matches in my xml. unitName = “JPADB”

        any other advice? much appreciated! Thank you!

        -C

        • http://theopentutorials.com Praveen Macherla

          Actually you can use the [xml] [/xml] tags to post code. And regarding your problem, the only thing I see is the persistence.xml file name misspelled. If that is not the case, try recreating this project and deploy it.

          Good Luck.

  • Carlos

    nithya thank you!

    Here is my perstience.xml code

    java:/MySQLDS

  • Carlos

    Hmm well it appears i cant paste the entire xml code even with the tag.
    ill try it here with just the meat of the code without heading:

    java:/MySQLDS

  • nigel rowe


    If you are using Java project then you need to add this JAR file in either Client’s BuildPath or Classpath. Right click on client’s project -> Properties -> Buildpath -> Libraries -> Add External JAR. Deploy bean project on Server and run the client code

    I think you still need to add the jboss-as-7.1.0.Final/modules/org/jboss/ejb-client/main/jboss-ejb-client-1.0.2.Final.jar otherwise the JNDILookupClass.getInitialContext() throws errors.
    Well, that’s the only way I could get it to work from a bog standard java project.

    Apart from that, excellent tutorial my friend.

    • http://theopentutorials.com Nithya Vasudevan

      Yes, you need to add that JAR file in Client’s classpath if the client and EJB are in separate project. Updated the comment

  • Pingback: JavaPins

  • charbonnier

    hi !
    i read the example but i’ve this error

    lug 02, 2012 3:45:30 PM org.jboss.ejb.client.EJBClient
    INFO: JBoss EJB Client version 1.0.5.Final
    lug 02, 2012 3:45:30 PM org.xnio.Xnio
    INFO: XNIO Version 3.0.3.GA
    lug 02, 2012 3:45:30 PM org.xnio.nio.NioXnio
    INFO: XNIO NIO Implementation Version 3.0.3.GA
    lug 02, 2012 3:45:30 PM org.jboss.remoting3.EndpointImpl
    INFO: JBoss Remoting version 3.2.3.GA
    lug 02, 2012 3:45:31 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
    INFO: Received server version 1 and marshalling strategies [river]
    lug 02, 2012 3:45:31 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
    INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@8c30cbb, receiver=Remoting connection EJB receiver [connection=Remoting connection ,channel=jboss.ejb,nodename=nbruicardorange]} on channel Channel ID df6764f1 (outbound) of Remoting connection 583a2d43 to localhost/127.0.0.1:4447
    lug 02, 2012 3:45:31 PM org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleMessage
    WARN: Unsupported message received with header 0xffffffff
    lug 02, 2012 3:45:36 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
    INFO: Initial module availability report for Remoting connection EJB receiver [connection=Remoting connection ,channel=jboss.ejb,nodename=nbruicardorange] wasn’t received during the receiver context association
    Exception in thread “main” java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:RuiEJB,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@798322d1
    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
    at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    at $Proxy0.saveEntityBean(Unknown Source)
    at it.ssc.client.EJBApplicationClient.main(EJBApplicationClient.java:29)

    string name is “ejb:/RuiEJB//SessionBean!it.ssc.business.SessionBeanRemote”

  • Vera

    Hello,
    Thanks for your post.
    It is really useful:)

    After I got the same outcomes, I wonder that means my client is already connected to the DB I chose?
    Besides, how can I modify the codes in java to insert the data into the table I chose?

    Thanks!!

    • http://theopentutorials.com Nithya Vasudevan

      Client is just invoking the method in EJB which connects to the database and returns the value. This example already shows how to insert data in the table, see saveProject() method in ProjectBean class.

  • raghav

    Very Helpful tutorial, Thanks to the uploader.

  • Navaneetha

    Hi,it is very good tutorials.I trying to do this example in eclipse indigo with jboss(5.1) server.I not able to find the Standared.xm file.please help from that step onwards.is it possible to the above example using jboss(5.1).please help me.
    thank you

    • http://theopentutorials.com Nithya Vasudevan

      Refer this tutorial link for creating EJB3 JPA project with JBoss AS 5.1 and Eclipse IDE

  • yokesoe

    Hello…. I am new in Java. and I got this errors .. so please help me guru…………………….

    Exception in thread “main” java.lang.NoClassDefFoundError: org/jboss/marshalling/FieldSetter
    at org.jboss.ejb.client.EJBLocator.(EJBLocator.java:53)
    at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:137)
    at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:113)
    at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:96)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at com.ibytecode.client.EJBApplicationClient.doLookup(EJBApplicationClient.java:55)
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:16)
    Caused by: java.lang.ClassNotFoundException: org.jboss.marshalling.FieldSetter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    … 7 more

  • Nirbhay

    Hi thanks for the amazing tutorial
    but i have this error

    Aug 24, 2012 12:03:52 AM org.jboss.ejb.client.EJBClient
    INFO: JBoss EJB Client version 1.0.5.Final
    Exception in thread “main” java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:FirstJPAProject,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@8ef455
    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
    at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    at $Proxy0.saveCatalog(Unknown Source)
    at ejb3pack.client.EJBApplicationClient.main(EJBApplicationClient.java:36)

  • krishna

    I am getting the below message in the console and Hello world is not shown, please guide :

    “Found HelloWorldSessionBean.jar in deployment directory. To trigger deployment create a file called HelloWorldSessionBean.jar.dodeploy”

    • http://theopentutorials.com Praveen Macherla

      Do not spam. Know that others are busy with their works too. Reg the error, check the console, you may see some exceptions and cause.

  • krishna

    Hi,

    I am getting below error, please help

    INFO: JBoss EJB Client version 1.0.5.Final
    Exception in thread “main” java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:FirstJPAProject,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@482923

    • http://theopentutorials.com Praveen Macherla

      Possible problems – wrong lookup path, missing jars, ejb project not deployed on the server. Check the lookup path, include the necessary jars, see the jboss server console for exceptions. Carefully do all the steps mentioned.

  • Owais

    hi
    Nice tutorial but i got this type of error.
    Please help me to solve it.Thanks in advance.

    Exception in thread “main” java.lang.reflect.UndeclaredThrowableException
    at $Proxy0.saveProject(Unknown Source)
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:30)
    Caused by: java.lang.ClassNotFoundException: org.hibernate.exception.ConstraintViolationException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.jboss.marshalling.AbstractClassResolver.loadClass(AbstractClassResolver.java:135)
    at org.jboss.marshalling.AbstractClassResolver.resolveClass(AbstractClassResolver.java:116)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadClassDescriptor(RiverUnmarshaller.java:892)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1204)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
    at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1593)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
    at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1593)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
    at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1593)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1557)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
    at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)
    at org.jboss.ejb.client.remoting.InvocationExceptionResponseHandler$MethodInvocationExceptionResultProducer.getResult(InvocationExceptionResponseHandler.java:82)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:270)
    at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:47)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:272)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:132)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:260)
    at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:399)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:140)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    … 2 more

  • Krishna GN

    Hi Nithya ,

    I have been working on the Migration Project from EJB 2 to EJB 3 with WebLogic Server 10.3 and DataBase as Sybase .

    Actually I getting the following error as

    “(java.lang.IllegalArgumentException: Unknown entity bean class:
    class entity.MasatoTable,
    please verify that this class has been marked with the @Entity annotation.) ” . Can u please help with this error . It will be much useful if you can Publish a Migration Project from EJB 2 to EJB 3 with Web Logic . Ur Posts have been very much useful.

    Please help to solve my issue. Your Inputs are very much Appreciated.

    Please reply to mail: [email protected] or reply this post .

    Thanks

    • http://mywebsite.com sonali2708

      Excellent tutorial to start up with learning ejb in jboss AS 7 !!!
      Thanks Nithya.. :)

  • Jones Gold

    Hi Nithya……..really a very nice explanation… but when i try to deploy my project server following message

    JBAS014775: New missing/unsatisfied dependencies:
    service jboss.jdbc-driver.mysqlDriver (missing) dependents: [service jboss.data-source.java:/MySQLDS]

    16:43:13,564 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
    16:43:13,564 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.1.Final “Brontes” started (with errors) in 2497ms – Started 134 of 212 services (2 services failed or missing dependencies, 74 services are passive or on-demand)
    16:46:48,377 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) JBAS015003: Found Database.ear in deployment directory. To trigger deployment create a file called Database.ear.dodeploy
    16:46:48,409 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of “Database.ear”
    16:46:48,440 WARN [org.jboss.metadata.parser.jboss.JBossAppMetaDataParser] (MSC service thread 1-3) loader-repository element in jboss-app.xml is deprecated and has been ignored
    16:46:48,472 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of “Jsfdatabase.war”
    16:46:48,472 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of “Ejbdatabase.jar”
    16:46:48,518 INFO [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011401: Read persistence.xml for JPADB
    16:46:48,596 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named LoginDao in deployment unit subdeployment “Ejbdatabase.jar” of deployment “Database.ear” are as follows:

    java:global/Database/Ejbdatabase/LoginDao!dao.LoginDaoRemote
    java:app/Ejbdatabase/LoginDao!dao.LoginDaoRemote
    java:module/LoginDao!dao.LoginDaoRemote
    java:jboss/exported/Database/Ejbdatabase/LoginDao!dao.LoginDaoRemote
    java:global/Database/Ejbdatabase/LoginDao
    java:app/Ejbdatabase/LoginDao
    java:module/LoginDao

    16:46:48,862 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.subunit.”Database.ear”.”Ejbdatabase.jar”.INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit.”Database.ear”.”Ejbdatabase.jar”.INSTALL: Failed to process phase INSTALL of subdeployment “Ejbdatabase.jar” of deployment “Database.ear”
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_27]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_27]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_27]
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class dao.LoginDao for component LoginDao has errors:
    JBAS011440: Can’t find a persistence unit named EntityBean in subdeployment “Ejbdatabase.jar” of deployment “Database.ear”
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:169)
    at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:162)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:155)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    … 5 more

    16:46:48,908 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Initializing Mojarra 2.1.7-jbossorg-1 (20120227-1401) for context ‘/database’
    16:46:49,330 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-4) Hibernate Validator 4.2.0.Final
    16:46:49,595 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Monitoring jndi:/default-host/database/WEB-INF/faces-config.xml for modifications
    16:46:49,596 INFO [org.jboss.web] (MSC service thread 1-4) JBAS018210: Registering web context: /database
    16:46:49,830 INFO [org.jboss.as.server] (DeploymentScanner-threads – 2) JBAS015870: Deploy of deployment “Database.ear” was rolled back with failure message {“JBAS014671: Failed services” => {“jboss.deployment.subunit.\”Database.ear\”.\”Ejbdatabase.jar\”.INSTALL” => “org.jboss.msc.service.StartException in service jboss.deployment.subunit.\”Database.ear\”.\”Ejbdatabase.jar\”.INSTALL: Failed to process phase INSTALL of subdeployment \”Ejbdatabase.jar\” of deployment \”Database.ear\”"},”JBAS014771: Services with missing/unavailable dependencies” => ["jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.ValidatorFactoryjboss.naming.context.java.comp.Database.Ejbdatabase.LoginDaoMissing[jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.ValidatorFactoryjboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao]“,”jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.Validatorjboss.naming.context.java.comp.Database.Ejbdatabase.LoginDaoMissing[jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.Validatorjboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao]“]}
    16:46:49,845 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment Jsfdatabase.war in 26ms
    16:46:49,861 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment Ejbdatabase.jar in 32ms
    16:46:49,861 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment Database.ear in 39ms
    16:46:49,861 INFO [org.jboss.as.controller] (DeploymentScanner-threads – 2) JBAS014774: Service status report
    JBAS014775: New missing/unsatisfied dependencies:
    service jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao (missing) dependents: [service jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.Validator, service jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.ValidatorFactory]
    JBAS014777: Services which failed to start: service jboss.deployment.subunit.”Database.ear”.”Ejbdatabase.jar”.INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit.”Database.ear”.”Ejbdatabase.jar”.INSTALL: Failed to process phase INSTALL of subdeployment “Ejbdatabase.jar” of deployment “Database.ear”

    16:46:49,877 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) {“JBAS014653: Composite operation failed and was rolled back. Steps that failed:” => {“Operation step-2″ => {“JBAS014671: Failed services” => {“jboss.deployment.subunit.\”Database.ear\”.\”Ejbdatabase.jar\”.INSTALL” => “org.jboss.msc.service.StartException in service jboss.deployment.subunit.\”Database.ear\”.\”Ejbdatabase.jar\”.INSTALL: Failed to process phase INSTALL of subdeployment \”Ejbdatabase.jar\” of deployment \”Database.ear\”"},”JBAS014771: Services with missing/unavailable dependencies” => ["jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.ValidatorFactoryjboss.naming.context.java.comp.Database.Ejbdatabase.LoginDaoMissing[jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.ValidatorFactoryjboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao]“,”jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.Validatorjboss.naming.context.java.comp.Database.Ejbdatabase.LoginDaoMissing[jboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao.Validatorjboss.naming.context.java.comp.Database.Ejbdatabase.LoginDao]“]}}}

    • http://theopentutorials.com Nithya Vasudevan

      You got this error

      Can’t find a persistence unit named EntityBean in subdeployment “Ejbdatabase.jar” of deployment “Database.ear”

      Make sure these are given correctly;
      1. “persistence.xml” file name correctly, it is case-sensitive.
      2. persistence unit name in java code where you have injected (session bean) (Section 9), it should match persistence-unit name in persistence.xml (Section 10)
      3. In datasource element, the jndi-name=”java:/MySQLDS” should match the java:/MySQLDS in persistence.xml (Section 11.4).

      • Javed Iqbal

        Hi,

        I also facing same problem but it has been solved by doing this…

        in xml file :

        ….

        com.mysql.jdbc.Driver
        com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

  • Jones Gold

    Hi Nithiya…thanks for the reply
    According to your advice i changed the persistence unit name in persistence .xml and also i checked the jndi-name=”java:/MySQLDS in datasource element and java:/MySQLDS in persistence.xml both are matching but now I am getting new below error
    Please help me to find out the error
    JBAS014775: New missing/unsatisfied dependencies:
    service jboss.jdbc-driver.mysqlDriver (missing) dependents: [service jboss.data-source.java:/MySQLDS]

    10:52:28,359 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
    10:52:28,359 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.1.Final “Brontes” started (with errors) in 13468ms – Started 134 of 212 services (2 services failed or missing dependencies, 74 services are passive or on-demand)
    10:53:52,325 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) JBAS015003: Found Database.ear in deployment directory. To trigger deployment create a file called Database.ear.dodeploy
    10:53:52,326 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of “Database.ear”
    10:53:52,404 WARN [org.jboss.metadata.parser.jboss.JBossAppMetaDataParser] (MSC service thread 1-3) loader-repository element in jboss-app.xml is deprecated and has been ignored
    10:53:52,482 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of “Ejbdatabase.jar”
    10:53:52,482 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of “Jsfdatabase.war”
    10:53:52,701 INFO [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011401: Read persistence.xml for EntityBean
    10:53:52,904 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named LoginDao in deployment unit subdeployment “Ejbdatabase.jar” of deployment “Database.ear” are as follows:

    java:global/Database/Ejbdatabase/LoginDao!dao.LoginDaoRemote
    java:app/Ejbdatabase/LoginDao!dao.LoginDaoRemote
    java:module/LoginDao!dao.LoginDaoRemote
    java:jboss/exported/Database/Ejbdatabase/LoginDao!dao.LoginDaoRemote
    java:global/Database/Ejbdatabase/LoginDao
    java:app/Ejbdatabase/LoginDao
    java:module/LoginDao

    10:53:53,730 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-3) Initializing Mojarra 2.1.7-jbossorg-1 (20120227-1401) for context ‘/database’
    10:53:54,511 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-3) Hibernate Validator 4.2.0.Final
    10:53:54,886 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-3) Monitoring jndi:/default-host/database/WEB-INF/faces-config.xml for modifications
    10:53:54,980 INFO [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /database
    10:53:55,199 INFO [org.jboss.as.server] (DeploymentScanner-threads – 2) JBAS015870: Deploy of deployment “Database.ear” was rolled back with failure message JBAS014750: Operation handler failed to complete
    10:53:55,214 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment Jsfdatabase.war in 21ms
    10:53:55,214 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment Ejbdatabase.jar in 21ms
    10:53:55,214 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment Database.ear in 23ms
    10:53:55,214 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) {“JBAS014653: Composite operation failed and was rolled back. Steps that failed:” => {“Operation step-2″ => “JBAS014750: Operation handler failed to complete”}}

    And my big doubt is that when i restart my server it showing below msg

    New missing/unsatisfied dependencies:
    service jboss.jdbc-driver.mysqlDriver (missing) dependents: [service jboss.data-source.java:/MySQLDS]

    Is there any problem in Configuring of MySQL Datasource in JBoss AS 7?

    • http://theopentutorials.com Nithya Vasudevan

      This tutorial assumes you use server standalone.xml config file. Also check whether you have correctly followed the steps 10 and 11.

      • Jones Gold

        Hi Nithiya mam…………Thank u very much…….Actually in module.xml i given the resource-root path wrongly now i am correct that… now application working fine…

        Thanks lot

  • zahra

    dear nithiya, i tried your example and when trying to run the client application i get this exception. Do you have any solution for this?
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.addToEnvironment(Unknown Source)
    at zahra.clientutility.JNDILookupClass.getInitialContext(JNDILookupClass.java:21)
    at zahra.client.EJBApplicationClient.doLookup(EJBApplicationClient.java:50)
    at zahra.client.EJBApplicationClient.main(EJBApplicationClient.java:15)
    Exception in thread “main” java.lang.NullPointerException
    at zahra.client.EJBApplicationClient.main(EJBApplicationClient.java:29)

  • Amlan Anupam

    Hi Nithiya Mam,
    Thank you very much for this wonderful tutorial. I followed the steps specified and I am successfully able to deploy my jpa project. But while executing the client application I am getting the following error. Please help to resolve it.

    18:15:46,742 ERROR [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting “wxin80001533d” task-3) Exception on channel Channel ID 2735e358 (inbound) of Remoting connection 00b9b1fe to /127.0.0.1:2142 from message org.jboss.remoting3.remote.InboundMessage$3@9e666f: java.io.EOFException: Read past end of file
    at org.jboss.marshalling.SimpleDataInput.eofOnRead(SimpleDataInput.java:126) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
    at org.jboss.marshalling.SimpleDataInput.readUnsignedByteDirect(SimpleDataInput.java:263) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
    at org.jboss.marshalling.SimpleDataInput.readUnsignedByte(SimpleDataInput.java:224) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
    at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
    at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.processMessage(MethodInvocationMessageHandler.java:156)
    at org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver.handleMessage(VersionOneProtocolChannelReceiver.java:170)
    at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:437) [jboss-remoting-3.2.3.GA.jar:3.2.3.GA]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_31]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]

  • Devang

    I have created project as you explain, during execution it gives the following error
    Can you please guide me?

    Feb 22, 2013 1:08:20 PM org.jboss.ejb.client.EJBClient
    INFO: JBoss EJB Client version 1.0.5.Final
    Feb 22, 2013 1:08:20 PM org.xnio.Xnio
    INFO: XNIO Version 3.0.3.GA
    Feb 22, 2013 1:08:20 PM org.xnio.nio.NioXnio
    INFO: XNIO NIO Implementation Version 3.0.3.GA
    Feb 22, 2013 1:08:20 PM org.jboss.remoting3.EndpointImpl
    INFO: JBoss Remoting version 3.2.3.GA
    Feb 22, 2013 1:08:25 PM org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceivers
    WARN: Could not register a EJB receiver for connection to remote://localhost:4447
    java.lang.RuntimeException: Operation failed with status WAITING
    at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:93)
    at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:121)
    at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.(ConfigBasedEJBClientContextSelector.java:78)
    at org.jboss.ejb.client.EJBClientContext.(EJBClientContext.java:77)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:120)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    at $Proxy0.saveProject(Unknown Source)
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:29)
    Exception in thread “main” java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:FirstJPAEJBProject,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@147c5fc
    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
    at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    at $Proxy0.saveProject(Unknown Source)
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:29)

  • http://www.constantinescu.us Cosmin Constantinescu

    @Devang: Are u sure u named also the project “FirstJPAEJBProject”, like u specified in module name ?
    I got the same problem and this was my fix

  • Nilanka

    Mar 7, 2013 12:28:53 PM org.jboss.ejb.client.EJBClient
    INFO: JBoss EJB Client version 1.0.5.Final
    Mar 7, 2013 12:28:53 PM org.xnio.Xnio
    INFO: XNIO Version 3.0.3.GA
    Mar 7, 2013 12:28:53 PM org.xnio.nio.NioXnio
    INFO: XNIO NIO Implementation Version 3.0.3.GA
    Mar 7, 2013 12:28:53 PM org.jboss.remoting3.EndpointImpl
    INFO: JBoss Remoting version 3.2.3.GA
    Mar 7, 2013 12:28:54 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
    INFO: Received server version 1 and marshalling strategies [river]
    Mar 7, 2013 12:28:54 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
    INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@9446e4, receiver=Remoting connection EJB receiver [connection=Remoting connection ,channel=jboss.ejb,nodename=laptop]} on channel Channel ID dc2db15c (outbound) of Remoting connection 00b60b93 to localhost/127.0.0.1:4447
    Mar 7, 2013 12:28:54 PM org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleMessage
    WARN: Unsupported message received with header 0xffffffff

    what can i do?

  • Bob

    Exception in thread “main” java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:FirstJPAProject,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@1d20cb10
    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
    at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    at $Proxy0.saveProject(Unknown Source)
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:30)

    • Mhartyn

      You solve the problem?

  • Peemot

    Thank you so much for this tutorial, you are a lifesaver! :)

  • dhanayan

    hey nithya thanks for the tutorial …….,
    while i run the code in server it deployed successfully as”Deplyoed FirstJPAProject.jar”.

    While running thr client program i get the following error..can you pls help me

    Exception in thread “main” java.lang.NoSuchMethodError: org.jboss.remoting3.Channel.getOption(Lorg/xnio/Option;)Ljava/lang/Object;
    at org.jboss.ejb.client.remoting.ChannelAssociation.(ChannelAssociation.java:115)
    at org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver.associate(RemotingConnectionEJBReceiver.java:157)
    at org.jboss.ejb.client.EJBClientContext.registerEJBReceiver(EJBClientContext.java:295)
    at org.jboss.ejb.client.EJBClientContext.registerEJBReceiver(EJBClientContext.java:250)
    at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:125)
    at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.(ConfigBasedEJBClientContextSelector.java:77)
    at org.jboss.ejb.client.EJBClientContext.(EJBClientContext.java:76)
    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.saveProject(Unknown Source)
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:30)

    thanks in advance…!

  • Nagendra

    When Iam trying to run this iam getting following exception
    And i used JDK1.7 and Eclipse JUNO for this project is this lead to any problem??? please reply……

    20:46:54,395 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA
    20:46:55,692 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
    20:46:55,838 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final “Brontes” starting
    20:46:59,413 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
    20:46:59,422 INFO [org.xnio] XNIO Version 3.0.3.GA
    20:46:59,474 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
    20:46:59,557 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
    20:46:59,768 INFO [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem
    20:46:59,783 INFO [org.jboss.as.webservices] JBAS015537: Activating WebServices Extension
    20:46:59,846 INFO [org.jboss.as.security] JBAS013101: Activating Security Subsystem
    20:46:59,854 INFO [org.jboss.as.osgi] JBAS011940: Activating OSGi Subsystem
    20:46:59,861 INFO [org.jboss.as.naming] JBAS011800: Activating Naming Subsystem
    20:46:59,886 INFO [org.jboss.as.clustering.infinispan] JBAS010280: Activating Infinispan subsystem.
    20:47:00,149 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
    20:47:01,768 INFO [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
    20:47:02,138 INFO [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session
    20:47:02,207 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services – Stack CXF Server 4.0.2.GA
    20:47:02,518 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-8080
    20:47:02,854 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory D:jboss-as-7.1.1.Finalstandalonedeployments
    20:47:02,867 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) JBAS015014: Re-attempting failed deployment EJB-JPA.jar
    20:47:02,881 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) JBAS015003: Found EJB-JPA.jar in deployment directory. To trigger deployment create a file called EJB-JPA.jar.dodeploy
    20:47:03,096 INFO [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on localhost/127.0.0.1:4447
    20:47:03,165 INFO [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:9999
    20:47:03,317 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source
    20:47:03,581 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
    JBAS014775: New missing/unsatisfied dependencies:
    service jboss.jdbc-driver.mysqlDriver (missing) dependents: [service jboss.data-source.java:/MySQLDS]

    20:47:03,618 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of “EJB-JPA.jar”
    20:47:03,996 INFO [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011401: Read persistence.xml for JPADB
    20:47:04,110 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named CustomerServiceImpl in deployment unit deployment “EJB-JPA.jar” are as follows:

    java:global/EJB-JPA/CustomerServiceImpl!com.ejb.service.CustomerService
    java:app/EJB-JPA/CustomerServiceImpl!com.ejb.service.CustomerService
    java:module/CustomerServiceImpl!com.ejb.service.CustomerService
    java:jboss/exported/EJB-JPA/CustomerServiceImpl!com.ejb.service.CustomerService
    java:global/EJB-JPA/CustomerServiceImpl
    java:app/EJB-JPA/CustomerServiceImpl
    java:module/CustomerServiceImpl

    20:47:04,478 INFO [org.jboss.as] (MSC service thread 1-1) JBAS015951: Admin console listening on http://127.0.0.1:9990
    20:47:04,480 ERROR [org.jboss.as] (MSC service thread 1-1) JBAS015875: JBoss AS 7.1.1.Final “Brontes” started (with errors) in 11585ms – Started 171 of 255 services (6 services failed or missing dependencies, 76 services are passive or on-demand)
    20:47:04,967 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment EJB-JPA.jar in 32ms
    20:47:04,970 INFO [org.jboss.as.server] (DeploymentScanner-threads – 2) JBAS015870: Deploy of deployment “EJB-JPA.jar” was rolled back with failure message JBAS014750: Operation handler failed to complete
    20:47:04,974 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) {“JBAS014653: Composite operation failed and was rolled back. Steps that failed:” => {“Operation step-2″ => “JBAS014750: Operation handler failed to complete”}}

  • cesar

    excelente

  • Chamila

    THANKS YOU Nithya for posting this. I had really hard time finding a good tutorial on EJB 3 JPA and this was the IDEAL type of tutorial I was looking for. :D

  • Alex

    I’ve got the same error. Can you explain what is wrong?

  • manoj

    hi nithya mam…i followed all steps but when i run the EJBApplicationClient.java i getting the error….
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at com.manoj.client.EJBApplicationClient.doLookup(EJBApplicationClient.java:39)
    at com.manoj.client.EJBApplicationClient.main(EJBApplicationClient.java:14)
    Exception in thread “main” java.lang.NullPointerException
    at com.manoj.client.EJBApplicationClient.main(EJBApplicationClient.java:23)

    can you plz tell were the problem ,
    thanks,

  • manoj

    hi…mam after a small correction in JNDILookupClass.java..
    i getting this errors…..
    Sep 4, 2013 11:20:31 PM org.jboss.ejb.client.EJBClient
    INFO: JBoss EJB Client version 1.0.5.Final
    Sep 4, 2013 11:20:31 PM org.xnio.Xnio
    INFO: XNIO Version 3.0.3.GA
    Sep 4, 2013 11:20:31 PM org.xnio.nio.NioXnio
    INFO: XNIO NIO Implementation Version 3.0.3.GA
    Sep 4, 2013 11:20:31 PM org.jboss.remoting3.EndpointImpl
    INFO: JBoss Remoting version 3.2.3.GA
    Sep 4, 2013 11:20:36 PM org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceivers
    WARN: Could not register a EJB receiver for connection to remote://localhost:4447
    java.lang.RuntimeException: Operation failed with status WAITING
    at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:93)
    at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:121)
    at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.(ConfigBasedEJBClientContextSelector.java:78)
    at org.jboss.ejb.client.EJBClientContext.(EJBClientContext.java:77)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:120)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    at $Proxy0.saveProject(Unknown Source)
    at com.manoj.client.EJBApplicationClient.main(EJBApplicationClient.java:23)
    Exception in thread “main” java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:SecondJPAProject,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@192b996
    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
    at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    at $Proxy0.saveProject(Unknown Source)
    at com.manoj.client.EJBApplicationClient.main(EJBApplicationClient.java:23)
    can plz help me to fix this
    thanx.

  • Kumar Gaurav

    Sir I face the problem below:

    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at com.ibytecode.client.EJBApplicationClient.doLookup(EJBApplicationClient.java:55)
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:16)
    Exception in thread “main” java.lang.NullPointerException
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:30)

    • Lambros

      Try this:

      final Properties properties= new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
      properties.put(Context.PROVIDER_URL, “remote://localhost:4447″);
      initialContext = new InitialContext(properties);

      (Src: https://docs.jboss.org/author/display/AS71/JNDI+Reference)

  • balaji

    hi nitya..
    thanks for the tutorial. it is much helpful.. now i want to use oracle database instead of Mysql.. i’m new to JPA .. can you please guide me.. thanks in advance.

  • gaiapuffo22

    Hi,I have a problem with this example, use jboss 7.1 and oracle and do not know why I get the following error, if you can contact me because I have really covered everything and I can not find the error, I can send the project via email and my standalone jboss, I need a hand

    email [email protected] contact me if I send him the project

  • Victor Elliott

    Definitle i love you Praveen Macherla, jeje, EJB is easy in the way that u explain!! tks

  • Klaus Causemann

    Hi,

    Running the EJBApplicationClient, I receive the error message:

    “No EJB receiver available for handling [appName:,modulename:,distinctname:FirstJPAProject] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@ebe9f73″

    The modulename is interpreted as distinctname, although I used the method getLookupName ?
    Please give me a hint, what could be the problem. Thanks in advance.

    • ism

      hi,i have the same problem

      • Michele Mori

        Hi! I have the same problem, any idea?

  • Mhartyn

    Please fellows Help I dont know what the hell is wrong I revised everything 100 times…..

    My String is this: ejb:/FirstJPAProject//ProjectBean!com.ibytecode.business.IProject

    I get this error in: bean.saveProject(p1);

    jun 25, 2014 12:35:18 AM org.jboss.ejb.client.EJBClient

    INFO: JBoss EJB Client version 1.0.0.Beta10

    Exception in thread “main” java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:FirstJPAProject,distinctname:] combination

    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:344)

    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:92)

    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:83)

    at com.sun.proxy.$Proxy0.saveProject(Unknown Source)

    at com.ibytecode.client.EJBAplicationClient.main(EJBAplicationClient.java:30)

  • Ganga prasad Pandaraboina

    21:49:26,179 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA

    21:49:26,472 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA

    21:49:26,546 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final “Brontes” starting

    21:49:27,756 INFO [org.xnio] XNIO Version 3.0.3.GA

    21:49:27,756 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)

    21:49:27,768 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA

    21:49:27,779 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA

    21:49:27,818 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers

    21:49:27,824 INFO [org.jboss.as.configadmin] (ServerService Thread Pool — 26) JBAS016200: Activating ConfigAdmin Subsystem

    21:49:27,829 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool — 31) JBAS010280: Activating Infinispan subsystem.

    21:49:27,863 INFO [org.jboss.as.osgi] (ServerService Thread Pool — 39) JBAS011940: Activating OSGi Subsystem

    21:49:27,871 INFO [org.jboss.as.security] (ServerService Thread Pool — 44) JBAS013101: Activating Security Subsystem

    21:49:27,882 INFO [org.jboss.as.webservices] (ServerService Thread Pool — 48) JBAS015537: Activating WebServices Extension

    21:49:27,901 INFO [org.jboss.as.naming] (ServerService Thread Pool — 38) JBAS011800: Activating Naming Subsystem

    21:49:27,908 INFO [org.jboss.as.connector] (MSC service thread 1-7) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)

    21:49:27,918 INFO [org.jboss.as.security] (MSC service thread 1-6) JBAS013100: Current PicketBox version=4.0.7.Final

    21:49:28,119 INFO [org.jboss.as.naming] (MSC service thread 1-6) JBAS011802: Starting Naming Service

    21:49:28,171 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool — 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)

    21:49:28,175 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session

    21:49:28,393 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-7) JBoss Web Services – Stack CXF Server 4.0.2.GA

    21:49:28,770 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of “ojdbc6.jar”

    21:49:28,776 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-7) JBAS015012: Started FileSystemDeploymentService for directory E:jboss-as-7.1.1.Finaljboss-as-7.1.1.Finalstandalonedeployments

    21:49:28,786 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads – 1) JBAS015003: Found JPAProject.jar in deployment directory. To trigger deployment create a file called JPAProject.jar.dodeploy

    21:49:28,897 INFO [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on /127.0.0.1:9999

    21:49:28,897 INFO [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on localhost/127.0.0.1:4447

    21:49:28,931 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-7) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-9080

    21:49:29,158 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source

    21:49:29,512 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)

    21:49:29,534 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source

    21:49:29,580 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed “ojdbc6.jar”

    21:49:29,598 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of “JPAProject.jar”

    21:49:29,637 INFO [org.jboss.as.jpa] (MSC service thread 1-7) JBAS011401: Read persistence.xml for OracleDS

    21:49:29,710 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-5) JNDI bindings for session bean named ProjectBean in deployment unit deployment “JPAProject.jar” are as follows:

    java:global/JPAProject/ProjectBean!com.ibytecode.business.IProject

    java:app/JPAProject/ProjectBean!com.ibytecode.business.IProject

    java:module/ProjectBean!com.ibytecode.business.IProject

    java:jboss/exported/JPAProject/ProjectBean!com.ibytecode.business.IProject

    java:global/JPAProject/ProjectBean

    java:app/JPAProject/ProjectBean

    java:module/ProjectBean

    21:49:29,834 INFO [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011402: Starting Persistence Unit Service ‘JPAProject.jar#OracleDS’

    21:49:29,981 INFO [org.hibernate.annotations.common.Version] (MSC service thread 1-3) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}

    21:49:29,991 INFO [org.hibernate.Version] (MSC service thread 1-3) HHH000412: Hibernate Core {4.0.1.Final}

    21:49:29,994 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-3) HHH000206: hibernate.properties not found

    21:49:29,998 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-3) HHH000021: Bytecode provider name : javassist

    21:49:30,030 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-3) HHH000204: Processing PersistenceUnitInfo [

    name: OracleDS

    ...]

    21:49:30,267 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-3) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider

    21:49:30,533 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (MSC service thread 1-3) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: Could not create connection

    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:277)

    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:235)

    at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:761)

    at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:343)

    at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:397)

    at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:365)

    at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:329)

    at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:302)

    at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:464)

    at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129)

    at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:67) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:253) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:119) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_39]

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_39]

    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_39]

    Caused by: java.sql.SQLException: READ_COMMITTED and SERIALIZABLE are the only valid transaction levels

    at oracle.jdbc.driver.PhysicalConnection.setTransactionIsolation(PhysicalConnection.java:4638)

    at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.(BaseWrapperManagedConnection.java:194)

    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnection.(LocalManagedConnection.java:61)

    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:262)

    … 30 more

    21:49:30,565 WARN [org.hibernate.engine.jdbc.internal.JdbcServicesImpl] (MSC service thread 1-3) HHH000342: Could not obtain connection to query metadata : javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/OracleDS

    21:49:30,574 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-3) HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect

    21:49:30,582 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-3) HHH000422: Disabling contextual LOB creation as connection was null

    21:49:30,591 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-3) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory

    21:49:30,597 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-3) HHH000397: Using ASTQueryTranslatorFactory

    21:49:30,658 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-3) Hibernate Validator 4.2.0.Final

    21:49:31,315 INFO [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990

    21:49:31,319 INFO [org.jboss.as] (MSC service thread 1-2) JBAS015874: JBoss AS 7.1.1.Final “Brontes” started in 5524ms – Started 200 of 280 services (78 services are passive or on-demand)

    21:49:31,512 INFO [org.jboss.as.server] (DeploymentScanner-threads – 2) JBAS018559: Deployed “JPAProject.jar”

  • Tran Duy Khiem

    Thanks so much! You are very pro! I do it succecced!