Discussion:
[jetty-users] Can Jetty user bind JNDI by themselves?
Lin Ren
2018-04-08 02:41:26 UTC
Permalink
Hi,

 

I’m currently trying to bind a JNDI by myself in the Bean code (not in the application), code is like below:

 

   try {

      // Bind receiver under server name

      jndiName = WlngContext.getInstance().getServerName();

final String JNDI_PREFIX = "event_channel/";

      fullJndiName = JNDI_PREFIX + jndiName;

      namingContext = new InitialContext();

      localReceiver = new EventReceiverImpl(this);

      namingContext.bind(fullJndiName, localReceiver);

      eventContext = (EventContext) namingContext.createSubcontext(JNDI_PREFIX);

      namingListener = new EventReceiversListener(this);

      eventContext.addNamingListener("", EventContext.ONELEVEL_SCOPE, namingListener);

      refreshCachedEventReceivers();

    } catch (Exception e) {

      // Cleanup what we've done before throwing exception

      System.out.println("================================" + e.getMessage());

      e.printStackTrace();

      deactivate();

      throw e;

    }

 

And I got an exception said that:

 

javax.naming.NameNotFoundException: event_channel is not bound

         at org.eclipse.jetty.jndi.local.localContextRoot.bind(localContextRoot.java:608)

         at org.eclipse.jetty.jndi.local.localContextRoot.bind(localContextRoot.java:547)

         at javax.naming.InitialContext.bind(InitialContext.java:425)

         at com.bea.wlcp.wlng.event_channel.rmi.EventBroadcasterRmi.activate(EventBroadcasterRmi.java:54)

 

My question here is, can we bind JNDI by ourselves? If yes, how can we do for that?

 

Thanks!

 

Lin

 
Joakim Erdfelt
2018-04-09 12:22:36 UTC
Permalink
That error tells you that "/event_channel" doesn't exist.

You are trying to bind "/event_channel/${serverName}" before the parent
even exists.
Post by Lin Ren
Hi,
I’m currently trying to bind a JNDI by myself in the Bean code (not in the
*try* {
// Bind receiver under server name
jndiName = WlngContext.*getInstance*().getServerName();
*final* String *JNDI_PREFIX* = "event_channel/";
fullJndiName = *JNDI_PREFIX* + jndiName;
namingContext = *new* InitialContext();
localReceiver = *new* EventReceiverImpl(*this*);
*namingContext.bind(fullJndiName, localReceiver);*
eventContext = (EventContext) namingContext.createSubcontext(
*JNDI_PREFIX*);
namingListener = *new* EventReceiversListener(*this*);
eventContext.addNamingListener("", EventContext.*ONELEVEL_SCOPE*,
namingListener);
refreshCachedEventReceivers();
} *catch* (Exception e) {
// Cleanup what we've done before throwing exception
System.*out*.println("================================" + e
.getMessage());
e.printStackTrace();
deactivate();
*throw* e;
}
*javax.naming.NameNotFoundException: event_channel is not bound*
at org.eclipse.jetty.jndi.local.localContextRoot.bind(
localContextRoot.java:608)
at org.eclipse.jetty.jndi.local.localContextRoot.bind(
localContextRoot.java:547)
at javax.naming.InitialContext.bind(InitialContext.java:425)
at com.bea.wlcp.wlng.event_channel.rmi.
EventBroadcasterRmi.activate(EventBroadcasterRmi.java:54)
My question here is, can we bind JNDI by ourselves? If yes, how can we do for that?
Thanks!
Lin
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Lin Ren
2018-04-10 03:54:58 UTC
Permalink
Hi,

 

Thanks a lot for your reply!

 

Then how can I bind a resource to a tree like name, such as “a/b/c”, please? We’re trying merge from Weblogic to Jetty, and seems something different between Weblogic and Jetty on the JNDI name binding


 

Thanks!

 

Lin

 

From: Joakim Erdfelt [mailto:***@webtide.com]
Sent: 2018幎4月9日 20:23
To: JETTY user mailing list
Subject: Re: [jetty-users] Can Jetty user bind JNDI by themselves?

 

That error tells you that "/event_channel" doesn't exist.

 

You are trying to bind "/event_channel/${serverName}" before the parent even exists.

 




Joakim Erdfelt / HYPERLINK "mailto:***@webtide.com"***@webtide.com

 

On Sat, Apr 7, 2018 at 9:41 PM, Lin Ren <HYPERLINK "mailto:***@oracle.com"***@oracle.com> wrote:

Hi,

 

I’m currently trying to bind a JNDI by myself in the Bean code (not in the application), code is like below:

 

   try {

      // Bind receiver under server name

      jndiName = WlngContext.getInstance().getServerName();

final String JNDI_PREFIX = "event_channel/";

      fullJndiName = JNDI_PREFIX + jndiName;

      namingContext = new InitialContext();

      localReceiver = new EventReceiverImpl(this);

      namingContext.bind(fullJndiName, localReceiver);

      eventContext = (EventContext) namingContext.createSubcontext(JNDI_PREFIX);

      namingListener = new EventReceiversListener(this);

      eventContext.addNamingListener("", EventContext.ONELEVEL_SCOPE, namingListener);

      refreshCachedEventReceivers();

    } catch (Exception e) {

      // Cleanup what we've done before throwing exception

      System.out.println("================================" + e.getMessage());

      e.printStackTrace();

      deactivate();

      throw e;

    }

 

And I got an exception said that:

 

javax.naming.NameNotFoundException: event_channel is not bound

         at org.eclipse.jetty.jndi.local.localContextRoot.bind(localContextRoot.java:608)

         at org.eclipse.jetty.jndi.local.localContextRoot.bind(localContextRoot.java:547)

         at javax.naming.InitialContext.bind(InitialContext.java:425)

         at com.bea.wlcp.wlng.event_channel.rmi.EventBroadcasterRmi.activate(EventBroadcasterRmi.java:54)

 

My question here is, can we bind JNDI by ourselves? If yes, how can we do for that?

 

Thanks!

 

Lin

 


_______________________________________________
jetty-users mailing list
HYPERLINK "mailto:jetty-***@eclipse.org"jetty-***@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
HYPERLINK "https://urldefense.proofpoint.com/v2/url?u=https-3A__dev.eclipse.org_mailman_listinfo_jetty-2Dusers&d=DwMFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=XJ-Gh-WfgW8GDdxqZAEJhhrdvcNRWEfurTuAQfQYVAo&m=6Kgfq031S-kkrbCmZrMY-SHQJgc_yvp0cGete-fqLlc&s=7vXLnlD5bGsYfAkLc9-QSJSMa3Xkz8W03RfDvUt1kHU&e="https://dev.eclipse.org/mailman/listinfo/jetty-users

 
Jan Bartel
2018-04-10 22:16:55 UTC
Permalink
Make the subcontext first and then bind the object into it.

Jan
Post by Lin Ren
Hi,
Thanks a lot for your reply!
Then how can I bind a resource to a tree like name, such as “a/b/c”,
please? We’re trying merge from Weblogic to Jetty, and seems something
different between Weblogic and Jetty on the JNDI name binding

Thanks!
Lin
*Sent:* 2018幎4月9日 20:23
*To:* JETTY user mailing list
*Subject:* Re: [jetty-users] Can Jetty user bind JNDI by themselves?
That error tells you that "/event_channel" doesn't exist.
You are trying to bind "/event_channel/${serverName}" before the parent even exists.
Hi,
I’m currently trying to bind a JNDI by myself in the Bean code (not in the
*try* {
// Bind receiver under server name
jndiName = WlngContext.*getInstance*().getServerName();
*final* String *JNDI_PREFIX* = "event_channel/";
fullJndiName = *JNDI_PREFIX* + jndiName;
namingContext = *new* InitialContext();
localReceiver = *new* EventReceiverImpl(*this*);
*namingContext.bind(fullJndiName, localReceiver);*
eventContext = (EventContext) namingContext.createSubcontext(
*JNDI_PREFIX*);
namingListener = *new* EventReceiversListener(*this*);
eventContext.addNamingListener("", EventContext.*ONELEVEL_SCOPE*,
namingListener);
refreshCachedEventReceivers();
} *catch* (Exception e) {
// Cleanup what we've done before throwing exception
System.*out*.println("================================" + e
.getMessage());
e.printStackTrace();
deactivate();
*throw* e;
}
*javax.naming.NameNotFoundException: event_channel is not bound*
at
org.eclipse.jetty.jndi.local.localContextRoot.bind(localContextRoot.java:608)
at
org.eclipse.jetty.jndi.local.localContextRoot.bind(localContextRoot.java:547)
at javax.naming.InitialContext.bind(InitialContext.java:425)
at
com.bea.wlcp.wlng.event_channel.rmi.EventBroadcasterRmi.activate(EventBroadcasterRmi.java:54)
My question here is, can we bind JNDI by ourselves? If yes, how can we do for that?
Thanks!
Lin
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
<https://urldefense.proofpoint.com/v2/url?u=https-3A__dev.eclipse.org_mailman_listinfo_jetty-2Dusers&d=DwMFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=XJ-Gh-WfgW8GDdxqZAEJhhrdvcNRWEfurTuAQfQYVAo&m=6Kgfq031S-kkrbCmZrMY-SHQJgc_yvp0cGete-fqLlc&s=7vXLnlD5bGsYfAkLc9-QSJSMa3Xkz8W03RfDvUt1kHU&e=>
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Joakim Erdfelt
2018-04-10 22:26:42 UTC
Permalink
Like Jan says, make the subcontext first, then the others.

So "a/b/c" means you'll ..

* create subcontext "a"
* create subcontext "b" (from "a")
* create subcontext "c" (from "b")

This is how the jndi layer/api works.

The jetty implementation has a non-standard way to skip the subcontext
creation called "deep binding"

In the various javax.naming.Context methods that pertain to Environment (as
a Hashtable usually), setup an entry with key
"org.eclipse.jetty.jndi.deepBinding" with value of "true".
This feature was implemented in Jetty for the various EE folks to use (such
as TomEE, CDI, and OpenEJB).
Post by Jan Bartel
Make the subcontext first and then bind the object into it.
Jan
Post by Lin Ren
Hi,
Thanks a lot for your reply!
Then how can I bind a resource to a tree like name, such as “a/b/c”,
please? We’re trying merge from Weblogic to Jetty, and seems something
different between Weblogic and Jetty on the JNDI name binding

Thanks!
Lin
*Sent:* 2018幎4月9日 20:23
*To:* JETTY user mailing list
*Subject:* Re: [jetty-users] Can Jetty user bind JNDI by themselves?
That error tells you that "/event_channel" doesn't exist.
You are trying to bind "/event_channel/${serverName}" before the parent even exists.
Hi,
I’m currently trying to bind a JNDI by myself in the Bean code (not in
*try* {
// Bind receiver under server name
jndiName = WlngContext.*getInstance*().getServerName();
*final* String *JNDI_PREFIX* = "event_channel/";
fullJndiName = *JNDI_PREFIX* + jndiName;
namingContext = *new* InitialContext();
localReceiver = *new* EventReceiverImpl(*this*);
*namingContext.bind(fullJndiName, localReceiver);*
eventContext = (EventContext) namingContext.createSubcontext(
*JNDI_PREFIX*);
namingListener = *new* EventReceiversListener(*this*);
eventContext.addNamingListener("", EventContext.*ONELEVEL_SCOPE*,
namingListener);
refreshCachedEventReceivers();
} *catch* (Exception e) {
// Cleanup what we've done before throwing exception
System.*out*.println("================================" + e
.getMessage());
e.printStackTrace();
deactivate();
*throw* e;
}
*javax.naming.NameNotFoundException: event_channel is not bound*
at org.eclipse.jetty.jndi.local.localContextRoot.bind(
localContextRoot.java:608)
at org.eclipse.jetty.jndi.local.localContextRoot.bind(
localContextRoot.java:547)
at javax.naming.InitialContext.bind(InitialContext.java:425)
at com.bea.wlcp.wlng.event_channel.rmi.
EventBroadcasterRmi.activate(EventBroadcasterRmi.java:54)
My question here is, can we bind JNDI by ourselves? If yes, how can we do for that?
Thanks!
Lin
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
<https://urldefense.proofpoint.com/v2/url?u=https-3A__dev.eclipse.org_mailman_listinfo_jetty-2Dusers&d=DwMFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=XJ-Gh-WfgW8GDdxqZAEJhhrdvcNRWEfurTuAQfQYVAo&m=6Kgfq031S-kkrbCmZrMY-SHQJgc_yvp0cGete-fqLlc&s=7vXLnlD5bGsYfAkLc9-QSJSMa3Xkz8W03RfDvUt1kHU&e=>
_______________________________________________
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Loading...