SAP + Java: java.lang.NoClassDefFoundError: com.sap.conn.rfc.driver.CpicDriver

I developed a Java application that integrates with SAP. I developed it with Linux Server and Tomcat 7.0. I added sapjco3.jar and libsapjco3.so to the WEB-INF / lib folder. It works fine on the local server. But when deploying a WAR file to a remote server, the following error is generated.

java.lang.NoClassDefFoundError: com.sap.conn.rfc.driver.CpicDriver at com.sap.conn.rfc.engine.DefaultRfcRuntime.createChannel(DefaultRfcRuntime.java:52) at com.sap.conn.rfc.engine.RfcIoOpenCntl.open_channel(RfcIoOpenCntl.java:1260) at com.sap.conn.rfc.engine.RfcIoControl.ab_rfcopen(RfcIoControl.java:85) at com.sap.conn.rfc.api.RfcApi.RfcOpen(RfcApi.java:83) at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.connect(MiddlewareJavaRfc.java:1107) at com.sap.conn.jco.rt.ClientConnection.connect(ClientConnection.java:659) at com.sap.conn.jco.rt.PoolingFactory.init(PoolingFactory.java:103) at com.sap.conn.jco.rt.ConnectionManager.createFactory(ConnectionManager.java:171) at com.sap.conn.jco.rt.DefaultConnectionManager.createFactory(DefaultConnectionManager.java:44) at com.sap.conn.jco.rt.ConnectionManager.getFactory(ConnectionManager.java:160) at com.sap.conn.jco.rt.RfcDestination.initialize(RfcDestination.java:754) at com.sap.conn.jco.rt.RfcDestination.ping(RfcDestination.java:964) at com.my.ciry.sap.Connection.<init>(Connection.java:63) 

The error occurs when sending the destination from the Tomcat server.

 private JCoDestination dest; public Connection(SapSystem system) { dest = JCoDestinationManager.getDestination(SAP_SERVER); dest.ping(); } 

What is the cause of the problem.

+6
source share
2 answers

Ideally, you should store the libsapjco3.so file outside of your web application. Place it in an arbitrary place and add this path to the environment variable LD_LIBRARY_PATH. sapjco.jar may be in your class path.

If tomcat cannot load the .so file using an environment variable, you can try using System.setProperty ("java.library.path", "folder_path_of_.so_file");

OR try specifying this variable by editing the tomcat configuration files.

Finally, make sure the path_of_.so_file folder needs privileges for the tomcat user.

This will solve your problem.

......

+1
source

SAP servers are usually configured based on

System ID , Message Server and possibly a Group Server along with the Instance Number .

You probably need to pass these parameters when instantiating your connection. It may be that on localhost this is not necessary / ignorant, but it is required in production.

Try connecting to the server using the SAP tools and try to provide all the parameters that you otherwise could have provided.

If you post what settings you use for your JCO, maybe I can help more.

0
source

Source: https://habr.com/ru/post/951100/


All Articles