[jboss-user] [JNDI/Naming/Network] - javax.naming.NameNotFoundException whe doing jndi lookup

patwary_shiva do-not-reply at jboss.com
Mon Oct 15 17:27:03 EDT 2007


I  have written a small program to do jndi lookup .I call this program form struts action class.This class is in jar file under the server/lib directory of jboss.The strut action class is in war under the deploy directory.It throws javax.naming.NameNotFoundException: com.abc.DistributedScheduler not bound exception.Below is the code  Not much logic in this program.It works under weblogic but throws error in jboss..

// Standard Java classes
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

// Third-party classes
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * JNDISchedulerResolver
 *
 *
 */

public class JndiSchedulerResolver 
{
  // Public data ////////////////////////////////////////////////////////

  // Public methods /////////////////////////////////////////////////////

  public JndiSchedulerResolver()
  {
    Hashtable props = new Hashtable();
    // Turn on binding replication for clustering
    try
    {
      WebServerFactory.getSingleton().addJNDIProperties(props);
    }
    catch (Exception e)
    {
    }
    
    try 
    {
      this.context = new InitialContext(props);
    }
    catch (NamingException e)
    {
      logger.error("An error occurred", e);
    }
  }

  public void setLocalScheduler(Scheduler scheduler)
    throws SchedulerException
  {
    bindScheduler(LOCAL_SCHEDULER_JNDI_NAME, scheduler);
  }

  public Scheduler getLocalScheduler()
    throws SchedulerException
  {
    return lookupScheduler(LOCAL_SCHEDULER_JNDI_NAME);
  }

  public void setDistributedScheduler(Scheduler scheduler)
    throws SchedulerException
  {
    bindScheduler(DISTRIBUTED_SCHEDULER_JNDI_NAME, scheduler);
  }

  public Scheduler getDistributedScheduler()
    throws SchedulerException
  {
    return lookupScheduler(DISTRIBUTED_SCHEDULER_JNDI_NAME);
  }

  // Protected methods //////////////////////////////////////////////////

  // Private methods ////////////////////////////////////////////////////

  private void bindScheduler(String jndiName, Scheduler scheduler)
    throws SchedulerException
  {
    try
    {
      this.context.bind(jndiName, scheduler);
    }
    catch (NamingException e)
    {
      throw new SchedulerException(e);
    }
  }

  private Scheduler lookupScheduler(String jndiName)
    throws SchedulerException
  {
    try
    {
      return (Scheduler) this.context.lookup(jndiName);
    }
    catch (NamingException e)
    {
      throw new SchedulerException(e);
    }
  }

  // Private data ///////////////////////////////////////////////////////
  private Context context;

  private static final String LOCAL_SCHEDULER_JNDI_NAME =
    "com.abc.LocalScheduler";
  private static final String DISTRIBUTED_SCHEDULER_JNDI_NAME =
    "com.abc.DistributedScheduler";

  private static final Log logger =
    LogFactory.getLog(JndiSchedulerResolver.class);

}

Error:

com.abc.common.scheduler.SchedulerException: javax.naming.NameNotFoundException: com.abc.DistributedScheduler not bound
	at com.abc.common.scheduler.JndiSchedulerResolver.lookupScheduler(JndiSchedulerResolver.java:108)
	at com.abc.common.scheduler.JndiSchedulerResolver.getDistributedScheduler(JndiSchedulerResolver.java:79)
	at com.abc.drm.webapp.test.ListScheduledTasksAction.doExecute(ListScheduledTasksAction.java:56)
	at com.abc.common.webapp.struts.BasicAction.execute(BasicAction.java:180)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.abc.drm.servlet.CheckUriAccessFilter.doFilter(CheckUriAccessFilter.java:120)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.abc.drm.servlet.InitializationFilter.doFilter(InitializationFilter.java:135)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:595)
Caused by: javax.naming.NameNotFoundException: com.abc.DistributedScheduler not bound
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
	at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
	at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
	at javax.naming.InitialContext.lookup(InitialContext.java:351)
	at com.abc.common.scheduler.JndiSchedulerResolver.lookupScheduler(JndiSchedulerResolver.java:104)

 





View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4095415#4095415

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4095415



More information about the jboss-user mailing list