3 Replies Latest reply on Jan 6, 2009 2:49 AM by jaikiran pai

    error when calling entity bean findall() functions

    Yu Cui Newbie

      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?

        • 1. Re: error when calling entity bean findall() functions
          jaikiran pai Master

          Please post the entire exception stacktrace. Which version of JBoss and Java do you use? Based on the one line error message, i can only guess that you are using JDK1.6. Please provide the exact versions. And where do you see this error, on the client or on the server?

          • 2. Re: error when calling entity bean findall() functions
            Yu Cui Newbie

            i use jdk1.6, jboss 5.0.0.GA, My eclipse 6.0


            java.lang.RuntimeException: Specified calling class, [I could not be found for sun.misc.Launcher$AppClassLoader@18d107f
            at org.jboss.ejb3.common.lang.SerializableMethod.getClassFromName(SerializableMethod.java:348)
            at org.jboss.ejb3.common.lang.SerializableMethod.toMethod(SerializableMethod.java:238)
            at org.jboss.ejb3.common.lang.SerializableMethod.toMethod(SerializableMethod.java:219)
            at org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase.invoke(ProxyInvocationHandlerBase.java:236)
            at org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase.invoke(SessionSpecProxyInvocationHandlerBase.java:101)
            at $Proxy2.findAll(Unknown Source)
            at MsgSender.main(MsgSender.java:61)
            Caused by: java.lang.ClassNotFoundException: [I
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at org.jboss.ejb3.common.lang.SerializableMethod.getClassFromName(SerializableMethod.java:344)
            ... 6 more


            The exception error occurs on the client.

            • 3. Re: error when calling entity bean findall() functions
              jaikiran pai Master

               

              java.lang.RuntimeException: Specified calling class, [I could not be found for sun.misc.Launcher$AppClassLoader@18d107f
              at org.jboss.ejb3.common.lang.SerializableMethod.getClassFromName(SerializableMethod.java:348)
              at org.jboss.ejb3.common.lang.SerializableMethod.toMethod(SerializableMethod.java:238)


              See this http://www.jboss.com/index.html?module=bb&op=viewtopic&t=147301#4196426. Known issue which we fixed recently.

              Workarounds:

              1) Use JDK 1.5 instead
              OR
              2) Use -Dsun.lang.ClassLoader.allowArraySyntax=true as mentioned in the README of the JBossAS-5.0 GA.