I wrote a client to insert data to derby database, and then print all the data rows
in the console. The code is as below
| ublic class MsgSender {
|
| public static void main(String[] args) {
| // TODO Auto-generated method stub
| try {
|
| Context ctx= new InitialContext ( );
| PersonFacadeRemote dbcon =
(PersonFacadeRemote)ctx.lookup("PersonFacade/remote");
| Person newperson = new Person();
| newperson.setName("terry");
| dbcon.save(newperson);
| List<Person> results = dbcon.findAll();
| for (Person person:results)
| {
| System.out.println(person.getPersonId()+" "+person.getName());
| }
|
| } catch (Exception e) {
| System.out.println(e.getMessage());
| } finally {
| try {
|
| }
| }
|
| }
|
when i debug the programe, i found that it can sucsessfully insert the data into the
database, but when the programe run at the place
results = dbcon.findAll();
i found that the dbcon.findall() throw an unexpected exception
java.lang.RuntimeException: Specified calling class, [I could not be found for
sun.misc.Launcher$AppClassLoader@18d107f
i just didn't know why this error happend, since
dbcon.save(newperson);
works well.
The database related class is actually auto-generated by Myeclipse , and i checked
finding nothing wrong to my knowlege. The Person class implents Serializable interface and
the findall() funcition is as below
| @Remote
| public interface PersonFacadeRemote {
| public List<Person> findAll(int... rowStartIdxAndCount);
| }
|
| @SuppressWarnings("unchecked")
| public List<Person> findAll(final int... rowStartIdxAndCount) {
| LogUtil.log("finding all Person instances", Level.INFO, null);
| try {
| final String queryString = "select model from Person model order by
model.person_id";
| Query query = entityManager.createQuery(queryString);
| if (rowStartIdxAndCount != null && rowStartIdxAndCount.length > 0) {
| int rowStartIdx = Math.max(0, rowStartIdxAndCount[0]);
| if (rowStartIdx > 0) {
| query.setFirstResult(rowStartIdx);
| }
|
| if (rowStartIdxAndCount.length > 1) {
| int rowCount = Math.max(0, rowStartIdxAndCount[1]);
| if (rowCount > 0) {
| query.setMaxResults(rowCount);
| }
| }
| }
| return (List<Person>)query.getResultList();
| } catch (RuntimeException re) {
| LogUtil.log("find all failed", Level.SEVERE, re);
| throw re;
| }
| }
|
|
HOW CAN I FIX THIS PROBLEM?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4199666#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...