6

I have developed a java web application integrating with SAP. I have developed it with Linux Server and Tomcat 7.0. I have added sapjco3.jar and libsapjco3.so in WEB-INF/lib folder. It is working fine local server. But when deploying WAR file in remote server the following error is generating.

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 is arising when ping the destination from Tomcat Server.

private JCoDestination dest;    
    public Connection(SapSystem system)  {

    dest = JCoDestinationManager.getDestination(SAP_SERVER);

            dest.ping();
}

What's the cause of the problem.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Master Mind
  • 2,386
  • 3
  • 31
  • 48
  • Is that class definitely within that jar file? – Jon Skeet Aug 06 '13 at 08:54
  • @JonSkeet , yes class is within the jar – Master Mind Aug 06 '13 at 08:57
  • Any other errors earlier in the log which might indicate something wrong in the war or jar file? – Jon Skeet Aug 06 '13 at 09:04
  • @JonSkeet , this is only error which is listing in remote server log. No issue when run in local server. – Master Mind Aug 06 '13 at 09:19
  • 2
    My wild hunch would be that the shared library cannot be found but this error is not being shown because it is somehow masked by the ClassNotFoundDef error. I think I saw this before in situations with .so files before. Storing the .so file in the WAR file also seems strange to me. I would expect it to be in a directory where the LD_LIBRARY_PATH is pointing to or somewhere the java.library.path is pointing to. Is this the case or not? – Henk de Vries Aug 08 '13 at 18:01
  • Could it be you have the .so in your local system classpath (or in the tomcat classpath), and it's not in the system classpath of the remote tomcat server? – Alper Akture Aug 08 '13 at 20:57
  • Thanks all, it was due to SAP Server authentication and added roles in SAP Server. – Master Mind Sep 09 '13 at 09:54

2 Answers2

0

SAP Servers are generally configured based on

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

You probably need to pass these parameters when instantiating your connection. It could be that on localhost, these are not needed/ignorable, but on production, it is required.

Try connecting to the server using SAP's tools and try to provide all the settings that you would otherwise provide.

If you post what settings you are using for your JCO, perhaps I can help more.

Nasir
  • 2,984
  • 30
  • 34
  • 1
    Sorry to say, but this is wrong. Whatever you choose at JCo side, no logon parameter setting, JCo program configuration or API usage will result in a NoClassDefFoundError. Such an error is always caused by external factors, e.g. a wrong JCo installation. – Trixx Dec 31 '16 at 19:22
0

Ideally, you should keep libsapjco3.so file outside your web application. Place it in any arbitary location and add that folder path to LD_LIBRARY_PATH environment variable. sapjco.jar can be in your classpath.

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

OR try to supply this variable by editing tomcat configuration files.

Finally, ensure that folder_path_of_.so_file has needed privileges for tomcat user.

This will solve your problem.

......

Gana
  • 482
  • 3
  • 11
  • 32