Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

javax.ejb.EJBException

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am facing problem when I try to insert the record by using entity been. I am getting an error at the place “manager.persist(cust);” in EmployeeBean class.

I tried to fix this problem for three days but I am not able to fix. Can any one to help me to fix this problem please

[code] Error Stack is this

[#|2010-01-28T21:29:13.000-0600|INFO|sun-appserver9.1|oracle.toplink.essentials.session.file:/C:/glassfish/domains/domain1/applications/j2ee-apps/MiniProject/MiniProjectEJB_jar/-PATPersistence|_ThreadID=16;_ThreadName=p: thread-pool-1; w: 5;|TopLink, version: Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))|#]

[#|2010-01-28T21:29:13.031-0600|INFO|sun-appserver9.1|oracle.toplink.essentials.session.file:/C:/glassfish/domains/domain1/applications/j2ee-apps/MiniProject/MiniProjectEJB_jar/-PATPersistence|_ThreadID=16;_ThreadName=p: thread-pool-1; w: 5;|Server: unknown|#]

[#|2010-01-28T21:29:22.468-0600|INFO|sun-appserver9.1|oracle.toplink.essentials.session.file:/C:/glassfish/domains/domain1/applications/j2ee-apps/MiniProject/MiniProjectEJB_jar/-PATPersistence|_ThreadID=16;_ThreadName=p: thread-pool-1; w: 5;|file:/C:/glassfish/domains/domain1/applications/j2ee-apps/MiniProject/MiniProjectEJB_jar/-PATPersistence login successful|#]

[#|2010-01-28T21:29:22.828-0600|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=16;_ThreadName=p: thread-pool-1; w: 5;EmployeeBean;|EJB5018: An exception was thrown during an ejb invocation on [EmployeeBean]|#]

[#|2010-01-28T21:29:22.828-0600|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=16;_ThreadName=p: thread-pool-1; w: 5;|
javax.ejb.EJBException
at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3869)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3769)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:210)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
at $Proxy32.doAction(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
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)
Caused by: java.lang.IllegalArgumentException: Object: SampleEntity.Customer@115441f is not a known entity type.
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:3212)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:205)
at com.sun.enterprise.util.EntityManagerWrapper.persist(EntityManagerWrapper.java:440)
at SampleEntity.EmployeeBean.doAction(EmployeeBean.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
... 17 more
|#]


[/code]

[code] @Entity
@Table(name = "CUSTOMER_TABLE")
public class Customer implements java.io.Serializable {
private int id;
private String lastName;
private String firstName;
private Date timeCreated = new Date();

@Id
@Column(name = "CUST_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)

public int getId() {
return id;
}

public void setId(int pk) {
id = pk;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}


public Date getTimeCreated() {
return timeCreated;
}

public void setTimeCreated(Date time) {
timeCreated = time;
}

}

[/code]

[code] @Stateless

public class EmployeeBean implements EmployeeServiceRemote {

@PersistenceContext(unitName="PATPersistence")
private EntityManager manager;

public EmployeeBean()
{
}

@TransactionAttribute(TransactionAttributeType.REQUIRED)

public void doAction()
{
Customer cust = new Customer();

cust.setFirstName("Joe");
manager.persist(cust);

System.out.println("Saved");

cust = manager.find(Customer.class,cust.getId());

System.out.println(cust.getFirstName());

}

}

[/code]

[code] @Remote
public interface EmployeeServiceRemote {
public void doAction();
}

[/code]

[code] public class Main {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

EmployeeServiceRemote service = null;

try{
service = (EmployeeServiceRemote) new InitialContext().lookup("SampleEntity.EmployeeServiceRemote");
service.doAction();
}catch (Exception e) {
System.out.println(e.getStackTrace());
}


}

}
[/code]
 
Vish Murthy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I missed to past persistence.xml

[code] <?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name ="PATPersistence">
<jta-data-source>jdbc/PATDataSource</jta-data-source>
</persistence-unit>
</persistence>
[/code]
 
Vish Murthy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one respond to my question please
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Caused by: java.lang.IllegalArgumentException: Object: SampleEntity.Customer@115441f is not a known entity type.



You have to declare your persistent classes in the persistent.xml like below:

<class>com.xxx.yyy.Employee</class>

Thanks,
Ramana.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic