Lin Ren
2018-04-08 02:41:26 UTC
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
Â
Â
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
Â