Support #205

Running Simon Client in Tomcat Container

Added by LolaAmerica 7 months ago. Updated 7 months ago.

Status:ClosedStart date:05/22/2017
Priority:NormalDue date:
Assignee:achristian% Done:

0%

Category:unknownSpent time:0.35 h
Target version:1.3.1

Description

Somebody has a solution to run a SIMON Client on Tomcat Container and has successfully contected to a server outside of the Tomcat Container (eg . the server is running on another machine.
I tried it with the simon Hello-World example, but i got the Excetpion:

java.lang.NoClassDefFoundError: de/root1/simon/exceptions/LookupFailedException

Can anyone help?

RunsOnServerInTomcat.zip (34.6 KB) LolaAmerica, 05/23/2017 09:17 AM

Info_for_SimonDEV.zip (35.3 KB) LolaAmerica, 05/23/2017 09:19 AM

History

#1 Updated by achristian 7 months ago

This must be a classpath issue. I have personally no experience with tomcat+simon. Either you have to put simon jar to your webapp, or to tomcat lib folder. Depends on what you're trying to do.

If simon jar is already in correct folder, there might be an issue with the classloader.

Sounds like you followed a kind of tutorial. Can you provide a link to this?

#2 Updated by LolaAmerica 7 months ago

thanks, i am now a step nearer to the solution. I copied the simon jar to the WebContent->WEB-INF->lib folder and he founds the missing classes. But now i got the following error:

de.root1.simon.exceptions.LookupFailedException: Not able to load remote interfaces. Maybe you need to specify a specific classloader via Lookup#setClassLoader()?

Then i copied the Interfaces to the same above directory, but still the same error.

#3 Updated by LolaAmerica 7 months ago

Eclipse saved havn't delete an old package. This was the cause for the before Error. I Resetup the project and the before Errormessage is gone.

But now i got the follwoing:
javax.servlet.ServletException: com.sun.proxy.$Proxy14 cannot be cast to de.test.simon.ServerInterface
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

But i use the same source as in the helloworld example. It runs on as Java Application but not on the Tomcat Server 8.

Any idea?

The Code of the Client is the follwing:

  public static void runClient() throws IOException, LookupFailedException, EstablishConnectionFailed {

        // create a callback object
        ClientCallbackImpl clientCallbackImpl = new ClientCallbackImpl();

        // 'lookup' the server object
        Lookup nameLookup = Simon.createNameLookup("127.0.0.1", 11222);

        ServerInterface server = (ServerInterface) nameLookup.lookup("server");

        // use the serverobject as it would exist on your local machine
        server.login(clientCallbackImpl);

        // do some more stuff
        // ...

        // and finally 'release' the serverobject to release to connection to the server
        nameLookup.release(server);
    }

#4 Updated by achristian 7 months ago

Please be more precise:

  • What runs on tomcat?
  • Which Tomcat version? Which Java version? Which OS?
  • What runs outside tomcat?
  • How does the code that causes the issue exactly look like? --> Short reproducer sample project
  • If you face exceptions, please show complete stacktrace

#5 Updated by LolaAmerica 7 months ago

i added in Zip a more Info. If you need more let me know. If you have an FTP account, i can deliver you more...

Thanks a lot.

#6 Updated by LolaAmerica 7 months ago

excuse me, i took the wrong folder ... here the full info-package.

#7 Updated by achristian 7 months ago

The solution to your answer is quite simple: Your shared interface is not the same on client and server.

Have a look at this (quite old but the principle is still valid) wiki article: http://dev.root1.de/projects/simon/wiki/Setup_eclipse

You need to have exactly the same interface on server as on client. Therefore, you're advised to have three (!) projects:

  1. Server: Containing server only code
  2. Client: Containing client only code
  3. Shared: Containing shared code, which is used by client AND server.

Your solution:

Your server interface:

package de.test.pst.simon;

import de.root1.simon.annotation.SimonRemote;
import de.root1.simon.exceptions.SimonRemoteException;

public interface ServerInterface extends SimonRemote {

    public void login(ClientCallBackInterface clientCallback) throws SimonRemoteException;
}

Your client interface:

package de.test.simon;

import de.root1.simon.annotation.SimonRemote;
import de.root1.simon.exceptions.SimonRemoteException;

public interface ServerInterface extends SimonRemote {

    public void login(ClientCallBackInterface clientCallback) throws SimonRemoteException;
}

--> The package is different. And that's why the client cannot cast the proxy/skeleton object to

de.test.simon.ServerInterface

due to the fact that it is a

de.test.pst.simon.ServerInterface

Copy&Pasting Code from Server to Client and back is not a good workflow. Create a separate, shared code project, that client and server depend on.

That is NOT a SIMON related issue, that is more a general behavior on distributed network systems.

br,
Alex

#8 Updated by achristian 7 months ago

  • Status changed from New to Closed

closed, as it it not a SIMON issue.

#9 Updated by LolaAmerica 7 months ago

I read an article for rmi, that it can be problematic when using on Client Server different package-names for the shared components.
So i created a new project where i just copied the shared package in the Tomcat client. And now it works.... fine. Simon is great....

Also available in: Atom PDF