For Programmers: Free Programming Magazines  


Home > Archive > Java Help > March 2004 > Eclipse/Ant, JAR's, and RMI









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Eclipse/Ant, JAR's, and RMI
Andrew Gniadek

2004-03-27, 12:30 am

Hey,
I'm new to Ant, and xml for that matter. I need to rmi compile & package
a set of simple classes whose objects call each other remotely. I need
separate jars for a "server" and one for "client" containing whatever
classes are needed for each. Using Ant the classes should be compiled,
packaged into the jars and then the jars should be copied to some other
specified directory. And of course, the jars should be executable.
The files I use are AddressBook (interface extends Remote),
AddressBookImpl (extends UnicastRemoteObject implements AddressBook),
BuddyInfoInterf (interface extends Remote), BuddyInfo (the
implementation, extends Unicast... implements BuddyI...), and
AddressBookUser.
The AddressBook is created on the server-side (in main() found in
AddressBookImpl) and is populated with BuddyInfo's also created server-side.
AddressBookUser is just the client accessing some info from ABook or BInfo.
So, anyway, here's the xml file I've written to do the tasks assigned.
The classes compile fine, and the jar files seem to contain the proper
files. My problem is that the jar files don't execute properly. The
main() in AddressBookImpl creates the ABook and binds it to the
rmiregistry. When I run the server.jar that is "initially" created
during the process (the one in the base dir) it works fine but this only
seems to work correctly because it's in the same dir as all of the
compiled classes. The copied jar file in the other directory, or even if
I manually copy the server.jar file in the base dir to some other dir,
causes an exception when trying to bind the AddressBook to the registry
saying it can't find a stub that is definitely located in the jar. And
I'm running the rmiregistry in whatever dir the server.jar is in each time:

Exception in thread "main" java.rmi.ServerException: RemoteException
occurred in
server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: AddressBookImpl_Stub
at sun.rmi.server.....

<?xml version="1.0"?>
<project default="packaging">

<!-- Change location(s) to desired path(s) where client and/or
server jar files should be copied to, else will create folders
"client" and "server" in project directory and copy them to
there. -->
<property name="serverDir" location="./server"/>
<property name="clientDir" location="./client"/>

<!-- performs all tasks -->
<target name="packaging">

<!-- Compiles all files in project directory. Necessary for
AddressBookUser.java to be compiled -->
<javac srcdir="."/>

<!-- RMI compiles AddressBookImpl & BuddyInfo -->
<rmic classname="AddressBookImpl" base="."/>
<rmic classname="BuddyInfo" base="."/>

<!-- Creates server jar file -->
<jar destfile="./server.jar" basedir="." includes="**.class"
excludes="AddressBookUser.**">
<manifest>
<attribute name="Main-Class" value="AddressBookImpl"/>
<attribute name="Class-Path" value="."/>
</manifest>
</jar>

<!-- Creates client jar file -->
<jar destfile="./client.jar" basedir="." includes="**.class"
excludes="AddressBookImpl.** BuddyInfo.** **Skel.class">
<manifest>
<attribute name="Main-Class" value="AddressBookUser"/>
<attribute name="Class-Path" value="."/>
</manifest>
</jar>

<!-- copy jar files to specified directories -->
<copy file="./server.jar" todir="${serverDir}"/>
<copy file="./client.jar" todir="${clientDir}"/>

</target>

</project>

Sorry bout the length. Just want to cover my bases. Thanks for any help.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com