Qpid
  1. Qpid
  2. QPID-3307

ClassNotfound Exception when using Qpid java client in Complex classloading Environments.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.13
    • Component/s: Java Client
    • Labels:
      None

      Description

      Hi ,

      When we are using qpid client to receive JMSObject in complex class loading environments like web application containers/Osgi environments .There is a scenario where this issues comes.

      Scenario.

      In a web application container normally they use a class loader per web app. and if we have qpid client libs at the root classloader level this error can come. The reason for this is Serializable Object types that are used inside the web app are not visible to the class loader that loads the JMSObject message and unmarshall it.

      thanks,
      Charith

      1. QPID-3307_patch.txt
        6 kB
        Charith Dhanushka Wickramarachchi
      2. QPID-3307_patch.txt
        6 kB
        Charith Dhanushka Wickramarachchi
      3. QPID-3307_patch.txt
        6 kB
        Charith Dhanushka Wickramarachchi
      4. QPID-3307_patch_unit_test.txt
        4 kB
        Charith Dhanushka Wickramarachchi

        Activity

        Hide
        Charith Dhanushka Wickramarachchi added a comment -

        Attaching the patch to resolve this issue.

        I looked at the Apache ActiveMQ code and used the method they used to resolve this exact issue.

        thanks,
        Charith

        Show
        Charith Dhanushka Wickramarachchi added a comment - Attaching the patch to resolve this issue. I looked at the Apache ActiveMQ code and used the method they used to resolve this exact issue. thanks, Charith
        Hide
        Charith Dhanushka Wickramarachchi added a comment -

        Re-attaching the patch Granting license to ASF for inclusion in ASF works

        Show
        Charith Dhanushka Wickramarachchi added a comment - Re-attaching the patch Granting license to ASF for inclusion in ASF works
        Hide
        Keith Wall added a comment -

        Hi Charith

        I think the patch on the whole looks fine. My comments would be only a) the absence of a unit test case and b) bracing style does not match https://cwiki.apache.org/qpid/java-coding-standards.html. I think a unit test that exercised the happy/unhappy path with a normal classloader arrangement would suffice. We do already have a system test, ObjectMessageTest, but I think we should be striving for more unit tests wherever we can.

        cheers Keith.

        Show
        Keith Wall added a comment - Hi Charith I think the patch on the whole looks fine. My comments would be only a) the absence of a unit test case and b) bracing style does not match https://cwiki.apache.org/qpid/java-coding-standards.html . I think a unit test that exercised the happy/unhappy path with a normal classloader arrangement would suffice. We do already have a system test, ObjectMessageTest, but I think we should be striving for more unit tests wherever we can. cheers Keith.
        Hide
        Charith Dhanushka Wickramarachchi added a comment -

        Hi Keith ,

        Thanks for the feedback. I have updated the patch by changing the bracing style according to the doc you have pointed.

        I'll attach another patch for unit tests after i look at the current system test and object message test.

        thanks,
        Charith

        Show
        Charith Dhanushka Wickramarachchi added a comment - Hi Keith , Thanks for the feedback. I have updated the patch by changing the bracing style according to the doc you have pointed. I'll attach another patch for unit tests after i look at the current system test and object message test. thanks, Charith
        Hide
        Charith Dhanushka Wickramarachchi added a comment -

        Hi ,

        I'm attaching an unit test case which will send receive an Object Message which have a custom Serializable Type inside.In that case the ObjectInputStream i have provided will be used. To re-create the exact class loading scenario I'll have to find a way to simulate that kind of class loading environment within the Unit test. I'll have to think through it on how to implement that.

        thanks,
        Charith

        Show
        Charith Dhanushka Wickramarachchi added a comment - Hi , I'm attaching an unit test case which will send receive an Object Message which have a custom Serializable Type inside.In that case the ObjectInputStream i have provided will be used. To re-create the exact class loading scenario I'll have to find a way to simulate that kind of class loading environment within the Unit test. I'll have to think through it on how to implement that. thanks, Charith
        Hide
        Keith Wall added a comment -

        Hi Charith

        Did you take a look at the unit tests in directory client/src/test/java in package org.apache.qpid.test.unit.client.message?

        I think the addition of a 'pure' unit test, rather than an extension to the system test would be more appropriate. I'd imagine we'd want a unit test much like client's BytesMessageTest, which would exercise the happy paths (serialised class, serialised primitive) and the maybe the unhappy path (serialised class not found through I can see this might be tricky).

        I took a look at your extension to the system test ObjectInputStream. Does the test using CustomSerializableObject give us anything more than the existing tests with ObjectMessageTest.Payload?

        Hope this helps.

        Show
        Keith Wall added a comment - Hi Charith Did you take a look at the unit tests in directory client/src/test/java in package org.apache.qpid.test.unit.client.message? I think the addition of a 'pure' unit test, rather than an extension to the system test would be more appropriate. I'd imagine we'd want a unit test much like client's BytesMessageTest, which would exercise the happy paths (serialised class, serialised primitive) and the maybe the unhappy path (serialised class not found through I can see this might be tricky). I took a look at your extension to the system test ObjectInputStream. Does the test using CustomSerializableObject give us anything more than the existing tests with ObjectMessageTest.Payload? Hope this helps.
        Hide
        Charith Dhanushka Wickramarachchi added a comment -

        Hi Keith ,

        Thanks for the feedback. Yes you are correct i was looking at Test cases in systests/src/main/java. As you mentioned the scenario covered by the test case i have provided is already covered in org.apache.qpid.test.unit.client.message.ObjectMessageTest.

        I see there is no unit test for Object messages in package org.apache.qpid.test.unit.client.message to I'll add an unit test for it and provide a patch.

        thanks,
        Charith

        Show
        Charith Dhanushka Wickramarachchi added a comment - Hi Keith , Thanks for the feedback. Yes you are correct i was looking at Test cases in systests/src/main/java. As you mentioned the scenario covered by the test case i have provided is already covered in org.apache.qpid.test.unit.client.message.ObjectMessageTest. I see there is no unit test for Object messages in package org.apache.qpid.test.unit.client.message to I'll add an unit test for it and provide a patch. thanks, Charith
        Hide
        Robbie Gemmell added a comment -

        Hi Charith,

        Have you made any progress on adding at least happy-path unit testing for this? It would be good to get your patch applied.

        Regards,
        Robbie

        Show
        Robbie Gemmell added a comment - Hi Charith, Have you made any progress on adding at least happy-path unit testing for this? It would be good to get your patch applied. Regards, Robbie
        Hide
        Charith Dhanushka Wickramarachchi added a comment -

        Hi Robbie,

        Sorry for the delay in updating. Actually i found a way to simulate the Environment but i caught up with some work and couldn't find a time to work on a unit test case. I think happy path is already covered in the current serialization test cases we have. Only thing is i need to add a test case that simulates the above mentioned class loading environment. Will be able to provide a patch for that soon, possibly in next weekend.

        thanks,
        Charith

        Show
        Charith Dhanushka Wickramarachchi added a comment - Hi Robbie, Sorry for the delay in updating. Actually i found a way to simulate the Environment but i caught up with some work and couldn't find a time to work on a unit test case. I think happy path is already covered in the current serialization test cases we have. Only thing is i need to add a test case that simulates the above mentioned class loading environment. Will be able to provide a patch for that soon, possibly in next weekend. thanks, Charith
        Hide
        Robbie Gemmell added a comment -

        In the interests of getting this applied I have applied the 'QPID-3307_patch.txt' from June 20th, and then corrected a couple of style issues and added some basic unit tests myself for ObjectMessage and ClassLoadingAwareObjectInputStream to provide some unit rather than system test coverage of the classes.

        Resolving JIRA.

        Show
        Robbie Gemmell added a comment - In the interests of getting this applied I have applied the ' QPID-3307 _patch.txt' from June 20th, and then corrected a couple of style issues and added some basic unit tests myself for ObjectMessage and ClassLoadingAwareObjectInputStream to provide some unit rather than system test coverage of the classes. Resolving JIRA.

          People

          • Assignee:
            Robbie Gemmell
            Reporter:
            Charith Dhanushka Wickramarachchi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development