Skip to main content
1-Visitor
October 27, 2014
Question

Remote method server exception

  • October 27, 2014
  • 2 replies
  • 4148 views

Hi!

I want to set state for the WTDocument by java code through rms like this:

RemoteMethodServer rms = RemoteMethodServer.getDefault();

rms.setUserName("***");

rms.setPassword("***");

WTChangeOrder2 cho = (WTChangeOrder2)( new ReferenceFactory()).getReference("VR:wt.change2.WTChangeOrder2:16423065").getObject();

wt.fc.QueryResult qr = wt.change2.ChangeHelper2.service.getChangeablesBefore(cho);

wt.doc.WTDocument wtd = null;

wt.fc.QueryResult qr2 = new wt.fc.QueryResult();

while (qr.hasMoreElements())

{

wtd = (wt.doc.WTDocument)qr.nextElement();

Class argTypes[] = {wt.lifecycle.LifeCycleManaged.class, wt.lifecycle.State.class};

Object argValues[] = {(wt.lifecycle.LifeCycleManaged)wtd, wt.lifecycle.State.toState("CANCELLED")};

rms.invoke("setState", wt.lifecycle.LifeCycleServerHelper.service.getClass().getName(), null, argTypes, argValues);

}

But I have an exception like this:

WARNING: The ManagerService is not initialized! This can be caused by:

1) Attempting to invoke a server only method from a remote client

2) Attempting to invoke a method on a service from the constructor or static initializer of another service

What is wrong?

2 replies

12-Amethyst
October 27, 2014

You need to do this way.

RemoteMethodServer rms = RemoteMethodServer.getDefault();

rms.setUserName("***");

rms.setPassword("***");

rms.invoke("yourMethodName", Yourclass.class.getName,null,argTypes,argValues);

// Put your logic inside your method

public yourMethodName() {

WTChangeOrder2 cho = (WTChangeOrder2)( new ReferenceFactory()).getReference("VR:wt.change2.WTChangeOrder2:16423065").getObject();

wt.fc.QueryResult qr = wt.change2.ChangeHelper2.service.getChangeablesBefore(cho);

wt.doc.WTDocument wtd = null;

wt.fc.QueryResult qr2 = new wt.fc.QueryResult();

while (qr.hasMoreElements())

{

wtd = (wt.doc.WTDocument)qr.nextElement();

State st=State.toState(String state);

LifeCycleHelper.service.setLifeCycleState(wtd,st);

}

}

Let me know if you need further detail

1-Visitor
October 27, 2014

Vino, I have changed the method to the LifeCycleHelper.service.setLifeCycleState(wtd,st) and now it's working fine. Please correct me. If I want to use your sample, so I should have my custom class with the method on the server side?

12-Amethyst
October 28, 2014

Yes that's right. You should have custom class and from that you need to invoke that method of any other class or on same class server side. As yogesh said your custom class should implement RemoteAccess.

1-Visitor
October 27, 2014

The class you call with rms.invoke() needs to extend StandardManager and implement RemoteAccess, Serializable. I guess LifeCycleServerHelper does not satisfy that criteria and cannot be called like that. As Vino said, write your own class containing yourMethodName() inside a class that extends StandardManager and implements RemoteAccess, Serializable.