File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes java.lang.reflect.UndeclaredThrowableException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "java.lang.reflect.UndeclaredThrowableException" Watch "java.lang.reflect.UndeclaredThrowableException" New topic


ramand singh

Joined: Jul 05, 2011
Posts: 2
Hi I am getting a problem Using EJB 3.0 with JBoss5.1.

I got error

at $Proxy2.addItem(Unknown Source)
at client.Test.main(
Caused by: org.jboss.remoting.InvocationFailureException: Unable to perform invocation; nested exception is: box.Employeer

If I am using String object instead of Employee object then code work fine. But using employee object giving me errors.

Please help me

Here is my code


package box;
import java.util.List;

import javax.ejb.Remote;

public interface NameRemote {
public void addItem(Employee emp);
public List<Employee> getItems();


import java.util.ArrayList;
import java.util.List;

import javax.ejb.Stateful;
import javax.ejb.Stateless;

* Session Bean implementation class Name
@Stateful(mappedName = "helloBean")
public class NameBean implements NameRemote {

List<Employee> empList= new ArrayList<Employee>();
public void addItem(Employee emp) {


public List<Employee> getItems() {

return empList;


Employee class:

package box;

public class Employee {
private String firstName;
private String lastName;
private String compName;
private double salary;

public Employee() {
firstName="Enter fn";
lastName="Enter ln";
compName= "Enter cn";
public Employee(String fn,String ln,String cn,double salary){

public String getFirstName() {
return firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;
public void setLastName(String lastName) {
this.lastName = lastName;
public String getCompName() {
return compName;
public void setCompName(String compName) {
this.compName = compName;
public double getSalary() {
return salary;
public void setSalary(double salary) {
this.salary = salary;
public String toString(){
return firstName+ " "+lastName+ " "+compName+ " "+ salary;


Main Class::

package client;

import java.util.Scanner;

import javax.naming.InitialContext;

import box.Employee;
import box.NameRemote;

public class Test {

private static Scanner scn= new Scanner(;
public static void main(String[] args) {
String fn=;
String ln=;
String cn=;
double salary= Double.parseDouble(;
Employee emp= new Employee(fn, ln, cn, salary);

try {
InitialContext ctx= new InitialContext();
NameRemote obj= (NameRemote) ctx.lookup("helloBean");



} catch (Exception e) {
// TODO Auto-generated catch block



Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
What happens if the Employee class implements the Serializable interface ?

What makes me wonder, too, is the error message part "box.Employeer ": Nowhere in your code the word "Employeer" occurs!

SCJP 5 (98%) - SCBCD 5 (98%)
ramand singh

Joined: Jul 05, 2011
Posts: 2

It works... Why we need serilizable Interface in Employee class??
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
Why we need serilizable Interface in Employee class??

The underlying rmi protocoll requires that all objects that are invoked remotely have to be serializable.
I agree. Here's the link:
subject: java.lang.reflect.UndeclaredThrowableException
It's not a secret anymore!