Skip to Content
0
Former Member
Nov 19, 2009 at 05:11 PM

Call UniversalWorklistService from CAF

48 Views

<p>I'm having to resort to asking this question after having spent a couple of days trying to figure this out, looking through SDN articles and tutorials, Javadoc, etc.</p>

<p>What I am trying to do is connect to the UWL service from a CAF application service in order to use some of the UWL API calls from within another application. I've seen many other people do this from Web Dynpro, or Portal, or some other way so before people try and point me to articles for those - please don't. I'm looking for anyone who has actually got this working.</p>

<p>The basic code is as follows:</p>

<code>

Hashtable env = new Hashtable();<br>

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sapportals.portal.prt.registry.PortalRegistryFactory");<br>

Context ctx = new InitialContext(env);<br>

IUWLService uwlService = (IUWLService)ctx.lookup("/broker/services/"+IUWLService.ALIAS_KEY);<br>

</code>

<p>I have tried several ways to get this to work with the relevant jar files as dependencies but it comes down to this:<br>

<b>1.</b> Reference the UWLJWF SC from my SC and refer the ejbModule DC to "tc/kmc/bc.uwl/api".<br>

<b>2.</b> Retrieve all required jars (<em>bc.uwl.service.api_api.jar, bc.uwl.service.api_core.jar, com.sap.netweaver.bc.uwl_core.jar, com.sap.portal.runtime.application.rfcengine_api.jar, prtapi.jar, prtconnection.jar</em>) bundle into an External Library type DC and deploy with my composite application.</p>

<p>In the case of <b>1</b>: the error is <em>"<code>java.lang.NoClassDefFoundError: com/sap/netweaver/bc/uwl/IUWLService</code>"</em> which implies to me that the classloader for the server is not picking it up from somewhere yet the project builds fine in NWDS as the reference exists to UWLJWF. That particular SC is also deployed on the server, as I believe is standard.</p>

In the case of 2: the error is "java.lang.ClassCastException: class com.sap.netweaver.bc.uwl.core.portal.UWLPortalService:WCE_PRIVATE_CL_sap.com/com.sap.netweaver.bc.uwl[at]com.sap.engine.boot.loader.ResourceMultiParentClassLoader[at]75605aa1[at]alive incompatible with interface com.sap.netweaver.bc.uwl.IUWLService:demo.sap.com/uwltest~ear[at]com.sap.engine.boot.loader.ResourceMultiParentClassLoader[at]27a3bd7[at]alive"> which doesn't make much sense to me except that there is some difference between the instances of the classloaders that is causing the issue.

<p>If I modify the code to specifically cast:<br>

<code>UWLPortalService uwlPortalService = (UWLPortalService)ctx.lookup("/broker/services/"+IUWLService.ALIAS_KEY);</code><br>

... I get a similar class cast exception except the error is "can't cast UWLPortalService to UWLPortalService"... pretty much the same.</p>

<hr>

<p>As an alternative I've tried to connect from just a standard Java app within eclipse referencing the appropriate SAP runtime libraries and those mentioned above. Connecting to the context is much the same except to provide a port number:</p>

<code>

Hashtable env = new Hashtable();<br>

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");<br>

env.put(Context.PROVIDER_URL, "*HOST*:50004");<br>

env.put(Context.SECURITY_AUTHENTICATION,"simple");<br>

env.put(Context.SECURITY_CREDENTIALS, "**********");<br>

env.put(Context.SECURITY_PRINCIPAL, "**********");<br>

Context ctx = new InitialContext(env);<br>

</code>

<p>Using this code I can connect to the InitialContextFactory and list all bindings that exist at root level. However, if I change the initial context factory to <em>com.sapportals.portal.prt.registry.PortalRegistryFactory</em> and do a similar search or specifically try to lookup "/broker/services/UniversalWorklistService", I just get NULL.</p>

<p>So I'm not sure the port number is the same for both the factories. Has anyone tried this and can tell me what the port should be? For InitialContextFactoryImpl it appears to work with 50004 but not for the PortalRegistryFactory, although strangely no exceptions are thrown.</p>

<hr>

<p>Thanks in advance to anyone who might be able to shed some light. As I've already said, please don't just point me at snippets of code for WDJ tutorials.</p>