cancel
Showing results for 
Search instead for 
Did you mean: 

Get Client JAR to access EJB from remote JAVA client application

Former Member
0 Kudos

Experts,

As I understand, when you access enterprise beans from a remote Java client application, you must <u>get Client JAR</u>. This will provide the necessary classes to use the client view of the enterprise beans. The Deploy service can pack the interfaces, stubs, and skeletons of the EJB application in a JAR file, which is created in the directory you specified.

Further, here is the procedure to obtain the client JAR.

http://help.sap.com/saphelp_nw04/helpdata/en/5f/2dd984b5d1304b9155f161568f2f64/frameset.htm

This procedure is a bit too advanced for me, so I have a few questions:

1. The procedure mentions that I need to "Select the EJB application for which you want to create a client JAR from the Deployed Components list." Where do I do this? In the VisualAdministrator tool?

2. At the end, the procedure indicates that to be able to do this you have to set a classpath reference from the Java client application to this client JAR. Does this mean I have to add this JAR as an "external JAR", similar to how I added the sapj2eeclient.jar and ejb20.jar?

Thanks much!

Kevin

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hai Kevin,

You can find the jar files with server.

Location \usr\sap\J2E\JCXX\j2ee\j2eeclient

needed jars

1.sapj2eeclient.jar

2.ejb20.jar

3.exception.jar

4.logging.jar

here is the code for remote client



import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
 
 public class RemoteClient {
 public static void main(String[] args) {
  
  
  Context ctx = null;
 
 
 
  Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
                                                                                p.put(Context.PROVIDER_URL, "xx.xx.xx:50004");
   p.put(Context.SECURITY_PRINCIPAL, "user name");
   p.put(Context.SECURITY_CREDENTIALS, "password");
 
  try {
 
     ctx = new InitialContext(p );
     
   Object o=  ctx.lookup("JNDI name");
   
   
   SesionBeanHome objSesionBeanHome =(SesionBeanHome )o;
    
    System.out.println(objSesionBeanHome .findAll().size());
   
    
  } catch(Exception ne) {
System.out.println(ne);
      
  } finally {
    try {
     ctx.close();
    } catch (Exception e) {
   System.out.println(e);
    }
  }

  
  
  
  
  
  
 }
}


regards,

naga

Former Member
0 Kudos

<i>1. The procedure mentions that I need to "Select the EJB application for which you want to create a client JAR from the Deployed Components list." Where do I do this? In the VisualAdministrator tool?</i>

Yes. If you check the link for Runtime administration [http://help.sap.com/saphelp_nw04/helpdata/en/25/1d353e39011a38e10000000a114084/content.htm ], you'll get more clarity on this.

<i>At the end, the procedure indicates that to be able to do this you have to set a classpath reference from the Java client application to this client JAR. Does this mean I have to add this JAR as an "external JAR", similar to how I added the sapj2eeclient.jar and ejb20.jar?</i>

Yes. Once the jar file gets generated, you can copy it to the workstation on which you have your IDE, and the set your classpath to refer to this library also. If you are using a DC based setup then the procedure might differ and will involve use of concepts like External library DC & Used DCs.

Regards,

Amol

Former Member
0 Kudos

Amol,

Thanks for the reply. I'm still a bit unclear on what I need to do.

Does this generated client jar need to be referenced at compile time? Do I need to add it to my Java Build Path? Or does it just need to be in a classpath location fro runtime?

And second, does this client jar replace the need to add the EJB jar to the Java Build Path for the standalone JAVA application? The client jar does not seem to have enough classes in it to support compile time.

Thanks,

Kevin

Former Member
0 Kudos

>>Does this generated client jar need to be referenced at compile time? Do I need >>to add it to my Java Build Path? Or does it just need to be in a classpath >>location fro runtime?

You need to have it on the build path during compile time and in the classpath at the runtime. If you remember the good old days of generating stubs for EJBs and put them in classpath, then its the same thing.

>>And second, does this client jar replace the need to add the EJB jar to the Java >>build Path for the standalone JAVA application? The client jar does not seem to >>have enough classes in it to support compile time.

Could you please elaborate?

Former Member
0 Kudos

Thank you for the information. Here are more details about my remaining question.

The generated client jar does not contain the classes I need at build time. It only contains classes such as EJBCollection, EJBEnumeration, MultipleFinderKey, PortalRoleServices_Stub, and PortalRoleServicesHome_Stub. The classes in the jar starting with "PortalRoleServices" seem to be generated based on my custom EJB class, named PortalRoleServices. The others seem standard, regardless of EJB.

This generated client jar jar was missing the "PortalRoleServices" and "PortalRoleServicesHome" classes. For these missing classes, it seems that I have to add the JAR from EJB itself to the buildpath of the standalone JAVA application.

Is the generated client jar supposed to contain all of these classes for my custom EJB?

If the generated client jar does not contain all of these classes, what is the correct way to add the remaining EJB classes to my standalone java application for compile and run time?

Thank you,

Kevin