8 Replies Latest reply on Jul 3, 2012 4:27 AM by bsudhananthan

    Issue when accessing nonserialized java object in stateless session bean

    bsudhananthan

      I'm using JBOSS AS 7 and jdk 1.7. In which i created a simple ejb project with session bean(BookCatalogBean) and a local plain java object(SimpleClass.java) which is not serialized. When i tried to call a method by invoking session bean it throws an exception  ::::: java.io.NotSerializableException(The full trace has been attached in this thread ). The exception is due to my SimpleClass.java is not serialized But i don't want it to be serialized.

       

      My class defenition as follows:

       

      Session Bean:

      @Stateless

      @Remote(BookCatalogInterface.class)

      public class BookCatalogBean implements  BookCatalogInterface{

       

                 @PersistenceContext(unitName = "EntityBean")

                    private EntityManager em;

       

      public SimpleClass checkforDatabaseConnection() {

             SimpleClass simpleclassl= new SimpleClass() ;

             ......

             ......

             return simpleclassl;

          }

      }

       

       

      Simple Non Serialized java class:

       

      public class SimpleClass {

            long id;

       

          public long getId() {

              return id;

          }

       

          public void setId(long id) {

              this.id = id;

          }  

      }

       

       

      Please any one give me the solution for the above issue.

      Thanks in advance.

        • 1. Re: Issue when accessing nonserialized java object in stateless session bean
          wdfink

          As you return the SimpleClass in a remote call it must be Serializable, otherwise it fails as you see

          1 of 1 people found this helpful
          • 2. Re: Issue when accessing nonserialized java object in stateless session bean
            bsudhananthan

            Thank you Wolf-Dieter Fink for your reply.

             

            Wolf-Dieter Fink wrote:

             

            As you return the SimpleClass in a remote call it must be Serializable, otherwise it fails as you see

             

            But Even when i invoke a method of session bean through local look up, i got an exception states

            "java.lang.RuntimeException: JBAS014154: Failed to marshal EJB parameters"

            (Entire trace has been Attached in this reply). But the exact code works for me in Jboss 5.

            • 3. Re: Issue when accessing nonserialized java object in stateless session bean
              wdfink

              Looks like that you have a 'org.json.JSONArray' somewhere in your call which can not serialized.

               

              How do you call the EJB via Remote-interface?

              I'm not sure whether it will work via local-interface, but I suppose that it is not a requirement if you use the locac-if

              • 4. Re: Issue when accessing nonserialized java object in stateless session bean
                bsudhananthan

                Wolf-Dieter Fink wrote:

                 

                Looks like that you have a 'org.json.JSONArray' somewhere in your call which can not serialized.

                 

                How do you call the EJB via Remote-interface?

                I'm not sure whether it will work via local-interface, but I suppose that it is not a requirement if you use the locac-if

                Thanks for you quick reply Wolf-Dieter Fink.

                 

                Yes 'JSONArray' cannot be serialized and that not need to be. I called the EJB via local-ifc. And there is no problem with lookup and specific method invokation. The problem is with returning NonSerialized 'JSONArray' object.

                 

                In Action.Class  i've called the lookup as below:

                 

                final Context context = new InitialContext();

                MapFacadeLocal map = (MapFacadeLocal)context.lookup("ejb:myApp/MapManager/

                MapFacadeBean!com.mydomain.nms.server.resource.map.interfaces.MapFacadeLocal");

                JSONArray mapDetailsJSON = map.getMapDetailsJSON(this.getGroupId());

                 

                 

                And my interface is like:

                 

                @Local

                public interface MapFacadeLocal

                {

                .....

                .....

                 

                JSONArray getMapDetailsJSON(final long groupId) throws Exception;

                .....

                }

                 

                 

                 

                And if you need any additional information Let me know.

                Note: This works fine in my JBoss 5.

                 

                 

                Thanks,

                Wolf-Dieter Fink

                • 5. Re: Issue when accessing nonserialized java object in stateless session bean
                  wdfink

                  I suppose this will be a bug. Do you use the latest 7.1? Maybe do you get a nightly build or the git repo and re-test it.

                  If you see still the issue please file a JIRA for AS7 and link it to this thread.

                   

                  From the spec,  Enterprise JavaBeans 3.1, Final Release; chapter 3.2.2 :

                   

                  Access to an enterprise bean through the local client view is only required to be supported for local cli-

                  ents packaged within the same application as the enterprise bean that provides the local client view.

                  Compliant implementations of this specification may optionally support access to the local client view

                  of an enterprise bean from a local client packaged in a different application. The configuration require-

                  ments for inter-application access to the local client view are vendor-specific and are outside the scope

                  of this specification. Applications relying on inter-application access to the local client view are

                  non-portable.

                   

                  In EJB 3.x, a local client accesses a session bean through the bean’s local business interface or through

                  a no-interface client view representing all the public methods of the bean class. For a session bean or

                  entity bean client and component written to the EJB 2.1 and earlier APIs, the local client accesses the

                  enterprise bean through the bean’s local home and local component interfaces. The container object that

                  implements a local business interface or the no-interface local view is a local Java object.

                   

                  The arguments and results of the methods of the local client view are passed “by reference”. Enter-

                  prise beans that provide a local client view should therefore be coded to assume that the state of any

                  Java object that is passed as an argument or result is potentially shared by caller and callee.

                  • 6. Re: Issue when accessing nonserialized java object in stateless session bean
                    bsudhananthan

                    Currently i'm using latest nightly build downloaded from  https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/ last week. I will do some little more R&D related to this issue to make sure that i'm not missing anything and then i'll raise an issue in jira for JBOSS 7.

                     

                    Thank u very much,

                    Wolf-Dieter Fink

                    • 7. Re: Issue when accessing nonserialized java object in stateless session bean
                      wdfink

                      No problem.

                       

                      Please be so kind and post the result and JIRA link here

                      • 8. Re: Issue when accessing nonserialized java object in stateless session bean
                        bsudhananthan

                        Test project for reproducing the issue.

                         

                        1.test.ear.zip  : Contains my "test.ear" i.e my application.

                        2.Src_File.zip: Contains the source file(Project created in eclipse).

                        3.Serialization.log.zip : Contains Entire log trace.

                         

                        Note: Uploaded the above files for reproducing the issue created in Jboss as 7 JIRA https://issues.jboss.org/browse/AS7-5103