Start a conversation

Unable to read sbmjndi.properties file in JSP page after upgrading to Aurea Process 2020 R1 with JBoss

Overview

You have JSP pages that read the sbmjndi.properties file to retrieve database details which worked with Aurea Process (formerly known as CX Process, Savvion and SBM) 2015 SP1 with the Pramati application server but are now failing after upgrading to Aurea Process 2020 R1 with the JBoss application server. 

The following code is the code that is used to retrieve the database details in the sbmjndi.properties file that works with Aurea Process 2015 SP1 with Pramati:

InitialContext ctx; 
Properties prop = new Properties();
InputStream is = ClassLoader.getSystemResourceAsStream("sbmjndi.properties");
prop.load(is);

String jndiUrl = prop.getProperty(providerURL);
String jndiContextFactory = prop.getProperty(factory);

prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, jndiContextFactory);
prop.setProperty(Context.PROVIDER_URL, jndiUrl);

ctx = new InitialContext(prop);
return (ctx);

When the same code is run after upgrading to Aurea Process 2020 R1 with JBoss, these JSP pages are now failing with the following error:

java.lang.NullPointerException 
java.util.Hashtable.put(Hashtable.java:514)
java.util.Properties.setProperty(Properties.java:161)
org.apache.jsp.can.attachments_jsp._jspService(attachments_jsp.java:466)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:69)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:365)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:242)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

Solution

Diagnosis

With JBoss, the path to the sbmjndi.properties file is not added to the portal server's classpath, so when the call ClassLoader.getSystemResourceAsStream("sbmjndi.properties") is made it is not able to find and load the sbmjndi.properties file.

Solution

To load the sbmjndi.properties file, you will need to use the  java.lang.Thread.getContextClassLoader() method to read the properties file.  The following is a code sample that can be used to read the sbmjndi.properties file into an InputStream.

ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 
InputStream is = classLoader.getResourceAsStream("sbmjndi.properties");

Testing

Once you have made the required code changes to your JSP pages, the JSP pages will be able to access the property values from the sbmjndi.properties file.

 

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Priyanka Bhotika

  2. Posted

Comments