5 Replies Latest reply on Oct 6, 2008 12:12 PM by peterj

    Setting codebase in jboss ejb3 application has no efffect

    esalagea

      This is related to the topic http://www.jboss.com/index.html?module=bb&op=viewtopic&t=140498&start=0
      I have posted some time ago with no success.

      I'll be short:
      My bean application A (which runs inside jboss jvm) generates (with javaassist) a class C and perform an rmi call on a remote object RO passing in argument an object of type C (the generated class). My generated class is available on a http class server created by my application. So In my bean application A I add to the
      java.rmi.server.codebase property the address of my class server. so two entries are in the codebase: the jboss class server and my class server.
      The problem is that when the RO (remote object) receives the call, it will only try to download the class in the jbosses class server (on 8083 port) because it doesn't receive my codebase. So it will not find the class there because it is only availbe on my class server.

      So does jboss takes in account the property java.rmi.server.codebase when marshaling objects? does it override the marshaller?


      So, in short: whatever my bean writes in the java.rmi.server.codebase property (I also tried to leave it empty), the remote object will receive the codebase of jboss class server.
      The question is: can I change this behavior.

      Thanks in advance, It would really help me, It's been 2 months since I have this problem.

        • 1. Re:  Setting codebase in jboss ejb3 application has no efffe
          esalagea

          I keep doing researches on the internet.
          It looks like my problem is related to the jboss bug https://jira.jboss.org/jira/browse/JBPAPP-361
          but this bug is marked as "done" ...

          • 2. Re:  Setting codebase in jboss ejb3 application has no efffe
            esalagea

            I keep putting answers for myself .. maybe one day someone will help me ...
            finally i found out that, for some reason, the java.rmi.server.codebase property is only read once by the jboss jvm. If my bean application changes this property (adds a new codebase) the classes will still be serialised with the old codebase.
            Well.. is there anybody in there? Just nod if you can hear me ...

            • 3. Re:  Setting codebase in jboss ejb3 application has no efffe
              peterj

              One of the issues with asking questions in a user's forum is that at times you just might be treading in areas where no-one has gone before. In addition, if you attempt to combine several technologies, then the number of forum readers who have used that particular combination tapers off rapidly. Which means that unfortunately sometimes you are just on your own.

              Though I guess that if I would have read you question better, and not gotten scared away by the different things you were mentioning (javassist, RMI, downloading classes over port 8083????) and instead focused on your actual question: "does jboss takes in account the property java.rmi.server.codebase when marshaling objects?" I might have done a search through the source code looking for "java.rmi.server.codebase" and come up with the information you just found out: "the java.rmi.server.codebase property is only read once by the jboss".

              • 4. Re:  Setting codebase in jboss ejb3 application has no efffe
                esalagea

                Thanks Peter ...
                I took a deeper look in the Jboss code (including changing some code, recompiling, debugging) and I found the answer to my question.
                Basically that's it, jboss only reads once the java.rmi.server.codebase system property.
                So my question is: is this a bug? is this the desired behavior?

                Here some info about my researches:


                -the codebase is set by the org.jboss.web.WebService.createService() method, if the codebase is null on the creation of the service.

                - The class JBossRMIClassLoader is responsible for class annotation when marshaling objects. The method "public String getClassAnnotation(Class cl)" should add the annotation (i.e. the codebase), but it delegates this job (adding annotations) to an RMIClassLoaderSpi object that is created when the JBossRMIClassLoader class is loaded. For some resson, the RMIClassLoaderSpi object only reads the codebase once, and not each time it annotates a class. I have changed the code of org.jboss.system.JBossRMIClassLoader.getClassAnnotation(Class cl) method in order to make it print the annnotations. And indeed, the codebase annotations stays the same affter the system property java.rmi.server.codebase has changed.

                So yes, we can say, generally, that "Jboss only reads the "java.rmi.server.codebase" property once, at startup.

                One can add the java property -Djava.rmi.server.codebase="codebaseJboss someOtherCodebase" to JBoss startup in order to add different codebases.
                This solution works for my problem but I'm not happy with it because my application dinamically decides the codebases addresses it uses. So I have to force it to use some specified ports.

                So shoud I create a JIRA issue for this? (should that be a bug? or request for new feature? or improovement?)

                Emil

                • 5. Re:  Setting codebase in jboss ejb3 application has no efffe
                  peterj

                  You can always open a JIRA for a new feature. Providing a patch that implements the feature will greatly enhance the chances of the feature being implemented.