cancel
Showing results for 
Search instead for 
Did you mean: 

JCO in EJB over JBoss

Former Member
0 Kudos

Hi all,

Please, I am having some troubles, I will apreciate any help.

I have made a java client which access SAP RFC´s using JCO.

Now I am trying to put this code in an EJB, which will be accessed from a servlet.

I am using Jboss 3.26, an Eclipse 3.0 IDE witrh Lomboz plug-in.

I have two questions:

1. Is a good stategy to use EJB with JCO??

Or maybe, to use servlet its enough?

Or simple JSP with JavaBeans?

Someone has some working code for sample?

2. When I try do deploy the servlet, I get a error

when I call JCO.Attributes:

-ERROR MESSAGE--

-


09:44:37,729 WARN Verify failed; continuing

java.lang.NoClassDefFoundError: com/sap/mw/jco/JCO$Attributes

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)

at java.lang.Class.privateGetPublicMethods(Class.java:1778)

at java.lang.Class.getMethods(Class.java:832)

-

-


The code of the EJB is:

-

-


EJB CODE -

-


import javax.ejb.SessionBean;

import com.sap.mw.jco.JCO;

import com.sap.mw.jco.*;

public abstract class SAPcadastro2Bean implements javax.ejb.SessionBean {

public String heartBit (String mesg){

return "Bean SAP Cadastro 2 Alive!";

}

public String testeSAP(String msg){

JCO.Client client = null;

try {

System.out.println("Dentro do Try");

// Print the version of the underlying JCO library

System.out.println("

Version of the JCO-library:

" +"----

-


" + JCO.getMiddlewareVersion());

// Create a client connection to a dedicated R/3 system

client = JCO.createClient( "210", // SAP client

"luisv", // userid

"hakimus", // password

"PT", // language

"172.16.17.33", // host name

"00" ); // system number

// Open the connection

client.connect();

// Get the attributes of the connection and print them

/*

JCO.Attributes attributes = client.getAttributes();

System.out.println("Connection attributes:

" + "----

-


" + attributes);

*/

// Here I stop the teste. All done

*/

System.out.println("

Congratulations! It worked.");

}

catch (Exception ex) {

System.out.println("Caught an exception:

" + ex);

}

// do not forget to close the client connection

if (client != null) client.disconnect();

return "OK";

}

}

-

-


END EJB CODE----

-


Thanks in advance!

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi luis,

1. You can access JCO from all of these methods, but best way would be to access them from servlet or JavaBean. But anyway it depends on your requirement, sometime you need SAP data inside EJB and sometime in Servlet for display purpose only. So your JCO would depends where you need SAP data….

2. You need to include four jar file in your project:

sapjco.jar, SAPmdi.jar, aii_proxy_rt.jar, aii_util_misc.jar and Also "sapjcorfc.dll" and "JCo.jar" file is your classpath

Rgds,

Raj

PS: Pls don't forget to assign reward points when you feel that the answers to your questions are valuable.

Former Member
0 Kudos

Thanks very much.

I was guessing/feelign that there was some libraries missing on my project.

I already have include the sapjco.jar in the build path, but, the otehers lib that you say:

SAPmdi.jar,

aii_proxy_rt.jar,

aii_util_misc.jar

Where do I get?

Remenber, I am using Jboss.

Vlado
Advisor
Advisor
0 Kudos

Hi Luis,

These jars are part of SAP Exchange Infrastructure (XI). I don't think you'll need them in your environment. Check the link in my previous reply - it explains the whole process from building to running the application.

Best regards,

Vladimir

Former Member
0 Kudos

Thank you Pavlov.

In your reference, two thing become clear:

1. I need to setup the libraries that Rwawal said, available on the applciation runtine.

How? By placing in some place that I havent found yet (I try the /lib´s and adding to libraries to the project)

or by adding a "referece", as Pavlov said, in some Jboss configuration file, that I still having found.

2. The solution in that case was under Tomcat, so using just servlets, not EJB.

I prefer to use EJB´s.

Plan B: Servlets.

Please, setting up this libraries is geting me troubles

Message was edited by: luis caceres

Former Member
0 Kudos

Hi,

I dont know whether you have these option in eclipse or not but when you right click your Web Project, You will find an option "Add/Remove additional libraries" here you will find this com.sap.mw.jco select this option.. another way would be top put these libraries in class path of you Web Server.. Try this...

Rgds,

Raj

Former Member
0 Kudos

PLEASE, THIS QUESTION REMAINS UNSOLVED

Former Member
0 Kudos

Look at your JBoss implementation and find a way to include following files into your overall classpath.

Assumption 1: your jco is installed in c:\java\sap\jco

Your system path variable should be able to access

c:\java\sap\jco

Your overall JBoss classpath should include

c:\java\sap\jco;c:\java\sap\jco\sapjco.jar

This should take care of your problem

Enjoy

Vlado
Advisor
Advisor
0 Kudos

Hi Luis,

1. For simple JCO access there's no need to use EJBs, servlet is enough. Servlets are the Controller components of the MVC paradigm, so this should be the right place to put your JCO code. EJBs (especially entity beans) are the Model components, JSP is the View component.

2. Check this thread:

Hope that helps!

Vladimir