-
15. Re: JBoss7 JNDI
pushpak1981 Jan 12, 2012 6:32 AM (in response to jaikiran)Great ! Thanks a lot.
-
16. Re: JBoss7 JNDI
benze Feb 1, 2012 11:48 PM (in response to wolfc)Carlo de Wolf wrote:
Either add an ObjectFactory to the naming subsystem:
<subsystem xmlns="urn:jboss:domain:naming:1.1"> <bindings> <object-factory name="java:/custom/dog" module="org.jboss.animalshelter" class="org.jboss.animalshelter.resource.DogFactory"/> </bindings> </subsystem>
or look through the example mention on:
https://docs.jboss.org/author/display/AS7/Creating+Programatic+JNDI+Bindings
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.
Thanks,
Eric -
17. Re: JBoss7 JNDI
sergiu_pienar May 30, 2012 11:08 AM (in response to jaikiran)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
kaising Sep 18, 2012 11:22 AM (in response to pushpak1981)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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:service:7.0 jboss-service_7_0.xsd">
<mbean name="be.post.mid.services:context=DefaultContextMBean"
code="be.post.common.servicebinder.ContextBinder">
<attribute name="Context">mid</attribute>
</mbean>
<!--#####################################
JKit DAO
######################################-->
<mbean name="name=be.post.mid.services:dao=UserContextMBean"
code="be.post.common.servicebinder.ObjectJndiBinder">
<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>
</mbean>
...
</server>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.
Why?
The code of our utility class looks
public class JndiBinder extends org.jboss.system.ServiceMBeanSupport implements
JndiBinderMBean {...
@Override
public void startService() throws Exception {
rebind();
}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 ?
Regards,
G.
-
19. Re: JBoss7 JNDI
kknd22 Sep 18, 2012 1:02 PM (in response to kaising)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 Sep 19, 2012 3:04 PM (in response to kknd22)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
-C
-
-
22. Re: JBoss7 JNDI
kknd22 Sep 24, 2012 1:09 PM (in response to pmm)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
org.jboss.as.naming.WritableServiceBasedNamingStore
public void bind(final Name name, final Object object) throws NamingException {
....
builder.install();
try {
listener.await();
}
.....
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?
Thanks
-Chris
-
23. Re: JBoss7 JNDI
kaising Dec 12, 2012 8:38 AM (in response to kknd22)hi knd,
Just don't know how you make it work...
I've downloaded the last build from hudson from here
https://ci.jboss.org/hudson/view/JBoss%20AS/job/JBoss-AS-7.0.x/
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' ?
Regards,
Guy
-
24. Re: JBoss7 JNDI
emmartins Dec 12, 2012 10:05 AM (in response to kaising)Hello Guy, please create a JIRA and attach deployments which we can use to replicate the issue.
-
25. Re: JBoss7 JNDI
pmm Dec 12, 2012 10:41 AM (in response to kaising)Guy Kaisin wrote:
hi knd,
Just don't know how you make it work...
I've downloaded the last build from hudson from here
https://ci.jboss.org/hudson/view/JBoss%20AS/job/JBoss-AS-7.0.x/
...
You need the latest 7.x not 7.0 builds from https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/