Skip to Content
author's profile photo Former Member
Former Member

Error while displaying a page

Hi techies..

I installed JDK and Tomcat in my Redhat linux and downloaded the Sap Java connector and installed it witout any problem. But the problem now is in one of the pages i'm establishing the connection for R/3 and while displating that page i get the error

javax.servlet.ServletException: Cannot allocate servlet instance for path /examples/servlet/response

and the root cause is java.lang.NoClassDefFoundError: com/sap/mw/jco/JCO$Record

can any one pls guide me how to procede.

Regards

Sriram

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2004 at 08:27 AM

    Hi Sriram,

    have you registered the JCo library in the Tomcat's classpath? That could be the reason for not finding the class mentioned in the error message you get.

    Have a look at this thread where similar case is discussed: webservice-using-axis--tomcat-can-never-connect-us

    Hope that helps!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2004 at 10:01 AM

    thnx Ivaylo Ivanov

    But the problem is I have a Linux Redhat 9 OS and i dont know what are all the environmetn variable have be set.

    In the link which u had given, its discussed for windows. but in my case thats not so. So if any help from your side greatly appreciated.

    Regards

    Sriram

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Sriram,

      well, the problem on my side is I have little experience with Linux Redhat 9 😊

      However, I don't think the suggestions given in the post I linked you to are that OS-dependent. You just need to put the sapjco.jar into a directory where Tomcat keeps its shared libraries, and that would be the Tomcat_Home/shared/lib directory. This way it should be able to load the JCo classes that you need for the connection to the SAP system.

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2004 at 01:28 PM

    hii Ivaylo Ivanov

    Thnk you for you help. The problem was with the paths of some .so file (eque of dlls). I placed the librfccm.so and libsapjco.so in the same folder where sapcar.jar is and then set the LD_LIBRARY_PATH to the above path. it worked fine.but the problem is when i run the below class file : Java example2.. it gives me error saying the following error

    Exception in thread "main" java.lang.NoCLassDefFoundError: Example2

    given the program. any help?

    /**

    • Example2.java

    • Property of SAP AG, Walldorf

    • (c) Copyright SAP AG, Walldorf, 2000-2003.

    • All rights reserved.

    */

    import com.sap.mw.jco.*;

    /**

    • @version 1.0

    • @author SAP AG, Walldorf

    */

    public class Example2 {

    // The MySAP.com system we gonna be using

    static final String SID = "R3";

    // The repository we will be using

    IRepository repository;

    public Example2()

    {

    try {

    // Add a connection pool to the specified system

    // The pool will be saved in the pool list to be used

    // from other threads by JCO.getClient(SID).

    // The pool must be explicitely removed by JCO.removeClientPool(SID)

    JCO.addClientPool( SID, // Alias for this pool

    10, // Max. number of connections

    "210", // SAP client

    "abap", // userid

    "new", // password

    "EN", // language

    "10.11.20.2", // host name

    "00" );

    // Create a new repository

    // The repository caches the function and structure definitions

    // to be used for all calls to the system SID. The creation of

    // redundant instances cause performance and memory waste.

    repository = JCO.createRepository("MYRepository", SID);

    }

    catch (JCO.Exception ex) {

    System.out.println("Caught an exception: \n" + ex);

    }

    }

    // Retrieves and prints information about the remote system

    public void systemInfo()

    {

    try {

    // Get a function template from the repository

    IFunctionTemplate ftemplate = repository.getFunctionTemplate("RFC_SYSTEM_INFO");

    // if the function definition was found in backend system

    if(ftemplate != null) {

    // Create a function from the template

    JCO.Function function = ftemplate.getFunction();

    // Get a client from the pool

    JCO.Client client = JCO.getClient(SID);

    // We can call 'RFC_SYSTEM_INFO' directly since it does not need any input parameters

    client.execute(function);

    // The export parameter 'RFCSI_EXPORT' contains a structure of type 'RFCSI'

    JCO.Structure s = function.getExportParameterList().getStructure("RFCSI_EXPORT");

    // Use enumeration to loop over all fields of the structure

    System.out.println("System info for " + SID + ":\n" +

    "----


    ");

    for (JCO.FieldIterator e = s.fields(); e.hasMoreElements(); ) {

    JCO.Field field = e.nextField();

    System.out.println(field.getName() + ":\t" + field.getString());

    }//for

    System.out.println("\n\n");

    // Release the client into the pool

    JCO.releaseClient(client);

    }

    else {

    System.out.println("Function RFC_SYSTEM_INFO not found in backend system.");

    }

    }

    catch (Exception ex) {

    System.out.println("Caught an exception: \n" + ex);

    }

    }

    // Retrieves and displays a sales order list

    public void salesOrders()

    {

    JCO.Client client = null;

    try {

    // Get a function template from the repository

    IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_SALESORDER_GETLIST");

    // if the function definition was found in backend system

    if(ftemplate != null) {

    // Create a function from the template

    JCO.Function function = ftemplate.getFunction();

    // Get a client from the pool

    client = JCO.getClient(SID);

    // Fill in input parameters

    JCO.ParameterList input = function.getImportParameterList();

    input.setValue("0000001200", "CUSTOMER_NUMBER" );

    input.setValue( "1000", "SALES_ORGANIZATION");

    input.setValue( "0", "TRANSACTION_GROUP" );

    // Call the remote system

    client.execute(function);

    // Print return message

    JCO.Structure ret = function.getExportParameterList().getStructure("RETURN");

    System.out.println("BAPI_SALES_ORDER_GETLIST RETURN: " + ret.getString("MESSAGE"));

    // Get table containing the orders

    JCO.Table sales_orders = function.getTableParameterList().getTable("SALES_ORDERS");

    // Print results

    if (sales_orders.getNumRows() > 0) {

    // Loop over all rows

    do {

    System.out.println("----


    ");

    // Loop over all columns in the current row

    for (JCO.FieldIterator e = sales_orders.fields(); e.hasMoreElements(); ) {

    JCO.Field field = e.nextField();

    System.out.println(field.getName() + ":\t" + field.getString());

    }//for

    } while(sales_orders.nextRow());

    }

    else {

    System.out.println("No results found");

    }//if

    }

    else {

    System.out.println("Function BAPI_SALESORDER_GETLIST not found in backend system.");

    }//if

    }

    catch (Exception ex) {

    System.out.println("Caught an exception: \n" + ex);

    }

    finally {

    // Release the client to the pool

    JCO.releaseClient(client);

    }

    }

    protected void cleanUp() {

    JCO.removeClientPool(SID);

    }

    public static void main(String[] argv)

    {

    Example2 e = new Example2();

    e.systemInfo();

    e.salesOrders();

    e.cleanUp();

    }

    }

    Regards

    Sriram

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 24, 2004 at 03:21 PM

    You should add your current directory i.e. "." in your CLASSPATH .

    As far as I know u can set your classpath in "bash_profile" file

    set your classpath in "bash_profile" as follows

    CLASSPATH=.:$CLASSPATH

    export CLASSPATH

    and now you can try running the program as

    java example2

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.