Hallo Zusammen,
ich habe ein Html formular erstellt und möchte von meinem Servlet mit JCO Programm auf SAP zugreifen, um die Daten auszulesen, die ich in meinem Formular eingegeben habe.leider, ensteht das unten stehende fehler:
Hat Jemand von euch eine Idee, wie man lösen kann
Danke voraus für eure Hilfe.
Gruss.
Programmcode:
package aenderungsantragsmanagement;
import java.io.IOException;
import java.io.PrintWriter;
//import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import javax.servlet.RequestDispatcher;
import com.sap.mw.jco.*;
/**
* Servlet implementation class for Servlet: Hallo
*
*/
public class Hallo extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public Hallo() {
super();
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
//The MySAP.com system we gonna be using
static final String SID = "R3";
// The repository we will be using
IRepository repository;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
try {
response.setContentType("text/html");
// Create a connection pool
JCO.addClientPool(
SID,// Alias for this pool
10, // Max. number of connections
"024", // SAP client
"fonou", // userid
"vivie82", // password
"DE", // language
"p52082", // host name
"00" ); // system number
// Create a new repository
repository = JCO.createRepository("MYRepository", SID);
//Get a function template from the repository
IFunctionTemplate ftemplate = repository.getFunctionTemplate("Z_TEST_CONNECTION");
// 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);
//Fill in input parameters
JCO.ParameterList input = function.getImportParameterList();
String Zuname = request.getParameter("Zuname");
String Vorname = request.getParameter("Vorname");
String Kommentar = request.getParameter("Kommentar");
input.setValue(Zuname, "ZZUNA");
input.setValue(Vorname, "ZVORN");
input.setValue(Kommentar, "ZKOME");
//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 ret = function.getExportParameterList().getStructure("RETURN");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Test</title>");
out.println("</head>");
out.println("<body>");
//Get table containing the data
JCO.Table test = function.getTableParameterList().getTable("ZPRKO");
for(int i = 0; i < test.getNumRows(); i++)
{
test.setRow(i);
Zuname = test.getString("ZZUNA");
Vorname = test.getString("ZVORN");
Kommentar = test.getString("ZKOME");
out.println("<FORM>");
out.println("<TABLE>");
out.println("<TR><TD>Zuname:</TD>");
out.println("<TD><INPUT>"+Zuname+"</TD><TR>");
out.println("<TR><TD>Vorname:</TD>");
out.println("<TD><INPUT>"+Vorname+"</TD></TR>");
out.println("<TR><TD>Kommentar:</TD>");
out.println("<TD><INPUT>"+Kommentar+"</TD></TR>");
}//for
out.println("</TABLE>");
out.println("</FORM>");
out.println("</BODY>");
out.println("</HTML>");
out.close();
// Release the client into the pool
JCO.releaseClient(client);
/*
//Setze die zurück gegebene Daten im Request
Probe antrag = new Probe();
request.setAttribute("antrag", input);
*/
/*
//Hole den Request Dispatcher für die JSP Datei
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Hallo.jsp");
//Leite auf die JSP Datei zum Anzeigen der Liste weiter
dispatcher.forward(request, response);
*/
}
else
{
System.out.println("Function RFC_SYSTEM_INFO not found in backend system.");
}
}
catch (Exception ex) {
ex.printStackTrace ();
System.exit (1);
}
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
this.doGet(request, response);
}
}
Fehler:
exception
javax.servlet.ServletException: Error instantiating servlet class aenderungsantragsmanagement.Hallo
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.NoClassDefFoundError: com/sap/mw/jco/IFunctionTemplate
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Unknown Source)