Closed nlamblin closed 2 years ago
Your server starts on port 0 (so probably doesn't start at all or there's some issue with port printing. I think it's somehow issue with giving the host, too, as this example works fine: https://github.com/eficode/JavaFXLibrary/blob/master/src/main/java/JavaFXLibraryRemoteServer.java
In my demo at Robocon I started that with Maven: https://github.com/Hi-Fi/rf-remote-library-demos/tree/master/basic_data_handling/src/java/pom.xml
I updated the Java code with the first example you gave :
import org.robotframework.javalib.library.AnnotationLibrary;
public class KeywordRemoteLibrary extends AnnotationLibrary {
public static void main(String[] args) throws Exception {
String host = "127.0.0.1";
int port = 64494;
KeywordRemoteLibraryServer.configureLogging();
KeywordRemoteLibraryServer server = new KeywordRemoteLibraryServer(host, port);
server.putLibrary("/RPC2", new KeywordRemoteLibrary());
server.start();
}
}
--------------------------------------------------------------------------------------------------------------
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.robotframework.remoteserver.RemoteServer;
import org.robotframework.remoteserver.logging.Jetty2Log4J;
public class KeywordRemoteLibraryServer extends RemoteServer {
public KeywordRemoteLibraryServer(String host, int port) {
super(host, port);
}
private static Log log = LogFactory.getLog(RemoteServer.class);
public static void configureLogging() {
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.FATAL);
org.eclipse.jetty.util.log.Log.setLog(new Jetty2Log4J());
LogFactory.releaseAll();
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.Log4JLogger");
log = LogFactory.getLog(RemoteServer.class);
}
}
However, I'm still facing the same issue. Could you please help me ? Thank you.
When I access to 127.0.0.1/64494
, I have this:
And netstat -ano
command :
Proto Local Address Foreign Address State PID
TCP 127.0.0.1:64494 0.0.0.0:0 LISTENING 92432
So, I supposed that the server is up?
Robotframework error during robot execution : Getting keyword names from library 'Remote' failed: Calling dynamic method 'get_keyword_names' failed: Connecting remote server at http://127.0.0.1:64494 failed: <Fault 0: 'Failed to invoke method get_keyword_names in class org.robotframework.remoteserver.servlet.ServerMethods: java.lang.RuntimeException'>
Stacktrace on the server:
java.lang.RuntimeException: null
at org.robotframework.remoteserver.library.DynamicApiRemoteLibrary.getKeywordNames(DynamicApiRemoteLibrary.java:54) ~[jrobotremoteserver-4.0.0.jar:?]
at org.robotframework.remoteserver.servlet.ServerMethods.get_keyword_names(ServerMethods.java:53) ~[jrobotremoteserver-4.0.0.jar:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
...
So, I supposed that connection is done correct?
Thank you very much for your help.
Update : I added this and problem seems to be fixed.
static List<String> includePatterns = new ArrayList<String>() {{
add("keywords/*.class");
}};
public KeywordRemoteLibrary() {
super(includePatterns);
}
However, I still have error on RED IDE. Indeed it is still mentioned that Remote is not connected. But I think that it is a RED issue correct ?
With jrobotremoteserver you have to have trailing / at the end, as otherwise it defaults to /RPC2. But with browser you can see, that remote should end with /RPC2 as library is published to that path.
Haven't used RED so don't know if it reads remote documentation like that.
No comments for long time -> closing.
I'm trying to implement
JavaLibCore
andRemoteServer
to use Java method in robotframework as keywords.Could you please help me to find a way to fix below error? Thank you a lot.
Java code
Keyword class
Main class
Eclipse console
Robotframework code
Error However I'm facing an error on robotframework script: