on 09-14-2016 2:46 PM
Hello Friends,
I’m connecting the SAP ECC system using JAVA and get the data from the Function Module.
Using
JAVA: JDK 1.7
Tomcat: version 8
Eclipse
I added “sapjco.jar” under application build path---Libraries.
I pasted “librfc32.dll “ under this path :C:\Windows\System32:
My Code:
package bjs.ecc.connection;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
public class ECC120Connection {
public static void main(String[] args) {
// TODO Auto-generated method stub
JCO.Client connectSAPClient = null;
IRepository mRepository;
try {
connectSAPClient=JCO.createClient("<SAP Client>","<UserId>","<Password>","EN","<Application server host name>","<system number>");
System.out.println("Step1");
try {
connectSAPClient.connect();
System.out.println("Sucessfully to connect to SAP system");
} catch (Exception ex) {
System.out.println("Failed to connect to SAP system");
}
mRepository = new JCO.Repository("saprep", connectSAPClient);
JCO.Function strExecuteFunction = mRepository.getFunctionTemplate(
"ZCI_PRICE_CHECKER").getFunction();
if (strExecuteFunction != null) {
JCO.ParameterList importParam = strExecuteFunction
.getImportParameterList();
importParam.setValue("11462", "IV_UPC");
try {
connectSAPClient.execute(strExecuteFunction);
System.out
.println("Sucessfully to execute the Function Module");
} catch (Exception ex) {
System.out.println("Failed to execute the Function Module");
}
// Print return message
JCO.Structure ret = strExecuteFunction.getExportParameterList()
.getStructure("RETURN");
System.out.println("ZCI_PRICE_CHECKER RETURN: "
+ ret.getString("EV_MAKTX"));
// Get table containing the orders
JCO.Table priceChecker_orders = strExecuteFunction
.getTableParameterList().getTable("ZCI_PRICE_CHECKER");
if (priceChecker_orders.getRow() > 0) {
} else {
System.out.println("No results found");
}
} else {
System.out
.println("Function ZCI_PRICE_CHECKER not found in backend system.");
}
} catch (Exception ex) {
System.out.println("Caught an exception: \n" + ex);
} finally {
// Release the client to the pool
JCO.releaseClient(connectSAPClient);
}
}
}
Run the application:
Its display below error
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.sap.mw.jco.JCO
at bjs.ecc.connection.ECC120Connection.main(ECC120Connection.java:69)
How to resolve this issue. Pls help me.
Regards
Vijay
SAP JCo 2.1 is out of support since 2013.
Furthermore SAP JCo 2.1 was never supported to run with JSE 1.7.
Please see note 549268 for further infos.
Solution:
Migrate your application and use JCo 3.0 instead,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still in confusion,
I developed this application using sapjco.jar file withjdk1.7.0_65 version in Eclipse
If i user sapjco3.jar whatever i did the code its not suitable. in that case what type of code i'll use. pls. help me this
if i use sapjco3.jar. is it require MODEL/MATA DATA.if it requires MODEL/MATA DATA when i run the application in tomcat is it working.
I am using Server is Tomcat. Can you pls. explain properly
I found connection code using sapjco3.jarDefining Destinations - Components of SAP Communication Technology - SAP Library
I didn't understand the below lines code. what is this ABAP_AS_WITHOUT_POOL and ABAP_AS_WITH_POOL
static String DESTINATION_NAME1 = "ABAP_AS_WITHOUT_POOL";
static String DESTINATION_NAME2 = "ABAP_AS_WITH_POOL";
Regards
Vijay
I developed this application using below environment
Jar file :sapjco3.jar
JDK Version: jdk1.6.0_45
Developing Tool: Eclipse and
Server: Tomcat server 7
OS: Windows 7
.dll files past into the :C:\Windows\System32(sapjco3.dll and librfc32.dll)
Using above Environment Its working fine into the my local System. I am able to connect SAP System and get the data from Function Module and populated into JSP.
Converted Same application as .war file and deployed into the below environment
Jar file :sapjco3.jar
JDK Version: jdk1.6.0_38
Server: Tomcat server 7
OS:Linux
After deploy the and run the application its thous the below error message.
HTTP Status 500 - Servlet execution threw an exception
--------------------------------------------------------------------------------
type Exception report
message Servlet execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: com/sap/conn/jco/JCo : cannot initialize class because prior initialization attempt failed
com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:104)
bjisp.PriceChecker.PCSAPConnectServlet.step3SimpleCall(PCSAPConnectServlet.java:137)
bjisp.PriceChecker.PCSAPConnectServlet.process(PCSAPConnectServlet.java:100)
bjisp.PriceChecker.PCSAPConnectServlet.doPost(PCSAPConnectServlet.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
root cause
java.lang.ExceptionInInitializerError: Native library sapjco3 is too old. Found library /usr/sap/JS1/sap_bobj/enterprise_xi40/linux_x64/libsapjco3.so has version "720.310", but required is at least version "721.713".
com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:244)
com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:99)
com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:170)
com.sap.conn.jco.JCo.createJCo(JCo.java:52)
com.sap.conn.jco.JCo.<clinit>(JCo.java:26)
com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:104)
bjisp.PriceChecker.PCSAPConnectServlet.step3SimpleCall(PCSAPConnectServlet.java:137)
bjisp.PriceChecker.PCSAPConnectServlet.process(PCSAPConnectServlet.java:100)
bjisp.PriceChecker.PCSAPConnectServlet.doPost(PCSAPConnectServlet.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.55 logs.
Kindly help me how to solve this issue Linux System
Regards
Vijay
Hi Vijay,
You need to place the fitting JCo JNI library on that system in the correct place. Please note that there are various Linux platforms and you need to use the correct library variant to make it work.
Simply download from SMP. The version available is obviously a very old one of an older patch level of JCo.
Best regards,
Markus
P.S.: the installation instructions of JCo 3.0 clearly state that you must not put the JNI library in the system32 folder. Please change this. Moreover, librfc32.dll is no longer used by JCo 3.0 and not needed at all.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.