cancel
Showing results for 
Search instead for 
Did you mean: 

How to deploy a JCO Server????

Former Member
0 Kudos

Hello Experts!

I have written a JCO Server by using the Netweaver Developer Studio. Now I want to deploy this JCO Server on our SAP XI Server. The aim of this should be to create a connection between ABAP and JAVA to send data from JAVA to ABAP.

The RFC connection already exists and is working. What I don't know is how to deploy my JCO Server and how to start this JCO Server from our XI Server. I hope anybody could help me.

Thanks in advance!!!

Greetings Alexander

Here is the source code of my JCO Server:

public class JCOServer implements JCO.ServerExceptionListener, JCO.ServerStateChangedListener {

static public class Repository extends JCO.BasicRepository implements IRepository {

public Repository(String name)

{

super(name);

}

}

protected static IRepository repository;

static {

repository = new Repository("TestRepository");

JCO.MetaData fmeta = new JCO.MetaData("ZEJB_TEST_ZUGRIFF");

fmeta.addInfo("REQUTEXT", JCO.TYPE_CHAR, 255, 0, 0, JCO.IMPORT_PARAMETER, null);

fmeta.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255, 0, 0, JCO.EXPORT_PARAMETER, null);

fmeta.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255, 0, 0, JCO.EXPORT_PARAMETER, null);

repository.addFunctionInterfaceToCache(fmeta);

}

static public class Server extends JCO.Server {

public Server(String gwhost, String gwserv, String progid, boolean isUnicode, IRepository repository)

{

super(gwhost,gwserv,progid,repository);

this.setProperty("jco.server.unicode", isUnicode?"1":"0");

}

protected void handleRequest(JCO.Function function)

{

JCO.ParameterList input = function.getImportParameterList();

JCO.ParameterList output = function.getExportParameterList();

JCO.ParameterList tables = function.getTableParameterList();

System.out.println("handleRequest(" + function.getName() + ")");

System.out.println("Anfrage vom SAP-Server: " + input.getString("REQUTEXT"));

if (function.getName().equals("ZEJB_TEST_ZUGRIFF")) {

output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");

output.setValue("Das ist eine Antwort von JCOServer","RESPTEXT");

}

}

}

JCO.Server srv[] = new JCO.Server[1];

public JCOServer()

{

JCO.addServerExceptionListener(this);

JCO.addServerStateChangedListener(this);

}

public void startServers()

{

srv[0] = new Server("vxi1","sapgw00","BEAN",true,repository);

for (int i = 0; i < srv.length; i++) {
try {
srv.setTrace(true);
srv
.start();
}
catch (Exception ex) {
System.out.println("Konnte Server nicht starten: " + srv.getProgID() + ":

" + ex);

}//try

}//for

}

public void serverExceptionOccurred(JCO.Server server, Exception ex)

{

System.out.println("Ausnahme in Server " + server.getProgID() + ":

" + ex);

ex.printStackTrace();

}

public void serverStateChangeOccurred(JCO.Server server, int old_state, int new_state)

{

System.out.print("Server " + server.getProgID() + " hat den Status geändert von [");

if ((old_state & JCO.STATE_STOPPED ) != 0) System.out.print(" GESTOPPT ");

if ((old_state & JCO.STATE_STARTED ) != 0) System.out.print(" GESTARTED ");

if ((old_state & JCO.STATE_LISTENING ) != 0) System.out.print(" HORCHEN ");

if ((old_state & JCO.STATE_TRANSACTION) != 0) System.out.print(" TRANSAKTION ");

if ((old_state & JCO.STATE_BUSY ) != 0) System.out.print(" BESCHÄFTIGT ");

System.out.print("] nach [");

if ((new_state & JCO.STATE_STOPPED ) != 0) System.out.print(" GESTOPPT ");

if ((new_state & JCO.STATE_STARTED ) != 0) System.out.print(" GESTARTED ");

if ((new_state & JCO.STATE_LISTENING ) != 0) System.out.print(" HORCHEN ");

if ((new_state & JCO.STATE_TRANSACTION) != 0) System.out.print(" TRANSAKTION ");

if ((new_state & JCO.STATE_BUSY ) != 0) System.out.print(" BESCHÄFTIGT ");

System.out.println("]");

}

public static void main(String[] argv)

{

JCOServer obj = new JCOServer();

obj.startServers();

}

}

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Solved the problem!!!

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Alexander,

congratulations to the invention of the wheel....

Now, what do you think is the function of the application server itself? what you do here is to put a shell around JCO and then try to run it from another shell. Why not just use it from your program?

I recommend to do some of the examples with JCO and then see what the difference on this is.

Regards,

Benny

Former Member
0 Kudos

Hi Benny,

because I don't want to use it within the program. I know I can use it. But later I need to deploy this JCO Server anyway. But I still solved the problem now and don't need more such useful answers like the one from you!

Greetings, Alexander

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

Alexander,

I have to admit, that I did not know there is an actual server implementation for standalone use. Apologize for that. However, deploying this on a Java server is redoing the work that was already done, with less functionality. The J2EE community already defined the Java Resource Adapter standard for this.

Regards,

Benny