Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

NoSuchObjectLocalException Error

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating an entity bean using CMP 1.1 as Jrun's CMP2.0 doesnot integrate with existing tables. I have two finder methods for the bean, findByPrimaryKey and findbyCustomerId. I am having a problem gettin the findbyCustomerId which is returning a collection of objects. I am making use of local EJB objects.

Home Interface:

public interface CustomerHome extends javax.ejb.EJBLocalHome{

public Customer findByPrimaryKey(CustomerKey key) throws javax.ejb.FinderException;

public Collection findByCustomerId(int key) throws javax.ejb.FinderException;
}

Local Interface:

public interface Customer extends javax.ejb.EJBLocalObject{
public int getCustomerId();
public int getCustIncome();
public int getAddress();
public void setCustomerId(int arg);
public void setCustIncome(int arg);
public void setAddress(int arg);
}

The bean class is nothing but provides the implementation ( getters and setters )for the interface with the abstract definitions for other callback methods.

I have a helper method which I am using to create the home objects and define some methods.

public String getDataFields(){
String fieldName = "";
Collection custcoll;
try {
CustomerHome custh = (CustomerHome)context.lookup("local/ejb/Customer");
custcoll= custhome.findByCustomerId(customerId);
int size = custcoll.size();
System.out.println("collection size: " + size);
Iterator iterator = custcoll.iterator();
while(iterator.hasNext()){
System.out.println("inside iterator");
Customer cust1 = (Customer)iterator.next();
if(cust1!=null)
fieldName=cust1.getColumnName();
System.out.println("fieldName");
}
} catch (FinderException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
return fieldName;
}

01/18 16:16:26 error nested exception is: jrunx.persistence.LoadingException: SELECT * FROM Customer_Audit WHERE CUSTOMER_ID=?
javax.ejb.NoSuchObjectLocalException: nested exception is: jrunx.persistence.LoadingException: SELECT * FROM Customer_Audit WHERE REQUEST_ID=?
at jrun.ejb.interceptors.EntitySynchronizationInterceptor.invokeObjectMethod(EntitySynchronizationInterceptor.java:78)
at jrun.ejb.interceptors.EntityInstanceInterceptor.invokeObjectMethod(EntityInstanceInterceptor.java:233)
at jrun.ejb.interceptors.ContainerManagedTransactionInterceptor.invokeRequired(ContainerManagedTransactionInterceptor.java:304)
at jrun.ejb.interceptors.ContainerManagedTransactionInterceptor.invokeTransactedMethod(ContainerManagedTransactionInterceptor.java:140)

In the log files i get the message printing the size of the collection returned by the finder method but somehow the EJB reference the client is gettin is invalid.

Your help would be greatly appreciated. Please provide your suggestions to help solve this problem.
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is that REQUEST_ID the stack trace mentions? Just wondering if your code/deployment descriptors and the database are disagreeing on which column is actually the primary key.
 
gautam anand
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its not request_id ..it was actually Customer_id. Sorry for tht.
 
This tiny ad is suggesting that maybe she should go play in traffic.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic