The Artima Developer Community
Sponsored Link

Jini Forum
Exception registering service with Entry[] arguments

10 replies on 1 page. Most recent reply: Dec 9, 2005 8:59 AM by austin_p P

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 10 replies on 1 page
kathy doris

Posts: 4
Nickname: katherine
Registered: Dec, 2005

Exception registering service with Entry[] arguments Posted: Dec 8, 2005 4:39 AM
Reply to this message Reply
Advertisement
hi, I am having trouble registering service with Entry arguments.

Entry[] entry = new Entry[1];
entry[0] = new Name("TestServer");

ServiceItem item = new ServiceItem(null,impl,entry);
ServiceRegistration reg = registrar.register(item, 10000000L);

when i do this i get an exception shown below

but when i use the service item as
ServiceItem item = new ServiceItem(null,impl,null);

i dont get any errors

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidObjectException: hash cannot be zero
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at com.sun.jini.reggie.RegistrarImpl_Stub.register(Unknown Source)
at com.sun.jini.reggie.RegistrarProxy.register(RegistrarProxy.java:118)
at com.elind.finswitch.startup.Testserver.<init>(Testserver.java:117)
at com.elind.finswitch.startup.Testserver.main(Testserver.java:37)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidObjectException: hash cannot be zero
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.InvalidObjectException: hash cannot be zero
at com.sun.jini.reggie.EntryClass.readObject(EntryClass.java:275)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.defaultReadObject(Unknown Source)
at com.sun.jini.reggie.EntryClass.readObject(EntryClass.java:271)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.defaultReadObject(Unknown Source)
at com.sun.jini.reggie.EntryClass.readObject(EntryClass.java:271)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source)
... 7 more


Any suggestions what cud be wrong.


austin_p P

Posts: 8
Nickname: austin14
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 8, 2005 7:09 AM
Reply to this message Reply
Kathy,
ould you please tell me the steps you followed in registering the service for:

ServiceItem item = new ServiceItem(null,impl,null);

I am having trouble registering a service. Could you also tell me how you ran the service registration program. What did you include in the classpath..
I could start the reggie service but unable to register a service.

Thanks,
Austin14

austin_p P

Posts: 8
Nickname: austin14
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 8, 2005 7:17 AM
Reply to this message Reply
Kathy,
When i run unicast discovery program , it throws java.net.connectException saying connection refused. with multicast discovery , it throws unmarshalling exception. class not found exception

Thanks.
Austin14

kathy doris

Posts: 4
Nickname: katherine
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 8, 2005 7:22 AM
Reply to this message Reply
are you able to find the lookup service?You must also have a webserver running in the root directory which contains all the classes.Are you getting any exceptions when u try to register.Which method are u using for looking up the service

kathy doris

Posts: 4
Nickname: katherine
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 8, 2005 7:28 AM
Reply to this message Reply
start the webserver in ur root folder then
use this to start the jini server

set CLASSPATH=jini-core.jar;jini-ext.jar;jsk-lib.jar
java -Djava.security.policy=ce.policy -jar "C:\Program Files\jini2_1\lib\start.jar" start-transient-reggie.config

and the file start-transient-reggie.config contains

import com.sun.jini.start.ServiceDescriptor;
import com.sun.jini.start.NonActivatableServiceDescriptor;

com.sun.jini.start {
private static codebase = "http://localhost/reggie-dl.jar";
private static policy = "security.policy";
private static classpath = "reggie.jar";
private static config = "transient-reggie.config";

static serviceDescriptors = new ServiceDescriptor[] {
new NonActivatableServiceDescriptor(
codebase, policy, classpath,
"com.sun.jini.reggie.TransientRegistrarImpl",
new String[] { config })
};
}

then u can lookup for service on localhost.

austin_p P

Posts: 8
Nickname: austin14
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 8, 2005 8:32 AM
Reply to this message Reply
Kathy,
These are the steps i followed:

I installed jini @ C:\jini2_1
My java files are @ C:\jiniworkspace\jini\com
My policy files and config files are @ C:\jiniworkspace\jini

I running the following cmds from C:\jiniworkspace\jini

1) I set the classpath using cmd:
set CLASSPATH=.; C:\jini2_1\lib\jini-core.jar;C:\jini2_1\lib\jini-ext.jar;C:\jini2_1\lib\reggie. jar;C:\jini2_1\lib-dl\reggie-dl.jar;C:\jini2_1\lib\sun-util.jar;C:\jini2_1\lib\t ools.jar;%CLASSPATH%

2)I start the webserver using the cmd:
start java -jar C:\jini2_1\lib\tools.jar -port 8083 -dir C:\jini2_1\lib -verbose
The result is :

Dec 8, 2005 10:11:16 AM com.sun.jini.tool.ClassServer run
INFO: ClassServer started [[C:\jini2_1\lib\], port 8083]

3) java -Djava.security.policy= C:\jiniworkspace\jini\policy.all -jar \jini2_1\lib\start.jar C:\jiniworkspace\jini\start-transient-reggie.config

Now it says:
Exception in thread "main" java.lang.NoClassDefFoundError: policy/all

i tried giving absolute path like security.policy = policy.all but no luck.

start-transient-reggie.config contains :

import com.sun.jini.config.ConfigUtil;
import com.sun.jini.start.ServiceDescriptor;
import com.sun.jini.start.NonActivatableServiceDescriptor;

com.sun.jini.start {
private static codebase ="http://localhost/reggie-dl.jar";
private static policy = "C:\jiniworkspace\jini\reggie.policy";
private static classpath = "C:\jini2_1\lib\reggie.jar";
private static config = "C:\jiniworkspace\jini\transient-reggie.config";

static serviceDescriptors = new ServiceDescriptor[] {
new NonActivatableServiceDescriptor(
codebase, policy, classpath,
"com.sun.jini.reggie.TransientRegistrarImpl",
new String[] { config })
};
}


transient-reggie.config contains :

import net.jini.jrmp.*;

com.sun.jini.reggie {
serverExporter = new JrmpExporter();
initialMemberGroups = new String[] {};
}

Since the above approach was not working for me , i downloaded the brian murphy starter kit examples.I could the start the reggie service from C:\jini2_1\examples\scripts

Now i ran the serviceRegistration program from C:\jiniworkspace\jini using the cmd:

java -Djava.security.policy=C:\jiniworkspace\jini\policy.all -classpath C:\jini2_1\lib\jini-core.jar;C:\jini2_1\lib\sun-util.jar;C:\jini2_1\lib\jini-ex t.jar;. com.serviceRegistration

I get :

java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:153)
at net.jini.core.discovery.LookupLocator.getRegistrar(LookupLocator.java
:328)
at com.serviceRegistration.<init>(serviceRegistration.java:87)
at com.serviceRegistration.main(serviceRegistration.java:26)

==================== ======================================
public class serviceRegistration implements ServiceIDListener {
public static void main(String arg[]) {
new serviceRegistration();
}

public void serviceIDNotify (ServiceID serviceid)
{
System.out.println ("server: received ServiceID"+ serviceid.toString());
}
public serviceRegistration()
{
myServerImpl Server;
LookupLocator lookup = null;
ServiceRegistrar registrar = null;
ServiceRegistration reg = null;


System.setSecurityManager(new RMISecurityManager());

try {
lookup = new LookupLocator("jini://localhost:4194");
String host = lookup.getHost();
int port = lookup.getPort();
System.out.println("Host:"+host);
System.out.println("Port:"+port);
} catch(java.net.MalformedURLException e){

System.err.println("Lookup failed: " + e.toString());
System.exit(1);
}
try {
System.out.println(InetAddress.getLocalHost());
} catch (UnknownHostException e1) {

e1.printStackTrace();
}

try {
System.out.println("test");
registrar = lookup.getRegistrar(120000);

} catch (IOException e) {
System.err.println(e.toString());
e.printStackTrace();
System.exit(1);
} catch (ClassNotFoundException e) {
System.err.println("Registrar search failed" + e.toString());
System.exit(1);
}
System.out.println("Found a registrar");


try
{
Server = new myServerImpl();
Entry[] entryAttributes = new Entry[1];
entryAttributes[0] = new Name("MyServer");
ServiceItem item = new ServiceItem(null, Server, entryAttributes);
reg = registrar.register(item, 10000000L);

} catch(RemoteException e) {
System.err.println("Register exception: " + e.toString());
}
System.out.println("Service registered with registration id: " +
reg.getServiceID());

} // end of contructor


}

austin_p P

Posts: 8
Nickname: austin14
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 8, 2005 8:34 AM
Reply to this message Reply
Kathy, what am i missing? I know there is some minor thing. Any tips on this

austin_p P

Posts: 8
Nickname: austin14
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 8, 2005 10:31 AM
Reply to this message Reply
I could resolve the policy error.now it hits policy.all file...but gives different exception.

Dec 8, 2005 12:18:06 PM com.sun.jini.start.HTTPDStatus httpdWarning
WARNING: Problem accessing desired URL[http://localhost/reggie-dl.jar]: java.io.
FileNotFoundException: http://localhost/reggie-dl.jar.
Dec 8, 2005 12:18:06 PM com.sun.jini.start.NonActivatableServiceDescriptor creat
e
SEVERE: classloader.problem
Dec 8, 2005 12:18:06 PM com.sun.jini.start.ServiceStarter checkResultFailures
WARNING: Exception creating service.
java.io.IOException: The filename, directory name, or volume label syntax is inc
orrect
at java.io.WinNTFileSystem.canonicalizeWithPrefix0(Native Method)
at java.io.Win32FileSystem.canonicalizeWithPrefix(Win32FileSystem.java:3
76)
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:348)
at java.io.File.getCanonicalPath(File.java:513)
at java.io.File.getCanonicalFile(File.java:534)
at com.sun.jini.start.ClassLoaderUtil.getClasspathURLs(ClassLoaderUtil.j
ava:88)
at com.sun.jini.start.ClassLoaderUtil.getImportCodebaseURLs(ClassLoaderU
til.java: 146)
at com.sun.jini.start.NonActivatableServiceDescriptor.create(NonActivata
bleServic eDescriptor.java:564)
at com.sun.jini.start.ServiceStarter.create(ServiceStarter.java:290)
at com.sun.jini.start.ServiceStarter.main(ServiceStarter.java:470)
Dec 8, 2005 12:18:06 PM com.sun.jini.start.ServiceStarter checkResultFailures
WARNING: Associated service descriptor [0]: [http://localhost/reggie-dl.jar, C:j
eggie.jar, com.sun.jini.reggie.TransientRegistrarImpl, [C:jiniworkspacejini
ransient-reggie.config], com.sun.jini.start.NonActivatableServiceDescriptor$1@1d
fafd1, BasicProxyPreparer[]]

kathy doris

Posts: 4
Nickname: katherine
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 8, 2005 9:44 PM
Reply to this message Reply
u shud start the webserver and jini sevice in the root directory which contains all ur java classes.also that directory must have a copy of reggie-dl.jar.
for example if u r package structure is myprog/com/ then start the service and webserver in myprog and keep a copy of reggie-dl.jar in myprog.hope it works

austin_p P

Posts: 8
Nickname: austin14
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 9, 2005 7:36 AM
Reply to this message Reply
i am trying to start reggie from C:\test directory. I have put all config and policy files here. I also copied the reggie-dl.jar file to C:\test. but i still get the same error "unable to access http://localhost/reggie-dl.jar"
did u put reggie-dl.jar in the classpath? in fact i tried that also.

austin_p P

Posts: 8
Nickname: austin14
Registered: Dec, 2005

Re: Exception registering service with Entry[] arguments Posted: Dec 9, 2005 8:59 AM
Reply to this message Reply
I am starting the webser from C:\test location as follows:

start java -jar C:\jini2_1\lib\tools.jar -port 8083 -dir C:\jini2_1\lib -verbose

i am able to access http://localhost:8083/start.jar from browser but not http://localhost:8083/reggie-dl.jar

Flat View: This topic has 10 replies on 1 page
Topic: Starting reggie: Manifest not found Previous Topic   Next Topic Topic: help needed in registering a service

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use