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

JCA to SAP

Hi,

Can someone help me to get a connection to a SAP system using JCA.

I'm using WAS 6.4 SP9.

The code below is the code I used.

Hashtable env1 = new Hashtable();

env1.put(

Context.INITIAL_CONTEXT_FACTORY,

"com.sap.engine.services.jndi.InitialContextFactoryImpl");

env1.put(Context.PROVIDER_URL, "yar2:50004");

Context context = new InitialContext(env1);

Object obj = (Object)context.lookup("deployedAdapters/SAPFactory");

int i = 43;

ConnectionFactory connectionFactory = (ConnectionFactory) obj;

The code below works. But I get a "ClassCastException" when I want to change the object to a connectionFactory.

On my build path the following jar is included.

Connector.jar.

I wan't to use this code in a EJB.

Help

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 22, 2005 at 01:52 PM

    Hi Edward,

    did you see this page from the JCA dev manual: http://help.sap.com/saphelp_nw04/helpdata/en/23/40e6df7eec43a486652d1f626bf6fa/frameset.htm ?

    If you are about to get the connection from an EJB, then you can declare a resource reference to the connection factory and look that up relative to the java:comp/env context.

    Hope that helps!

    Message was edited by: Ivaylo Ivanov

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 22, 2005 at 03:32 PM

    Thanx Ivaylo Ivanov,

    I tried that but with the following result.

    "NameNotFoundException".

    The ejb-jar.xml looks like below

    <session>

    <ejb-name>BackendServiceBean</ejb-name>

    <home>be.something.service.BackendServiceHome</home>

    <remote>be.something.service.BackendService</remote>

    <ejb-class>be.something.service.BackendServiceBean</ejb-class>

    <session-type>Stateless</session-type>

    <transaction-type>Container</transaction-type>

    <resource-ref>

    <res-ref-name>eis/SAPJRAFactor</res-ref-name>

    <res-type>javax.resource.cci.ConnectionFactory</res-type>

    <res-auth>Container</res-auth>

    </resource-ref>

    </session>

    I have to configure something more to get the mapping working from my EJB context to the right EIS JCA connector. How do I do that?

    Thanx

    Message was edited by: Edward van der Kust

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Edward,

      first of all, did you check (as Stephan suggested) if this is a typing error in the <res-ref-name> tag declaration?

      Anyway, to find out what the correct lookup string is, you could have a look at the JNDI tree on your server. To do that, connect the Visual Administrator to the server and open the JNDI Registry Service on the server node. Under the Runtime tab on the lefthand side browse the JNDI tree (it should look like the one below):

      ejbContexts [Context]

      sap.com [Context]

      _________<your application> [Context]

      _____________sap.com [Context]

      _________________<your application> [Context]

      _____________________BackendServiceBean [Context]

      ________________________<b>java:comp</b> [Context]

      ....

      ....

      __________________________<b>env</b> [Context]

      _____________________________<b>eis</b> [Context] -- this is based on the info from the ejb-jar.xml you pasted!

      _________________________________<b>SAPJRAFactor</b> -- this is based on the info from the ejb-jar.xml you pasted!

      Well, then the lookup string you need to use is "java:comp/env/eis/SAPJRAFactor".

      Hope it's much crear now.

  • author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2005 at 11:19 AM

    Thanx Ivaylo Ivanov,

    I now do get a instance ConnectionFactory but now I have to configure it to get the right connection from the Factory. This is in someway possible by implementing the Interface ConnectionSpec.

    Is there a implemenation of this Interface. Or how can I configure this specific connection.

    Can U help me?

    Message was edited by: Edward van der Kust

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2005 at 09:40 AM

    Thanx Vladimir Pavlov,

    But unfortunately it didn't help me any further. I can't set the properties.

    Of the connection and I can't find any implementation of the Interface ConnectionSpec.

    The jar file you mentioned was deprecated so I don't want to use that one.

    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.