cancel
Showing results for 
Search instead for 
Did you mean: 

Using WebDynpro JCo client connection in session bean?

0 Kudos

Hi

I would like to "piggy-back" the WebDynpro IWDJCOClientConnection functionality to establish a JCo connection from a session bean. The code is essentially as follows:

IWDJCOClientConnection cc =

WDSystemLandscape.getJCOClientConnection(<name>);

JCO.Client connection = cc.getClient();

However, the following exception is thrown:

java.lang.NullPointerException

at com.sap.tc.webdynpro.serverimpl.wdc.um.ClientUserFactory.getCurrentUser(ClientUserFactory.java:95)

at com.sap.tc.webdynpro.services.sal.um.api.WDClientUser.getCurrentUser(WDClientUser.java:63)

at com.sap.tc.webdynpro.serverimpl.core.sl.AbstractJCOClientConnection.checkPoolEntry(AbstractJCOClientConnection.java:277)

at com.sap.tc.webdynpro.serverimpl.core.sl.AbstractJCOClientConnection.getClient(AbstractJCOClientConnection.java:392)

My EJB is not part of a WebDynpro application, so my guess is that the exception is caused because there is no "current WebDynpro user" when this code is executed.

Can anyone confirm this? And more interestingly: can I do anything to make this work?

Best regards,

Thorsten

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

I solved this myself:

The exception is only thrown if the JCo pool has not yet been created. Testing the connection from the WD content administrator creates the pool and the exception does not recur. (Of course, this only works until the next restart, so this is not a useful workaround.) However, the WD API can be cheated into creating the pool without a WD user by simply binding an ITask to the TaskBinder:

import com.sap.tc.webdynpro.clientserver.task.Task;

import com.sap.tc.webdynpro.services.task.TaskBinder;

...

if (TaskBinder.getCurrentTask() == null) {

Task task = new Task();

TaskBinder.bindTaskToThread(task);

}

Since the TaskBinder and Task classes are not part of the published WD API, this might stop working at some point, but that's life I guess.

- Thorsten