cancel
Showing results for 
Search instead for 
Did you mean: 

JCo DestinationDataProvider Issues

Former Member
0 Kudos

Hi All:

I have a Java application using JCo 3.05 to connect to different SAP systems from the same client application.

public Connection(SapSystem system) {

DestDataProvider myProvider = new DestDataProvider(system);

com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(myProvider);

try {

dest = JCoDestinationManager.getDestination(SAP_SERVER);

repos = dest.getRepository();

} catch (JCoException e) {

throw new RuntimeException(e);

}

}

When switching to different SAP system, I got error message:

Exception in thread "main" java.lang.IllegalStateException: DestinationDataProvider already registered: com.pepsico.dctm.sap.DestDataProvider.

If unregister the destination data provider, I got new error message:

Exception in thread "main" java.lang.RuntimeException: Not possible to receive function.

at com.pepsico.dctm.sap.Connection.getFunction(Connection.java:79)

Does anyone know how to register and unregister the destination data provider in multiple destination data provider environment?

Thanks,

Brian

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

To the best of my knowledge you can only register a single DestinationDataProvider and any attempt to register multiple will result in the exception you've listed. E.g. if you check the API help for Environment.registerDestinationDataProvider():

Registers a provider for destination data.

Parameters:

    provider - the class that provides DestinationData

Throws:

    java.lang.IllegalStateException - if a provider is already registered

An approach that works fine for me is to use a [singleton|http://en.wikipedia.org/wiki/Singleton_pattern] for my custom class implementing the DestinationDataProvider, which has a register method that only registers a provider if that didn't happen before (and it wasn't unregistered).

For JCo 3.0.5 deregistering works fine for me, so I cannot comment on why you're getting the error you're seeing. In principle I'd wonder though if you really want to unregister your provider (usually I'd expect one would like to keep the one self-defined instance registered all the time).

If nobody else can explain the error you're getting I'd recommend to set a higher trace level as described in the API documentation:

JCo's tracing mechanism can be turned on by setting the following java environment properties at startup:

-Djco.trace_level=N (where 0 u2264 N u2264 10 with 10 = most detailed trace)

Cheers, harald