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

SAP NW CE: Establishing an RFC Connection Using an Existing Destination

Hello,

I want to establishing an RFC connection using an existing destination.

My code:

private static final String USER = "Administrator";
	private static final String PASSWORD = "********";
	private static final String SAP_NAMING_PROVIDER_URL = "vm-sapnwce:50004";
	private static final String SAP_INITIAL_CONTEXT_FACTORY_IMPL = "java.naming.factory.initial";

	public List<Person> findPerson(String employeeID, String name,
			Date dateOfBirth) {

		/*
		 * JNDI service naming environment properties initialization
		 */
		Properties ctxProp = new Properties();
		ctxProp.put(Context.INITIAL_CONTEXT_FACTORY,
				SAP_INITIAL_CONTEXT_FACTORY_IMPL);
		ctxProp.put(Context.PROVIDER_URL, SAP_NAMING_PROVIDER_URL);
		ctxProp.put(Context.SECURITY_PRINCIPAL, USER);
		ctxProp.put(Context.SECURITY_CREDENTIALS, PASSWORD);

		/*
		 * Create a JNDI API InitialContext object.
		 */
		Context jndiContext = null;
		try {
			jndiContext = new InitialContext(ctxProp);
		} catch (NamingException e) {
			System.out.println("Could not create JNDI API" + "context: "
					+ e.toString());
			e.printStackTrace();
			System.exit(1);
		}
		
		/*
		 * Create a JNDI API InitialContext object.
		 */
		DestinationService dstService = null;
		RFCDestination dst = null;
		try {
			dstService = (DestinationService) jndiContext.lookup(DestinationService.JNDI_KEY);
			if (dstService == null)
				throw new NamingException("Destination Service not available");
			dst = (RFCDestination) dstService.getDestination("RFC",
					"TDE");
		} catch (NamingException e1) {
			e1.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (DestinationException e) {
			e.printStackTrace();
		}		
		Properties jcoProperties = dst.getJCoProperties();

		/*
		 * Establishing a direct connection
		 */
		JCO.Client jcoClient = JCO.createClient(jcoProperties);
		jcoClient.connect();
...

But if I execute the method the jstart.EXE in sapmmc go in status "Some processes running" and the AS restarts.

Error in NWDS:

Nov 20, 2007 1:46:48 PM [1195562808569]:Error   : Thread[Thread-10,5,main]      ...rvices.rmi_p4.Parser.newRequest(ClientConnection):    The possible problem is that there is no available working correctly server node. Check your working servers
com.sap.engine.services.rmi_p4.P4ConnectionException: Error. Check your available working servers.
	at com.sap.engine.services.rmi_p4.P4ObjectBrokerClientImpl.getException(P4ObjectBrokerClientImpl.java:630)
	at com.sap.engine.services.rmi_p4.P4ObjectBrokerClientImpl.getException(P4ObjectBrokerClientImpl.java:612)
	at com.sap.engine.services.rmi_p4.Parser.newRequest(Parser.java:143)
	at com.sap.engine.services.rmi_p4.ClientConnection.run(ClientConnection.java:390)
	at java.lang.Thread.run(Thread.java:595)

If I execute the methode with the following code instead of the code above I can execute the method without any problems:

JCO.Client jcoClient = JCO.createClient("011", "Restle", "********",
"en", "sma82", "01");
jcoClient.connect();

Regards,

Armin

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 27, 2007 at 06:30 PM

    Hi armin,

    did you debugged your method and watched your jcoProperties, before creating the client?

    Regards, Jens

    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.