Overview
A custom web application that is deployed to Savvion Business Manager (SBM) 2020 R1 with JBoss is facing a JSP compilation issue where the datasource lookup is failing because ServiceLocator cannot be resolved.
JBoss exception:
org.apache.jasper.JasperException: JBWEB004062: Unable to compile class for JSP:
JBWEB004061: An error occurred at line: 8 in the generated java file
Only a type can be imported. com.savvion.sbm.util.ServiceLocator resolves to a package
JBWEB004060: An error occurred at line: 36 in the jsp file: /so/PIlist.jsp
ServiceLocator cannot be resolved
33:
34: try {
35:
36: ds = ServiceLocator.self().getDataSource(jndiDB);
37: con = ds.getConnection();
38: out.println(" \n");
39: out.println("Connection established");
JBWEB004211: Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compil er.ErrorDispatcher.javacError(ErrorDispatcher.java:69)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java :451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
org.apache.jasper.compiler.Compiler.compile(Compiler.j ava:339)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
org.apache.jasper.JspCompilationContext.compile(Jsp CompilationContext.java:606)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jas per.servlet.JspServlet.serviceJspFile(JspServlet.java:309)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:242)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
Environment
All Supported Operating System Savvion-BPM Portal 10.0.x
Solution
The module concept in JBoss does not allow the access of an API from one web module to other.
Client jars need to be explicitly added to the module.xml of the custom application.
The ServiceLocator class, in particular, is bundled in blclient.jar which should be added to the module.xml of the custom web application as outlined below:
In case you need to copy the deployment folder from a different app server to JBoss under $SBM_HOME\webapps\deploy, follow the below steps:
- Copy the so folder under $SBM_HOME\webapps\deploy
- Rename the folder to include .war in the end.
In this case, you can rename the folder as <app name>.war (it is still a folder) - Create a .war.dodeploy file.
As the final step, you need to create a new file with the name <app name>.war.dodeploy. - Restart the portal server. The application will be deployed under the same location
Thereafter, follow these steps to allow the data source lookup using com.savvion.sbm.util.ServiceLocator
in the external JSP:
- If your JSP code is using a custom datasoure (e.g. jndiDB ="jdbc/SampleDB"), create the datasource using the below steps:
- Login to Jboss Admin portal Console.
- Configuration -> Datasources and add a datasource using the Add button.
- After creating the datasource, make sure the data source is enabled and working as shown below:
- Create a module for your application. The below steps assume a sample app named so. Ensure you change the names in module.xml to match your application.
- Download and unzip the attached module.zip, placing the app folder under SBM_HOME\modules\com\savvion\sbm, while ensuring the file path matches your app name e.g. SBM_HOME\modules\com\savvion\sbm\so\lib\main\module.xml
- Now, overwrite (copy and replace) the module.xml from SBM_HOME\modules\com\savvion\sbm\bpmportal\lib\main to SBM_HOME\modules\com\savvion\sbm\so\lib\main
(This step is to ensure that the path of the jars is correct in module.xml. The SBM path might differ if you use the XML from a different environment). - Change the module name in module.xml copied under SBM_HOME\modules\com\savvion\sbm\so\lib\main
from
<module xmlns="urn:jboss:module:1.1" name="com.savvion.sbm.bpmportal.lib">
to <module xmlns="urn:jboss:module:1.1" name="com.savvion.sbm.appname.lib"> e.g.
<module xmlns="urn:jboss:module:1.1" name="com.savvion.sbm.so.lib">
Note: This module.xml references many jars that might not be required in your application. You may remove them if not required by the application.
- Create a WEB-INF folder under SBM_HOME\webapps\deploy\so.war and copy the attached jboss-deployment-structure.xml under this folder (bundled in WEB-INF.zip).
- Try to access the JSP performing the datasource lookup using ServiceLocator class.
Note: Follow the same steps for all the applications, making sure to change the app names in module.xml and file paths accordingly for each application.