This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RMI server fails at constructor


Hello, 

I knew this is probably not a new question to the achieves. However,
having read the related posts, I have no luck of finding the right
answer. I am new to GCJ, and trying to compile an very basic RMI server
to native code on WinXP. Any help would be appreciated!! 

The GCJ I am using is ThisisCool GCJ 4.0.2 version. My
server("GRMIServerImpl")is quite minimal, and I have pasted its code at
the button of this email. 

Here is my build batch file: 

setlocal
set prompt=?

PATH %cd%\bin;%PATH%
set MAIN=GRMIServerImpl

mkdir bin
mkdir obj

gcj -C -fCLASSPATH=bin -d bin src\GRMIServer.java
gcj -C -fCLASSPATH=bin -d bin src\GRMIServerImpl.java

pushd .\bin
grmic -vcompat GRMIServerImpl
copy GRMIServerImpl_Stub.class ..\..\client\src
popd

gcj --classpath=bin -c bin\GRMIServer.class -o obj\GRMIServer.o
gcj --classpath=bin -c bin\GRMIServerImpl.class -o obj\GRMIServerImpl.o
gcj --classpath=bin -c bin\GRMIServerImpl_Skel.class -o
obj\GRMIServerImpl_Skel.o
gcj --classpath=bin -c bin\GRMIServerImpl_Stub.class -o
obj\GRMIServerImpl_Stub.o
copy src\policy.all obj\

gcj obj\*.o --main=%MAIN% -o %MAIN%.exe
-Djava.security.policy=policy.all

Endlocal

After the build, if I run GRMIServerImpl.exe, it's going to throw a
error message:
D:\GCJTest\RMI\RMISimpleExample\server>GRMIServerImpl.exe
1
Exception in thread "main" java.lang.ExceptionInInitializerError
   at 0x0042243e (Unknown Source)
   at 0x00417742 (Unknown Source)
   at 0x0041c084 (Unknown Source)
   at 0x00420134 (Unknown Source)
   at 0x0042023c (Unknown Source)
   at 0x0043dfef (Unknown Source)
   at 0x004055a8 (Unknown Source)

Anyone know what cause this exception? My RMI server source code is the
following:
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;

public class GRMIServerImpl extends UnicastRemoteObject
                             implements GRMIServer
{

	GRMIServerImpl() throws RemoteException
	{
		super();
	}

	// remote method
	public int sum(int a,int b) throws RemoteException
	{
		return a + b;
	}

	public static void main(String args[])
	{
		//set the security manager
		try
		{
			System.setSecurityManager(new
RMISecurityManager());
			System.out.println("1");

			//create a local instance of the object
			GRMIServerImpl server = new GRMIServerImpl();
			//put the local instance in the registry
			String url = "rmi://localhost:1099/GRMISevice";
			
			System.out.println("Binding server to " + url +
"...");
			Naming.rebind(url, server);
			System.out.println("Server waiting.....");
		}
		catch (java.net.MalformedURLException me)
		{
			System.out.println("Malformed URL: " +
me.toString());
			me.printStackTrace();
		}

		catch (RemoteException re)
		{
			System.out.println("Remote exception: " +
re.toString());
			re.printStackTrace();
		}
		catch(Exception ex)
		{
			System.out.println("Exception: " +
ex.toString());
			ex.printStackTrace();
		}

	}
}

Best Regards
Rui


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]