title: JDE BSFN throwing boot strap login error through servlet but not main method
body: <p>I'm trying to call a JDE BSFN through a servlet, and it keeps failing on login, throwing a bootstrap login error.  I have the same code being called from a main method (launched from a script on command line), and it logs in fine. Both pieces of code use the same jar and configuration files, the only difference is one is a servlet and the other is just a main method.</p>
  
  <p>Has anyone ever run into this issue?  Everything worked fine when on Tools 9.1, but when trying to use Tools 9.2, this has started happening.  It seems something is getting blocked when using the servlet method.  Could this be a tools release issue?  Firewall issue?  I'm at a total loss, Oracle is no help.</p>
  
  <p>Here is the code that doesn't login:</p>
  
  <pre><code>
  import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  import com.jdedwards.system.connector.dynamic.Connector;
  import com.jdedwards.system.connector.dynamic.UserSession;
  import com.jdedwards.system.connector.dynamic.SystemException;
  import com.jdedwards.system.security.SecurityToken;
  import com.jdedwards.system.security.SecurityServer;
  import com.jdedwards.system.security.SecurityServerResponse;
  import com.jdedwards.system.security.SecurityServerInstance;
  import com.jdedwards.system.connector.dynamic.callmethod.BSFNExecutionWarning;
  import com.jdedwards.system.connector.dynamic.callmethod.ExecutableMethod;
  import com.jdedwards.system.connector.dynamic.spec.source.*;
  import com.jdedwards.system.connector.dynamic.spec.SpecFailureException;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Hashtable;
  import junit.framework.TestCase;
  import com.jdedwards.system.lib.JdeProperty;
  import com.jdedwards.system.security.SecurityServerException;
  
  public class OrderController extends HttpServlet {
      static OrderController abTest = null;
      private String username = "";
      private String password = "";
      private String env = "";
      private String role = "*ALL";
      private BSFNSpecSource specSource = null;
      private Connector connector = Connector.getInstance();
      private Connector connectorToken = null;
      private ExecutableMethod ab = null;
      private int sessionID;
      private int connectorSessionID;
      private long totalTime;
      private UserSession connectorSession = null;
  
      public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException { 
          long beginTime = 
          System.currentTimeMillis();
  
          try {
              username = "WEBCOM";
              password = "DK3N2PZ";
              env = "JPY920";
              role = "*ALL";
              System.setProperty("default_path", "/var/www/vhosts/bushhogservicecenter.com/httpdocs/jcomp/WEB-INF/classes/connectorsamplegood/");
              sessionID = connector.login(username, password, env, role);
              specSource = new OneworldBSFNSpecSource(sessionID);
              ab = specSource.getBSFNMethod("GetEffectiveAddress").createExecutable();
          } catch (SystemException e) {
              e.printStackTrace();
              System.out.println("root cause is:" + e.getRootException().getMessage());
              e.getRootException().printStackTrace();
          }
  
  
          ab.resetValues();
          ab.setValue("mnAddressNumber", "563885");
          BSFNExecutionWarning warning = null;
          try{
              warning = ab.execute(sessionID);
          } catch (Exception e){
          }
  
          //----------------------------------------------------------------
          //Setting the Output code below.......
          //----------------------------------------------------------------
  
          abTest.connector.logoff(abTest.sessionID);
      }
  
  }
  ```
  Here is the code that does login in:
  ```
  package com.brilliantblue.order;
  
  import com.jdedwards.system.connector.dynamic.Connector;
  import com.jdedwards.system.connector.dynamic.UserSession;
  import com.jdedwards.system.connector.dynamic.SystemException;
  import com.jdedwards.system.security.SecurityToken;
  import com.jdedwards.system.security.SecurityServer;
  import com.jdedwards.system.security.SecurityServerResponse;
  import com.jdedwards.system.security.SecurityServerInstance;
  import com.jdedwards.system.connector.dynamic.callmethod.BSFNExecutionWarning;
  import com.jdedwards.system.connector.dynamic.callmethod.ExecutableMethod;
  import com.jdedwards.system.connector.dynamic.spec.source.*;
  import com.jdedwards.system.connector.dynamic.spec.SpecFailureException;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Hashtable;
  import junit.framework.TestCase;
  import com.jdedwards.system.lib.JdeProperty;
  import com.jdedwards.system.security.SecurityServerException;
  
  public class TestConnector extends TestCase {
      static TestConnector abTest = null;
      private String username = "";
      private String password = "";
      private String env = "";
      private String role = "*ALL";
      private BSFNSpecSource specSource = null;
      private Connector connector = Connector.getInstance();
      private Connector connectorToken = null;
      private ExecutableMethod ab = null;
      private int sessionID;
      private int connectorSessionID;
      private int multipleRun = 1;
      private long totalTime;
      private UserSession connectorSession = null;
      private SecurityToken securityToken = null;
      private BSFNSpecSource specSource2 = null;
      private ExecutableMethod ab2 = null;
      private SecurityServerResponse ssResponse = null;
      private SecurityServer securityServer = null;
      private boolean testToken = false;
      private boolean testNormalToken = false;
      private String invalidToken = "";
  
      public static void main(String[] args) throws Exception {
         long beginTime = System.currentTimeMillis();
         abTest = new TestConnector("Dynamic Connector Test");
         abTest.setUp();
         abTest.testGetAddress();
         abTest.testGetAddressMap();
         long endTime = System.currentTimeMillis();
         abTest.totalTime = endTime - beginTime;
         System.out.println("Run " + abTest.multipleRun + " times of DC AddressBook, total time is " + abTest.totalTime);
         abTest.tearDown();
         System.exit(1);
      }
  
      protected void setUp() {
          try {
              username = "WEBCOM";
              password = "DK3N2PZ";
              env = "JPY920";
              role = "*ALL";
              multipleRun = 1;
              testToken =  false;
              testNormalToken = false;
              invalidToken = "";
              System.setProperty("default_path", "/var/www/vhosts/bushhogservicecenter.com/httpdocs/jcomp/WEB-INF/classes/connectorsamplegood/");
              if (testToken) {
                  System.out.println("Testing login in with token");
              }
              if (invalidToken != "") {
                  System.out.println("Testing Invalid Token");
              }
             if (!testToken)
                  sessionID = connector.login(username, password, env, role);
              else {
                  connectorToken = Connector.getInstance();
                  if (testNormalToken) {
                      try {
                          securityServer = SecurityServerInstance.getInstance();
  
                      } catch(SecurityServerException e) {
                          e.printStackTrace();
  
                      }
                      try {
                      ssResponse = securityServer.login(username, password);
                      securityToken = ssResponse.getToken();
                      }   catch (SecurityServerException es) {
                          es.printStackTrace();
                      }
  
                  } else {
                      sessionID = connector.login(username, password, env, role);
                      connectorSession = connector.getUserSession(sessionID);
                      securityToken = connectorSession.getToken();
                  }
                  System.out.println("--&gt;" + securityToken.toString() + "&lt;--");
                  if (invalidToken != "") {
                      //generate token
                      if (invalidToken == "null")
                          connectorSessionID = connectorToken.login("", env, role);
                      else {
                      SecurityToken invsecurityToken = new SecurityToken(invalidToken);
                          // this should raise an exception
                          connectorSessionID = connectorToken.login(invsecurityToken, env, role);
                          }
                  }
                  else
                      connectorSessionID = connectorToken.login(securityToken, env, role);
                  }
  
                  System.out.println("login success");
                  // specSource = new ImageBSFNSpecSource("JDEAddressBook.xml");
                  if (testToken){
                  System.out.println("login 1");
                      specSource = new OneworldBSFNSpecSource(connectorSessionID);
                  }else{
                  System.out.println("login 2");
                      specSource = new OneworldBSFNSpecSource(sessionID);
                  }
                  System.out.println("login 2.5");
                  ab = specSource.getBSFNMethod("GetEffectiveAddress").createExecutable();
                  System.out.println("login 3");
                  if (testToken){
                  System.out.println("login 4");
                      specSource2 = new OneworldBSFNSpecSource(connectorSessionID);
                  }else{
                  System.out.println("login 5");
                      specSource2 = new OneworldBSFNSpecSource(sessionID);
          }
                  System.out.println("login 6");
                  ab2 = specSource2.getBSFNMethod("GetEffectiveAddress").createExecutable();
                  System.out.println("login 7");
              } catch (SystemException e) {
                  e.printStackTrace();
                  System.out.println("root cause is:" + e.getRootException().getMessage());
                  e.getRootException().printStackTrace();
              }
          }
  
          protected void tearDown() {
          if (!testToken)
              abTest.connector.logoff(abTest.sessionID);
          else {
              abTest.connector.logoff(abTest.sessionID);
              abTest.connectorToken.logoff(abTest.connectorSessionID);
          }
          }
          public TestConnector(String s) {
              super(s);
          }
          public void testGetAddress() {
              try {
                  for (int i = 0; i &lt; multipleRun; i++) {
                      getAddress(563885);
                  }
              } catch (SystemException e) {
                  System.out.println(e.toString());
                  e.getRootException().printStackTrace();
              }
          }
          public void testGetAddressMap() {
              try {
                  for (int i = 0; i &lt; multipleRun; i++) {
                      getAddressMap(563885);
                  }
              } catch (SystemException e) {
                  System.out.println(e.toString());
                  e.getRootException().printStackTrace();
              }
          }
          public void getAddress(int addressNo) throws SystemException {
              System.out.println("get address book ID=" + addressNo);
              ab.resetValues();
              ab.setValue("mnAddressNumber", String.valueOf(addressNo));
              BSFNExecutionWarning warning = null;
              if (!testToken) {
                  warning = ab.execute(sessionID);
              }
              else {
                  warning = ab.execute(connectorSessionID);
              }
              System.out.println("szNamealpha=" + ab.getValue("szNamealpha").toString());
              System.out.println("mnAddressNumber=" + ab.getValue("mnAddressNumber").toString());
              System.out.println("szAddressLine1=" + ab.getValue("szAddressLine1").toString());
              System.out.println("szZipCodePostal=" + ab.getValue("szZipCodePostal").toString());
              if (warning != null) {
                  System.out.println(warning.toString());
              }
          }
          public void getAddressMap(int addressNo) throws SystemException {
              // clear parameter set
              ab.resetValues();
              // input
              Map input = new Hashtable();
              input.put("mnAddressNumber", String.valueOf(addressNo));
              ab.setValues(input);
              // execute
              if (!testToken) {
                  BSFNExecutionWarning errors = ab.execute(sessionID);
              }
              else {
                  BSFNExecutionWarning errors = ab.execute(connectorSessionID);
              }
              //output
              Map output = ab.getValues();
              System.out.println("szNamealpha=" + output.get("szNamealpha").toString());
              System.out.println("mnAddressNumber=" + output.get("mnAddressNumber").toString());
              System.out.println("szAddressLine1=" + output.get("szAddressLine1").toString());
              System.out.println("szZipCodePostal=" + output.get("szZipCodePostal").toString());
              //call ab2,
              // clear parameter set
              ab2.resetValues();
              // input
              Map input2 = new Hashtable();
              input2.put("mnAddressNumber", String.valueOf(addressNo));
              ab2.setValues(input2);
              // execute
              if (!testToken) {
                  BSFNExecutionWarning errors2 = ab2.execute(sessionID);
              } else {
                  BSFNExecutionWarning errors2 = ab2.execute(connectorSessionID);
              }
              //output
              Map output2 = ab2.getValues();
              System.out.println("szNamealpha=" + output2.get("szNamealpha").toString());
              System.out.println("mnAddressNumber=" + output2.get("mnAddressNumber").toString());
              System.out.println("szAddressLine1=" + output2.get("szAddressLine1").toString());
              System.out.println("szZipCodePostal=" + output2.get("szZipCodePostal").toString());
          }
      }
  ```
  Here are errors when the login fails:
  
  Feb 06, 2019 11:47:04 AM org.apache.commons.modeler.Registry registerComponent
  SEVERE: Error registering jde:targetType=management_agent_server
  javax.management.RuntimeMBeanException: RuntimeException thrown in preDeregister method
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.throwMBeanRegistrationException(DefaultMBeanServerInterceptor.java:985)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.preDeregisterInvoke(DefaultMBeanServerInterceptor.java:1047)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:433)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:537)
          at org.apache.commons.modeler.Registry.registerComponent(Unknown Source)
          at com.jdedwards.mgmt.agent.Server.initializeServer(Unknown Source)
          at com.jdedwards.mgmt.agent.Server.getServer(Unknown Source)
          at com.jdedwards.system.security.proxy.SecurityServerProxyImpl.&lt;init&gt;(Unknown Source)
          at com.jdedwards.system.security.proxy.SecurityServerProxyImpl.&lt;init&gt;(Unknown Source)
          at com.jdedwards.system.security.proxy.SecurityServerProxyImpl.install(Unknown Source)
          at com.jdedwards.system.security.proxy.SecurityServerProxyFactory.create(Unknown Source)
          at com.jdedwards.system.security.SecurityServerInstance.getInstance(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.loginBase(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.loginBase(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.login(Unknown Source)
          at com.brilliantblue.order.OrderController.service(OrderController.java:55)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
          at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
          at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
          at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
          at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
          at java.lang.Thread.run(Thread.java:722)
  Caused by: java.lang.NullPointerException
          at com.jdedwards.mgmt.agent.Server.preDeregister(Unknown Source)
          at org.apache.commons.modeler.BaseModelMBean.preDeregister(Unknown Source)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.preDeregisterInvoke(DefaultMBeanServerInterceptor.java:1045)
          ... 30 more
  
  Feb 06, 2019 11:47:04 AM com.jdedwards.mgmt.agent.Server initializeServer
  SEVERE: Unable to register the management agent server mbean
  javax.management.RuntimeMBeanException: RuntimeException thrown in preDeregister method
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.throwMBeanRegistrationException(DefaultMBeanServerInterceptor.java:985)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.preDeregisterInvoke(DefaultMBeanServerInterceptor.java:1047)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:433)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:537)
          at org.apache.commons.modeler.Registry.registerComponent(Unknown Source)
          at com.jdedwards.mgmt.agent.Server.initializeServer(Unknown Source)
          at com.jdedwards.mgmt.agent.Server.getServer(Unknown Source)
          at com.jdedwards.system.security.proxy.SecurityServerProxyImpl.&lt;init&gt;(Unknown Source)
          at com.jdedwards.system.security.proxy.SecurityServerProxyImpl.&lt;init&gt;(Unknown Source)
          at com.jdedwards.system.security.proxy.SecurityServerProxyImpl.install(Unknown Source)
          at com.jdedwards.system.security.proxy.SecurityServerProxyFactory.create(Unknown Source)
          at com.jdedwards.system.security.SecurityServerInstance.getInstance(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.loginBase(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.loginBase(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.login(Unknown Source)
          at com.brilliantblue.order.OrderController.service(OrderController.java:55)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
          at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
          at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
          at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
          at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
          at java.lang.Thread.run(Thread.java:722)
  Caused by: java.lang.NullPointerException
          at com.jdedwards.mgmt.agent.Server.preDeregister(Unknown Source)
          at org.apache.commons.modeler.BaseModelMBean.preDeregister(Unknown Source)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.preDeregisterInvoke(DefaultMBeanServerInterceptor.java:1045)
          ... 30 more
  
  com.jdedwards.system.connector.dynamic.ServerFailureException:   Exception occurred while validating role and/or environment in Java Connector Login method:
  [BOOTSTRAP_ERROR] An error occurred during bootstrap.
          at com.jdedwards.system.connector.dynamic.Connector.loginBase(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.loginBase(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.login(Unknown Source)
          at com.brilliantblue.order.OrderController.service(OrderController.java:55)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
          at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
          at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
          at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
          at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
          at java.lang.Thread.run(Thread.java:722)
  root cause is:[BOOTSTRAP_ERROR] An error occurred during bootstrap.
  com.jdedwards.system.connector.dynamic.ServerFailureException: [BOOTSTRAP_ERROR] An error occurred during bootstrap.
          at com.jdedwards.system.connector.dynamic.UserSession.initialize(Unknown Source)
          at com.jdedwards.system.connector.dynamic.UserSession.&lt;init&gt;(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.loginBase(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.loginBase(Unknown Source)
          at com.jdedwards.system.connector.dynamic.Connector.login(Unknown Source)
          at com.brilliantblue.order.OrderController.service(OrderController.java:55)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
  
  </code></pre>