Today we’ll talk about remote client creation which invokes our HelloWorldService from part 1.
Little more info about this sample:
Most common scheme of creating and invoking authorized service remotely consists of:
Below is full source code of remote client:
package com.client.example;
import com.emc.documentum.fs.datamodel.core.context.RepositoryIdentity;
import com.emc.documentum.fs.rt.ServiceException;
import com.emc.documentum.fs.rt.context.ContextFactory;
import com.emc.documentum.fs.rt.context.IServiceContext;
import com.emc.documentum.fs.rt.context.ServiceFactory;
import com.service.example.client.IHelloWorldService;public class HelloWorldClient
{
public static void main(String[] args)
{
String moduleName = “example”;
String contextRoot = “http://localhost:7001/services/”;ContextFactory contextFactory = ContextFactory.getInstance();
IServiceContext context = contextFactory.newContext();RepositoryIdentity repoId = new RepositoryIdentity();
repoId.setRepositoryName(”repositoryName”);
repoId.setUserName(”userName”);
repoId.setPassword(”password”);
repoId.setDomain(”");context.addIdentity(repoId);
try
{
IServiceContext registeredContext = contextFactory.register(context, moduleName, contextRoot);
ServiceFactory serviceFactory = ServiceFactory.getInstance();
IHelloWorldService service = serviceFactory.getRemoteService(IHelloWorldService.class, registeredContext, moduleName, contextRoot);
String response = service.sayHello(”John”);
System.out.println(”response = ” + response);
}
catch (ServiceException e)
{
e.printStackTrace();
}
}
}
I’ve updated helloworldservice.zip with remote client source code.
Next part of .NET remote client will be ready soon.
9 Responses
DFS tutorial
January 17th, 2008 at 10:14 am
1[…] Part 2 - Java client creation […]
sylvia
January 23rd, 2008 at 9:33 am
2hi me again..
I deployed example.ear to weblogic/DM6 server and I am able to see
three web services HelloWorldService, AgentService, ContextRegistryService active in
http://10.200.65.193:7001/services/example/HelloWorldService
however when I run the client application
I got
[javac] Compiling 1 source file to C:\emc-dfs-sdk-6.0\samples\HelloWorldService\build\classes
run.client:
[echo] Run the Test Solution (Service + Remote Client) remote client
[java] com.emc.documentum.fs.rt.ServiceRegistrationException: Failed registering service context to: “http://10.200.65.193:7001/services/example/”.
[java] at com.emc.documentum.fs.rt.context.impl.RemoteContextRegistry.register(RemoteContextRegistry.java:58)
[java] at com.emc.documentum.fs.rt.context.ContextFactory.register(ContextFactory.java:106)
[java] at com.emc.documentum.fs.rt.context.ContextFactory.register(ContextFactory.java:95)
[java] at com.client.example.HelloWorldClient.main(HelloWorldClient.java:32)
[java] Caused by: javax.xml.ws.soap.SOAPFaultException: java.lang.NoClassDefFoundError
[java] at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:160)
[java] at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:83)
[java] at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:248)
[java] at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:212)
[java] at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:105)
[java] at $Proxy26.register(Unknown Source)
[java] at com.emc.documentum.fs.rt.context.impl.RemoteContextRegistry.register(RemoteContextRegistry.java:50)
[java] … 3 more
run:
BUILD SUCCESSFUL
Total time: 4 seconds
Please help..
admin
January 23rd, 2008 at 6:50 pm
3Sylvia,
Can you see if there are any server side exceptions in the time of registering service context ? In other words do you get client side or server side exception ?
sylvia
January 23rd, 2008 at 11:18 pm
4craig,
good point! for some reason I got a different error today (authentication failed).So I checked the server side exception, and found it was looking for docbroker on 192.168.0.100:1489. After some search, it was hard coded somewhere in weblogic’s dfc.properties… I probably had missed something during installation. but anyway. thank you, it’s working now! yay!
sakthidassan
February 11th, 2008 at 3:35 pm
5craig
Having the above code as a model i created a custom model. I was able to generare the ear file for deploying in the server. When I ran the client in Weblogic portal server 10. i got the following exception in the client side.
com.emc.documentum.fs.rt.ServiceRegistrationException: Failed registering servic
e context to: “http://192.168.1.81:7001/services/fff/”.
at com.emc.documentum.fs.rt.context.impl.RemoteContextRegistry.register(
RemoteContextRegistry.java:58)
at com.emc.documentum.fs.rt.context.ContextFactory.register(ContextFacto
ry.java:106)
at com.emc.documentum.fs.rt.context.ContextFactory.register(ContextFacto
ry.java:95)
at com.emc.documentum.fs.doc.samples.client.testmyportfolio.testmyportfo
li(testmyportfolio.java:60)
at jsp_servlet.__index._jspService(__index.java:99)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:226)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:124)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:283)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(Servlet
StubImpl.java:391)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:309)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:3370)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
ervletContext.java:2117)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
ontext.java:2023)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
ava:1359)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
Caused by: javax.xml.ws.soap.SOAPFaultException: Failed to read a response: java
x.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: Unable to create an instance of com.emc.docu
mentum.fs.datamodel.core.context.Identity
- with linked exception:
[java.lang.InstantiationException]]
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.jav
a:160)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilde
r.java:83)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.
java:248)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.
java:212)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:105)
at $Proxy113.register(Unknown Source)
at com.emc.documentum.fs.rt.context.impl.RemoteContextRegistry.register(
RemoteContextRegistry.java:50)
… 19 more
===============================================
In the server side It threw the Following exception
Failed to read a response: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: Unable to create an instance of com.emc.docu
mentum.fs.datamodel.core.context.Identity
- with linked exception:
[java.lang.InstantiationException]]
Any Suggestion
mthx
February 15th, 2008 at 2:26 am
6hi,
I have succeeded to deploy the example, but running the client generatess an exception:
C:\Download\DFS\6.0\emc-dfs-sdk-6.0\samples\HelloWorldService>ant run.client
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.5.0_13\lib\tools.jar
Buildfile: build.xml
[echo] EMC DFS SDK 6.0 home is ‘../..’
[echo] This project home is ‘C:\Download\DFS\6.0\emc-dfs-sdk-6.0\samples\HelloWorldService’–beware spaces in this path (JDK issues).
run.client:
[echo] Run the Test Solution (Service + Remote Client) remote client
[java] java.lang.NoClassDefFoundError: com/client/example/HelloWorldClient
[java] Exception in thread “main”
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 1 second
C:\Download\DFS\6.0\emc-dfs-sdk-6.0\samples\HelloWorldService>
I can’t spot the problem.
Do you have any suggestions ??
best regards
Martin
karthick
February 18th, 2008 at 9:55 am
7Hi craig,
I have deployed helloworld dfs service in weblogic server.i could successfully execute it from eclipse environment.when i tried to invoke from jsp page it throws a
server side exception as
—————————-
Failed to read a response: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: Unable to create an instance of com.emc.documentum.fs.datamodel.
core.context.Identity
- with linked exception:
[java.lang.InstantiationException]]
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:241)
at com.sun.xml.ws.server.sei.SEIInvokerPipe.process(SEIInvokerPipe.java:97)
at com.sun.xml.ws.protocol.soap.ServerMUPipe.process(ServerMUPipe.java:62)
at com.sun.xml.ws.server.WSEndpointImpl$1.process(WSEndpointImpl.java:139)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:151)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:223)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:97)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:161
)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.
java:225)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletC
ontext.java:3214)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1
983)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: Unable to create an instance of com.emc.documentum.fs.datamodel.
core.context.Identity
- with linked exception:
[java.lang.InstantiationException]]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(Unmarshal
lerImpl.java:396)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.jav
a:335)
at com.sun.xml.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:84)
at com.sun.xml.bind.api.Bridge.unmarshal(Bridge.java:197)
at com.sun.xml.bind.api.Bridge.unmarshal(Bridge.java:189)
at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$DocLit.readRequest(EndpointArgumentsBu
ilder.java:462)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:239)
… 22 more
Caused by: javax.xml.bind.UnmarshalException: Unable to create an instance of com.emc.documentum.fs.
datamodel.core.context.Identity
- with linked exception:
[java.lang.InstantiationException]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingCo
ntext.java:556)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:199)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.createInstance(Unmarshallin
gContext.java:523)
at com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.startElement(StructureLoader.jav
a:145)
at com.sun.xml.bind.v2.runtime.unmarshaller.XsiTypeLoader.startElement(XsiTypeLoader.java:37
)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(Unmarshalling
Context.java:402)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingC
ontext.java:380)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStrea
mConnector.java:208)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.j
ava:142)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.jav
a:333)
… 27 more
Caused by: javax.xml.bind.UnmarshalException: Unable to create an instance of com.emc.documentum.fs.
datamodel.core.context.Identity
- with linked exception:
[java.lang.InstantiationException]
… 37 more
Caused by: java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExcept
ionConstructorAccessorImpl.java:30)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at com.sun.xml.bind.v2.ClassFactory.create0(ClassFactory.java:83)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.createInstance(ClassBeanInfoImpl.java:221)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.createInstance(Unmarshallin
gContext.java:517)
… 34 more
and client side exception as:
——————————–
com.emc.documentum.fs.rt.ServiceRegistrationException: Failed registering servic
e context to: “http://192.168.1.76:7001/services/example/”.
at com.emc.documentum.fs.rt.context.impl.RemoteContextRegistry.register(
RemoteContextRegistry.java:58)
at com.emc.documentum.fs.rt.context.ContextFactory.register(ContextFacto
ry.java:106)
at com.emc.documentum.fs.rt.context.ContextFactory.register(ContextFacto
ry.java:95)
at com.client.example.HelloWorldClient.hello(HelloWorldClient.java:29)
at jsp_servlet.__index._jspService(__index.java:101)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:226)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:124)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:283)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(Servlet
StubImpl.java:391)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:309)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:42)
at org.apache.beehive.netui.pageflow.PageFlowPageFilter.runPage(PageFlow
PageFilter.java:385)
at org.apache.beehive.netui.pageflow.PageFlowPageFilter.doFilter(PageFlo
wPageFilter.java:284)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:3368)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
ervletContext.java:2117)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
ontext.java:2023)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
ava:1359)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
Caused by: javax.xml.ws.soap.SOAPFaultException: Failed to read a response: java
x.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: Unable to create an instance of com.emc.docu
mentum.fs.datamodel.core.context.Identity
- with linked exception:
[java.lang.InstantiationException]]
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.jav
a:160)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilde
r.java:83)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.
java:248)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.
java:212)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:105)
at $Proxy74.register(Unknown Source)
at com.emc.documentum.fs.rt.context.impl.RemoteContextRegistry.register(
RemoteContextRegistry.java:50)
… 23 more
i need ur help
thanks
karthick s
mthx
February 19th, 2008 at 12:10 pm
8Hi again
I think I have tracked down the problem to be something in the build.xml - file around the ‘compile’ - target, as running ‘ant compile’ yields same error-message.
I then tracked down the javac.exe functionality, and this seems to works, as I can ‘compile’ the client-program by hand, if I add the needed classes to ClassPath.
Any hints ??
polekt
March 6th, 2008 at 11:14 pm
9What should CLASSPATH be to run HelloWorldClient once compiled? I want to run it from a command prompt on my local PC to access the remote service on a Windows 2003 server.
I’m getting the following when I try to run it:
Exception in thread “main” java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
at HelloWorldClient.main(HelloWorldClient.java:15)
Thanks, Tom
polekt@wyeth.com
484-865-5696
RSS feed for comments on this post · TrackBack URI
Leave a reply
You must be logged in to post a comment.
Categories
Archives
Links
Meta
Calendar
Recent Entries
Recent Comments
Most Commented
DFS Notes is proudly powered by WordPress - BloggingPro theme by: Design Disease