Java EE 5
ejb 3.0
Glassfish v2.1
eclipse
Hello guys, I started to learn Java Enterprise Beans. At the beginning, I decided to create a (stateful) Bean, which can add a new user into a simple table. The table is realize by an entity bean, which I created with the help of Eclipse and JPA. Via Eclipse I integrated one table from an existing postgresql database. While Eclipse was generating entity beans, a wizard required some informations about the database. I committed the following informations:
Database, mytestdb
URL, jbdc
ostgresql:mytestdb
Username, my name
password, 123456
I apply the following jdbc driver: postgresql-8.3-605.jdbc2ee.jar
a short connection test answers o.k
Before Eclipse generated resources, I was creating the persistence.xml file in a very simple way.
When Eclipse JPA-Wizard was finished, the requested resources were being build. The persistence.xml was being included the class tags of the entity beans.
Now, please take a quick look at the ejb, jndi-connection
Here you see the remote interface (RemoteInterface2.java) for the ejb:
entity bean:
After Eclipse deployed, I injected my ejb application (E.jar) into Glassfish V2.1.
I was tried to apply my ejb through a client application. (C.jar)
here you see the the main – methode of the client-app,
If I execute the main class, the getTest methods doing right but the setCustomer methode generats a lot of exceptions. Remember, the setCustomer methode accesses on entity beans.
Here you see the Exceptions:
Maybe persistence.xml provoks this Exceptions because the xml file is probably not correctly create but i'm not sure. I was only followed an tutorial about ejb. Probably I have unconsidered an important step. I'm very thankful when someone will helps me.
ejb 3.0
Glassfish v2.1
eclipse
Hello guys, I started to learn Java Enterprise Beans. At the beginning, I decided to create a (stateful) Bean, which can add a new user into a simple table. The table is realize by an entity bean, which I created with the help of Eclipse and JPA. Via Eclipse I integrated one table from an existing postgresql database. While Eclipse was generating entity beans, a wizard required some informations about the database. I committed the following informations:
Database, mytestdb
URL, jbdc

Username, my name
password, 123456
I apply the following jdbc driver: postgresql-8.3-605.jdbc2ee.jar
a short connection test answers o.k
Before Eclipse generated resources, I was creating the persistence.xml file in a very simple way.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_1_0.xsd"
version="1.0">
<persistence-unit name="Test">
</persistence-unit>
</persistence>
When Eclipse JPA-Wizard was finished, the requested resources were being build. The persistence.xml was being included the class tags of the entity beans.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_1_0.xsd"
version="1.0">
<persistence-unit name="Test">
<class>org.ejb.entity.Customer</class>
<class>org.ejb.entity.Order</class>
<class>org.ejb.entity.OrderPK</class>
</persistence-unit>
</persistence>
Now, please take a quick look at the ejb, jndi-connection
Here you see the remote interface (RemoteInterface2.java) for the ejb:
Code:
package org.ejb.stateful;
import javax.ejb.Remote;
@Remote
public interface RemoteInterface2 {
public String getTest();
public String getTest2();
public void setTest(String Eingabe);
}
the belonging stateful enterprise bean:
package org.ejb.stateful;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import org.ejb.entity.Customer;
@Stateful
public class Bean implements RemoteInterface2 {
private EntityManagerFactory emf;
private EntityManager manager;
private EntityTransaction tx;
public String getTest() {
// TODO Auto-generated method stub
return "Hello Wolrd";
}
public String getTest2(){
return "Hello World, again";
}
public void setCustomer() {
this.emf = Persistence.createEntityManagerFactory("Test");
this.manager= emf.createEntityManager();
this.tx=manager.getTransaction();
this.tx.begin();
Customer c = new Customer();
c.setVorname("dummy");
c.setTelefon("002330324");
c.setEmail("dummymailaddress");
manager.persist(c);
this.tx.commit();
this.manager.close();
}
}
entity bean:
Code:
package org.ejb.entity;
import java.io.Serializable;
import javax.persistence.*;
import java.util.Set;
/**
* The persistent class for the customer database table.
*
*/
@Entity
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer cid;
private Boolean anrede;
private String email;
private String name;
private String telefon;
private String vorname;
//bi-directional many-to-one association to Order
@OneToMany(mappedBy="customer")
private Set<Order> orders;
public Customer() {
}
public Integer getCid() {
return this.cid;
}
public void setCid(Integer cid) {
this.cid = cid;
}
public Boolean getAnrede() {
return this.anrede;
}
public void setAnrede(Boolean anrede) {
this.anrede = anrede;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getTelefon() {
return this.telefon;
}
public void setTelefon(String telefon) {
this.telefon = telefon;
}
public String getVorname() {
return this.vorname;
}
public void setVorname(String vorname) {
this.vorname = vorname;
}
public Set<Order> getOrders() {
return this.orders;
}
public void setOrders(Set<Order> orders) {
this.orders = orders;
}
}
After Eclipse deployed, I injected my ejb application (E.jar) into Glassfish V2.1.
I was tried to apply my ejb through a client application. (C.jar)
here you see the the main – methode of the client-app,
Code:
import javax.ejb.EJB;
import javax.rmi.PortableRemoteObject;
import org.ejb.stateful.RemoteInterface2;
public class Main {
@EJB
private static RemoteInterface2 b;
public static void main(String[] args){
StandardContex();
}
public static void StandardContex(){
try{
InitialContext context = new InitialContext();
b= (RemoteInterface2)context.lookup(RemoteInterface2.class.getName());
System.out.println("thats okay "+context.lookup(RemoteInterface2.class.getName()));
System.out.println(b.getTest());
b.setCustomer();
context.close();
}catch (NamingException e){
}
}
}
If I execute the main class, the getTest methods doing right but the setCustomer methode generats a lot of exceptions. Remember, the setCustomer methode accesses on entity beans.
Here you see the Exceptions:
Code:
Exception in thread "main" javax.ejb.EJBException: nested exception is: java.rmi.RemoteException: CORBA BAD_OPERATION 1398079720 No; nested exception is:
org.omg.CORBA.BAD_OPERATION: ----------BEGIN server-side stack trace----------
org.omg.CORBA.BAD_OPERATION: vmcid: SUN minor code: 232 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.methodNotFoundInTie(ORBUtilSystemException.java:699)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.methodNotFoundInTie(ORBUtilSystemException.java:723)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:147)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
----------END server-side stack trace---------- vmcid: SUN minor code: 232 completed: No
java.rmi.RemoteException: CORBA BAD_OPERATION 1398079720 No; nested exception is:
org.omg.CORBA.BAD_OPERATION: ----------BEGIN server-side stack trace----------
org.omg.CORBA.BAD_OPERATION: vmcid: SUN minor code: 232 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.methodNotFoundInTie(ORBUtilSystemException.java:699)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.methodNotFoundInTie(ORBUtilSystemException.java:723)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:147)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
----------END server-side stack trace---------- vmcid: SUN minor code: 232 completed: No
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:364)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:205)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
at org.ejb.stateful.__RemoteInterface2_Remote_DynamicStub.setCustomer(org/ejb/stateful/__RemoteInterface2_Remote_DynamicStub.java)
at org.ejb.stateful._RemoteInterface2_Wrapper.setCustomer(org/ejb/stateful/_RemoteInterface2_Wrapper.java)
at Main.StandardContex(Main.java:48)
at Main.main(Main.java:32)
Caused by: org.omg.CORBA.BAD_OPERATION: ----------BEGIN server-side stack trace----------
org.omg.CORBA.BAD_OPERATION: vmcid: SUN minor code: 232 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.methodNotFoundInTie(ORBUtilSystemException.java:699)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.methodNotFoundInTie(ORBUtilSystemException.java:723)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:147)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
----------END server-side stack trace---------- vmcid: SUN minor code: 232 completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.MessageBase.getSystemException(MessageBase.java:913)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(ReplyMessage_1_2.java:131)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(CorbaMessageMediatorImpl.java:685)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:472)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:363)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:219)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:192)
... 6 more
javax.ejb.EJBException: nested exception is: java.rmi.RemoteException: CORBA BAD_OPERATION 1398079720 No; nested exception is:
org.omg.CORBA.BAD_OPERATION: ----------BEGIN server-side stack trace----------
org.omg.CORBA.BAD_OPERATION: vmcid: SUN minor code: 232 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.methodNotFoundInTie(ORBUtilSystemException.java:699)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.methodNotFoundInTie(ORBUtilSystemException.java:723)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:147)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
----------END server-side stack trace---------- vmcid: SUN minor code: 232 completed: No
at org.ejb.stateful._RemoteInterface2_Wrapper.setCustomer(org/ejb/stateful/_RemoteInterface2_Wrapper.java)
at Main.StandardContex(Main.java:48)
at Main.main(Main.java:32)
Maybe persistence.xml provoks this Exceptions because the xml file is probably not correctly create but i'm not sure. I was only followed an tutorial about ejb. Probably I have unconsidered an important step. I'm very thankful when someone will helps me.