03-10-2020 12:59 AM
I want to create a JSP and fetch data from SAP. I followed the official tutorial of sJco 3.0 and stuck in the first step. I'm really confused. Can some give a hint ? below is the offical sample code.
public class StepByStepClient
{
static String DESTINATION_NAME1 = "ABAP_AS_WITHOUT_POOL";
static String DESTINATION_NAME2 = "ABAP_AS_WITH_POOL";
static
{
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST,
"ls4065");
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,
"85");
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT,
"800");
connectProperties.setProperty(DestinationDataProvider.JCO_USER,
"homo faber");
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD,
"alaska");
connectProperties.setProperty(DestinationDataProvider.JCO_LANG,
"en");
createDestinationDataFile(DESTINATION_NAME1,
connectProperties);
connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPA
CITY, "3");
connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMI
T, "10");
createDestinationDataFile(DESTINATION_NAME2,
connectProperties);
}
static void createDestinationDataFile(String destinationName,
Properties connectProperties)
{
File destCfg = new File(destinationName+".jcoDestination");
try
{
FileOutputStream fos = new FileOutputStream(destCfg,
false);
connectProperties.store(fos, "for tests only !");
fos.close();
}
catch (Exception e)
{
throw new RuntimeException("Unable to create the
destination files", e);
}
}
public static void step1Connect() throws JCoException
{
JCoDestination destination=JCoDestinationManager.getDestination(DESTINATION_NAME1);
System.out.print(destination.getAttributes());
}
1.I don't understand what's the use of createDestinationDataFile method? It just create a file isn't it? all the property already set up in DestinationProvider, then why need a file?
2.I copy the sample code to a project and it worked. But when I triy to create a JSP and call it error happened. I doubt maybe the configuration file ABAP_AS_WITHOUT_POOL.property is the reason. Anyone has same error before? The error is below.
08:49:20,035 ERROR [stderr] (default task-2) java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
08:49:20,036 ERROR [stderr] (default task-2) at java.lang.ClassLoader.loadLibrary(Unknown Source)
08:49:20,049 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
08:49:20,049 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
08:49:20,186 ERROR [stderr] (default task-2) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
08:49:20,187 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
...
08:49:20,229 ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request to /TestWebsite/1.jsp: javax.servlet.ServletException: java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:889)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:818)
at org.apache.jsp._1_jsp._jspService(_1_jsp.java:165)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
...
Caused by: java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:226)
at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:98)
at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sap.conn.jco.JCo.createJCo(JCo.java:52)
at com.sap.conn.jco.JCo.<clinit>(JCo.java:26)
at com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:104)
at SCOfetch.JCOtest.step4QueryTable(JCOtest.java:217)
at org.apache.jsp._1_jsp._jspService(_1_jsp.java:149)
... 45 more
05-14-2020 6:47 AM
In wildfly 11 server. I create a module for the dll and jar in modules folder and in jboss-deployment-structure.xml point to it and problem solved.
03-10-2020 4:49 AM
The sapjco3.dll seems to be missing or is the wrong version.
Do you have the sapjco3.dll library installed and did you make sure that JVM and sapjco3.dll are for the same platform.
Go to Start>Control Panel>Java to check JVM version.
Otherwise try these links for more information:
1. JCO 3 problems with Library - UnsatisfiedLinkError [SOLVED] - Toolbox for IT Groups
05-13-2020 3:12 PM
loki_luo15, please follow up on your open question.
05-14-2020 6:47 AM
In wildfly 11 server. I create a module for the dll and jar in modules folder and in jboss-deployment-structure.xml point to it and problem solved.