Java RMI implement an interface from other projekt - java

I'm trying to implement an interface that needs to be implemented by the server but also the client. I am making an RMI server/client system where the client should call the server, and get a value from the server.
It should be a "Remote Interface" between the server and client but i have problems implement it in my server and client programs.
Have made 3 projects in Eclipse
Projekt 1 (Server)
Projekt 2 (Client)
Projekt 3 (Remote Interface)
I want a class inside the Server project named DataImpl to implement the Remote Interface. Have tried to add a JARS in my Server libraries but it dosnen't work.. have these options:
So if i add them, and go to the DataImpl class inside the server, i still wont implement DataI. Here is the options, but they are all wrong.
Hope someone know what the problem is, and what i am doing wrong :)

I found the answer myself..
You should add the project
In the build path --> Project --> Add --> Choose it!

Is the project with the interface on the classpath for the project you want to use it in? If it is, implementing it the way you are doing it is correct.
This scenario is just like any other jar file in the class path. One project is including the other project in its classpath and then uses it.

Related

Maven - How to organize projects/modules?

I am developing a Windows Service that uses TCP/IP to communicate with their clients.
So i create a project for the service using Maven. Now i need to create a client to comunicate with this service. Is it better to create another project or a module? Or create it inside the Windows Service project?
For development purposes it easier to create another module. First, its easy to view both client and server code in the IDE without having to close and open projects. Second, common code can be placed in another module, which makes easier to code and debug.

Generic binding between EJB module and HTTP router module

TL;DR
Is it necessary to have an HTTP router module when deploying an EJB module containing web service implementations to WebSphere 7?
If so, is there a way to create/manage it without relying on IBM-specific files?
I have an application that is being restructured so that it can be built Maven. Currently, I am using was6-maven-plugin's endptEnabler goal to build an HTTP router module for an EJB module that contains some web services. This works well, but I just found out that the build machine we'll get to use won't actually have WebSphere installed on it. In the past this wouldn't have been a problem, since the router module had been developed manually by someone clicking a "Generate Router Module" button in RAD and then actually checking in the generated code into source control. With the Maven-centric build process, we thought it would be better to generate the module during the build process.
So now I am stuck: generating the router module via Maven seems a much cleaner approach but won't work on the build machine. I have a few options:
Extract the generated WAR and add it to our enterprise repository and then create a dependency from my EJB to the WAR. I really don't like this, but it would probably work.
Go back to having a realized HttpRouterModule project in the workspace. The problem with this is that the IBM-specific binding files have valid module IDs for my server, but I don't know if they'd cause problems on someone else's which is why I'd rather generate these files from Maven.
Keep generating the router module with Maven, but find a way to generate it in a way such that there is no WebSphere dependency.
I'd prefer to go with the third option, but I'm not sure how I can generate the module and the binding files in generic way such that it will still be recognized by WebSphere.
I'm open to hearing about other options too...
As far as I know you need http router module. From my experience I was also unable to create the module manually. Is there no way you could install was7 dev server on your build machine? I believe it is free download from IBM.
All my research so far indicates that this is necessary in WebSphere 7, and in earlier versions. It looks like WebSphere 8 does not require HTTP router modules. We're going with the second option, as the build server won't be able to generate the router modules on its own.
Not ideal, but once we move to WAS8 this won't be necessary.

Communication among server application and Android app

I want to write an Android app that is able to communicate with an application on a server pc, using java sockets.
I have created few classes that implement the Serializable interface, in order to send them through socket as protocol.
The problem is that I have to create two projects in Eclipse, one for the server application and one for the android app. So, I should create a duplicate of those protocol classes in order to use them in both projects.
Is that right? Is there a kind of "import project into another project" so that I can keep those protocol classes in a third project and import it in my android app and server application?
Thank you.
You don't actually need to create a separate Eclipse project for the shared classes. You can just create a 'common source folder' outside of the other two projects' disk hierarchy. For both the server and client projects. In the Properties/Java Build Path/Source add a 'Link source' to the new folder.

First steps on liferay web services

I followed this tutorial -documentation about Liferay Web service.
I runned Lifaray on tomcat
If I use http://localhost:8080/api/axis/Portal_UserService?wsdl by browser I have a response.
When I create a webService Client on Eclipse and I put this url http://localhost:8080/api/axis/Portal_UserService?wsdl in the Service Definition...
but I have this error message:
No server can be found and WebServiceProject does not exist. Choose an existing project or use the preferences to configure a server runtime.
Why?
create dynamic web project and configure a server then add wsdl .
This does not mean that the server (e.g. Liferay) can't be found but notifies you that Eclipse doesn't know where to put/how to configure the resulting WebService: It needs a server runtime and a WebServiceProject - e.g. you can create a WebServiceClient inside a project - if no suitable project exists, eclipse will complain.
So: Everything is fine on the Liferay side. You'll need infrastructure in your IDE to be able to go forward with this operation
I could not find any solution to this, for some reason Eclipse didn't recognize a valid wsdl. I downloaded a trial version of IntelliJ IDEA 13 Ultimate and setup the Web Service Client through there. Everything worked properly.

Automated deployment of JavaScript project for different environments

I was looking for similar problems and, of course, there exists many but I would like to know if someone uses a similar project like us and how you have deal with it.
We are working on a project where:
- Client side is completely based on JavaScript, with Dojo Toolkit framework, which makes AJAX request to our server side.
- Server side based on Java+Spring+Hibernate which implements some REST API.
We are managin the two parts as different projects, that is, for the server side we are using maven and for each change our CI server runs tests.
The important step here is we can configura maven with profiles so the CI can create a package ready for pre-production or production environments using different property files.
The client side is a bunch (with a nice structure) of HTML, CSS and JavaScript files. Like the server side, on the client side we have property file to point the client to the right place (like the development server side).
The question is: which could be the best way on this scenario to automate the client side?development? I mean, run JavaScript tests on CI and autodeploy to the right environment using the appropriate property file.
Thanks.
While someone gives you a proper and complete answer you might want to have a look at a similar question I did. Javascript web app and Java server, build all in Maven or use Grunt for web app?
I am trying different options out there but most probably we will finish using Grunt for the client side. Maven exec to call it and build everything (client + server) with different profiles.

Categories