1 2 Previous Next 25 Replies Latest reply: Dec 12, 2012 10:41 AM by Philippe Marschall Go to original post RSS
      • 15. Re: JBoss7 JNDI
        pushpak1981 Novice

        Great ! Thanks a lot.

        • 16. Re: JBoss7 JNDI
          Eric B Newbie

          Carlo de Wolf wrote:


          Either add an ObjectFactory to the naming subsystem:

          <subsystem xmlns="urn:jboss:domain:naming:1.1">
                  <object-factory name="java:/custom/dog" module="org.jboss.animalshelter" class="org.jboss.animalshelter.resource.DogFactory"/>

          or look through the example mention on:



          Can you provide more information on how to use the <object-factory/> bean?  I've looked for documentation for it, but cannot find anything and do not understand how to invoke it.  What is "module"?  Where/how do I provide a value?  Can I use this bean for a custom string binding?


          For example, I would like to bind a URL string to a jndi name.  ex: java:comp/env/url/google => http://www.google.com.  But I have no idea how to accomplish that kind of binding in AS7. 




          • 17. Re: JBoss7 JNDI
            Sergiu Pienar Apprentice

            What kind of context is the one on which you are calling the getChildTarget() method ?


            Can you supply with a more extended snippet ?


            Thank you

            • 18. Re: JBoss7 JNDI
              Guy Kaisin Newbie

              Hi All, don't want to break the discussion here. But I'm facing the same problem 'context is read only'.

              But let first state my problem.

              I am not creating a new application nor migrating an existing one.

              I'm 'porting' an existing application which is quite different then migrating: I don't want to touch the existing code.

              But if necessary, I can adapt some configuration.


              The application has been built targetting jboss 4.x.

              And registering some mbeans using a configuration file (i.e. -service.xml), here is a small extract to figure out:


              <?xml version="1.0" encoding="UTF-8"?>
              <server xmlns="urn:jboss:service:7.0"
                  xsi:schemaLocation="urn:jboss:service:7.0 jboss-service_7_0.xsd">
                  <mbean name="be.post.mid.services:context=DefaultContextMBean"
                         <attribute name="Context">mid</attribute>
                    JKit DAO
                  <mbean name="name=be.post.mid.services:dao=UserContextMBean"
                      <attribute name="JndiName">UserContext</attribute>
                      <attribute name="InterfaceClass">be.post.common.auth.user.UserContext</attribute>
                      <attribute name="ImplementationClass">be.post.common.auth.user.JBossUserContainer</attribute>



              But when deploying the application I got a stacktrace telling 'context is read only'

              Just to also indicate:


              - jboss 7.1.0 GA: impossible to use such mbeans because the serviceMBeanSupport class was not present

              - jboss 7.2.x alpha (build 1183) STILL gives the error


              Just reading some recommandations I saw it could be possible to use a work-around with WritableServiceBasedNamingStore.pushOwner(...) making the context writable.

              But in fact it seems unusable in my case.



              The code of our utility class looks


              like this:


              public class JndiBinder extends org.jboss.system.ServiceMBeanSupport implements
                      JndiBinderMBean {



                  public void startService() throws Exception {

                  private void rebind() throws NamingException {
                      InitialContext rootCtx = new InitialContext();
                      Name fullName = rootCtx.getNameParser("").parse(getFullJndiName());
                      logger.info("fullName=" + fullName);
                      org.jboss.util.naming.NonSerializableFactory.rebind(fullName, sHelper, true);




              And the error is raised when calling 'rebind'  ..NonSerializableFactory.rebind(...).


              Looking at the source code, I saw one argument is mandatory for WritableServiceBasedNamingStore.pushOwner(...): a 'ServiceTarget'.


              Here is the jboss source code (WritableServiceBasedNamingStore):


                   public static void pushOwner(final ServiceTarget target, final ServiceName... dependencies) {
                      WRITE_OWNER.push(new WriteOwner(target, dependencies));



              My questions are:


              (1) How can I instanciate a ServiceTarget regarding in the rebind() method of my JndiBinder utility ?

              (2) If not possible, could the recent re-introduced classes (in the system-jmx module - jb as 7) implement the binding by enabling a writable context ?









              • 19. Re: JBoss7 JNDI
                kknd22 Newbie

                I got the problem. Please show an example to get this mysterious context. I am porting some SAR from 4.3 to 7.1 as well. So far the porting has been quiet frustrating....

                • 20. Re: JBoss7 JNDI
                  kknd22 Newbie

                  Sorry. But I got excatly the same problem as Guy Kaisin and Sergiu Pienar. I run the debug thorugh JBOSS source code. It use reflection to call the MBean's start() method. Notice the method has no args. So is it even possible to get startContext.getChildTarget() ???

                  What is the apporiate work around? Thanks


                  • 21. Re: JBoss7 JNDI
                    Philippe Marschall Apprentice
                    • 22. Re: JBoss7 JNDI
                      kknd22 Newbie

                      Thanks for the quick turn around and fix. I maually apply the temp fix on the local source code of the base source 7.1.1.Final. JNDI binding start to work now!


                      However, it only work up till 7 bindings. Whenever we go  8 entries of jndi or above, the deployment hangs (ctrl-c can stop the server either). Through the debugger and thread dump, it inidcated that the wait was on




                      public void bind(final Name name, final Object object) throws NamingException {




                              try {





                      Any idea why 8 is such magic number? Is it that I did not apply the patch correctly or we might just discover another deffect?





                      • 23. Re: JBoss7 JNDI
                        Guy Kaisin Newbie

                        hi knd,


                        Just don't know how you make it work...

                        I've downloaded the last build from hudson from here



                        I took build version 3280.

                        But I still got 'context is read only' issue.

                        Please can you give details about your solution?

                        Do I need to use the "WritableServiceBasedNamingStore.pushOwner(xxx) " workaround?

                        If yes, how do you build the ServiceTarget object needed as parameter of the 'pushOwner' ?






                        • 24. Re: JBoss7 JNDI
                          Eduardo Martins Apprentice

                          Hello Guy, please create a JIRA and attach deployments which we can use to replicate the issue.

                          • 25. Re: JBoss7 JNDI
                            Philippe Marschall Apprentice

                            Guy Kaisin wrote:


                            hi knd,


                            Just don't know how you make it work...

                            I've downloaded the last build from hudson from here






                            You need the latest 7.x not 7.0 builds from https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/

                            1 2 Previous Next