6 Replies - 3017 Views - Last Post: 15 December 2008 - 11:15 PM Rate Topic: -----

#1 ambicainmail08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-March 08

Need help in Aglets

Posted 25 March 2008 - 11:10 AM

hiii,
Am doin B.tech IT final year.. am doin my final yr project using aglets...
actually i tried connect a aglet to a socket. but it throws access control permission denied.. connection refused.. and java.net.socketexception and so..

i browsed and found tht i got to change some policy file... but i cud not get it properly...

can anyone plzz help me out in this...

how to make aglets connect to a socket...??

can u plzz provide me with a sample code snipppet....

thanks in advance...

Regards
Ambica

Is This A Good Question/Topic? 0
  • +

Replies To: Need help in Aglets

#2 GWatt  Icon User is offline

  • member icon

Reputation: 278
  • View blog
  • Posts: 3,078
  • Joined: 01-December 05

Re: Need help in Aglets

Posted 25 March 2008 - 11:15 AM

We can't help you if you don't post your code. And I think you meant "Applets"

[edit]
btw:
Welcome to DIC
and

:code:

This post has been edited by GWatt: 25 March 2008 - 11:15 AM

Was This Post Helpful? 0
  • +
  • -

#3 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Need help in Aglets

Posted 25 March 2008 - 02:10 PM

Changing a policy file is a way, but it is quite cumbersome, and you have to do it everywhere where you want to run your applet. It is pretty pointless.
I would suggest another idea:
- jar your class(es) if they are not already jarred
- sign the jar file with jarsigner (use the keytool to generate a key)
This way your applet will ask the user for permission to access sockets, files, etc. Much simpler.

(Any socket example will work fine this way)
Was This Post Helpful? 1
  • +
  • -

#4 ambicainmail08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-March 08

Re: Need help in Aglets

Posted 25 March 2008 - 10:18 PM

View PostGWatt, on 25 Mar, 2008 - 11:15 AM, said:

We can't help you if you don't post your code. And I think you meant "Applets"

[edit]
btw:
Welcome to DIC
and

:code:


hiii...
it is a simple socket connection code in aglets to connect to other java code...
this is the actual exception tht is raised at run time...

java.security.AccessControlException: access denied (java.net.SocketPermission "128.2.2.1:1159*", "listen,resolve,accept")

Do help me as to how to fix this error...

thanks
Ambica
Was This Post Helpful? 0
  • +
  • -

#5 bhandari  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 9
  • View blog
  • Posts: 754
  • Joined: 31-January 08

Re: Need help in Aglets

Posted 25 March 2008 - 11:54 PM

share your code here
Was This Post Helpful? 0
  • +
  • -

#6 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Need help in Aglets

Posted 26 March 2008 - 02:10 AM

Source is not needed, he is having problem with the Applet's sandbox.
Was This Post Helpful? 0
  • +
  • -

#7 sweettam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-December 08

Re: Need help in Aglets

Posted 15 December 2008 - 11:15 PM

Hi…
I am a final computer science & engineering student going to do my final year on Mobile agents. Now I am in the process of learning Aglets API. I am doing so by coding samples for the various concepts in its API for the last 10 days. I got fascinated with the way that the behavior of the mobile agents that I coded. Now I encountered a problem when I modeled the following concept

“There are two agents Parent Agent and Child Agent – ParentAgent creates the ChildAgent giving its proxy as an argument and then dispatch it to the Remote Context(atp://localhost:2000). In the Remote Context the child agent would have to print the details of the Parent Proxy.”

I hereby presented that Source Code and Exceptions Occurred. These kinds of exceptions also occur when I dispatch an aglet which contains string array or a vector as its fields. I am waiting for your valuable comments on this problem. Thanks in advance.

VERSION: jdk6.0 update 11, aglets-2.0.2
OS: Windows XP Professional, Service Pack 2
Installation Path : JAVA : F:\Java\
AGLETS: F:\Java\aglets\
ENVIRONEMENT VARIABLES :
AGLETS_EXPORT_PATH : F:\Java\aglets\public;
AGLETS_HOME: F:\Java\aglets; AGLETS_PATH: F:\Java\aglets;F:\Java\aglets\public;
CLASSPATH: F:\Java\aglets\lib\aglets-2.0.2.jar;
F:\Java\aglets\public;
F:\Java\jdk6.0\jre\lib\rt.jar;

SOURCE CODE:

Parent.java
import com.ibm.aglet.Aglet;
import com.ibm.aglet.AgletContext;
import com.ibm.aglet.AgletProxy;
import java.net.URL;

public class Parent extends Aglet {
	public void run() {
		AgletContext context = getAgletContext();
		AgletProxy parentProxy = getProxy();
		try {
			AgletProxy childProxy  = context.createAglet(null, "Child", parentProxy);
			childProxy.dispatch(new URL("atp://localhost:2000"));
		} catch (Exception e) {
			System.out.println(e.toString());
		}
	}
}


import com.ibm.aglet.Aglet;
import com.ibm.aglet.AgletProxy;
import com.ibm.aglet.event.MobilityAdapter;
import com.ibm.aglet.event.MobilityEvent;

public class Child extends Aglet {

	AgletProxy parentProxy = null;

	public void onCreation(Object init) {
	   parentProxy = (AgletProxy) init;
	   addMobilityListener( new MobilityAdapter(){
		   public void onArrival(MobilityEvent me) {
			   System.out.println("ParentProxy : " + parentProxy.toString());;
		   } 
	   });
	}
}



EXCEPTION STACK TRACE:
---------------------------------------------------------------------------------------------------------------
Exceptions Occured at the Tahiti Server (Default Port:4434) running the Parent Aglet
---------------------------------------------------------------------------------------------------------------
***** Addr: atp://localhost:2000 place:
No integrity check because no security domain is authenticated.
java.io.IOException: FileNotFound: F:\Java\aglets\public\[B.class
at com.ibm.aglets.MAFAgentSystem_AgletsImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.aglets.MAFAgentSystem_AgletsImpl.readData(Unknown Source)
at com.ibm.aglets.MAFAgentSystem_AgletsImpl.fetch_class(Unknown Source)
at com.ibm.maf.atp.ConnectionHandler.handleFetchRequest(Unknown Source)
at com.ibm.maf.atp.ConnectionHandler.handleRequest(Unknown Source)
at com.ibm.maf.atp.ConnectionHandler.handle(Unknown Source)
at com.ibm.maf.atp.ConnectionHandler.run(Unknown Source)
code = 400
com.ibm.maf.MAFExtendedException: INTERNAL ERROR
at com.ibm.maf.atp.MAFAgentSystem_ATPClient.receive_agent0(Unknown Sourc
e)
at com.ibm.maf.atp.MAFAgentSystem_ATPClient.access$000(Unknown Source)
at com.ibm.maf.atp.MAFAgentSystem_ATPClient$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.maf.atp.MAFAgentSystem_ATPClient.receive_agent(Unknown Source
)
at com.ibm.aglets.LocalAgletRef.dispatch(Unknown Source)
at com.ibm.aglets.SystemMessage.handle(Unknown Source)
at com.ibm.aglets.AgletThread.run(Unknown Source)
com.ibm.aglet.RequestRefusedException: atp://localhost:2000, Integrity=DIGEST, C
onfidentiality=SHORTSECRETKEY, Timeout=0 Child

----------------------------------------------------------------------------------------------------------------------------
Exceptions Occured at the Tahiti Server (port 2000) for which the Child Aglet is Dispatched
----------------------------------------------------------------------------------------------------------------------------
java.io.IOException: atp://tampc:4434/[B.class
at com.ibm.net.protocol.atp.URLConnectionForATP.getInputStream(Unknown S
ource)
at com.ibm.aglets.tahiti.AgletClassLoader.loadResourceFromCodeBase(Unkno
wn Source)
at com.ibm.aglets.tahiti.AgletClassLoader.access$100(Unknown Source)
at com.ibm.aglets.tahiti.AgletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.aglets.tahiti.AgletClassLoader.getResourceAsByteArray(Unknown
Source)
at com.ibm.aglets.tahiti.AgletClassLoader.findByteCode(Unknown Source)
at com.ibm.aglets.tahiti.AgletClassLoader.loadClassFromCodeBase(Unknown
Source)
at com.ibm.aglets.tahiti.AgletClassLoader.findClassInternal(Unknown Sour
ce)
at com.ibm.aglets.tahiti.AgletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.ibm.aglets.tahiti.ResourceManagerImpl.loadClass(Unknown Source)
at com.ibm.aglets.AgletInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(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 com.ibm.aglets.RemoteAgletRef.findRef(Unknown Source)
at com.ibm.awb.weakref.WeakRef.setRef(Unknown Source)
at com.ibm.awb.weakref.VirtualRef.readObject(Unknown Source)
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.readObject(Unknown Source)
at com.ibm.aglets.AgletReader.readAglet(Unknown Source)
at com.ibm.aglets.AgletContextImpl.receiveAglet(Unknown Source)
at com.ibm.aglets.MAFAgentSystem_AgletsImpl$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.aglets.MAFAgentSystem_AgletsImpl.receive_agent(Unknown Source
)
at com.ibm.maf.atp.ConnectionHandler.handleDispatchRequest(Unknown Sourc
e)
at com.ibm.maf.atp.ConnectionHandler.handleRequest(Unknown Source)
at com.ibm.maf.atp.ConnectionHandler.handle(Unknown Source)
at com.ibm.maf.atp.ConnectionHandler.run(Unknown Source)
java.io.StreamCorruptedException: invalid type code: 30
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 com.ibm.aglets.RemoteAgletRef.findRef(Unknown Source)
at com.ibm.awb.weakref.WeakRef.setRef(Unknown Source)
at com.ibm.awb.weakref.VirtualRef.readObject(Unknown Source)
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.readObject(Unknown Source)
at com.ibm.aglets.AgletReader.readAglet(Unknown Source)
at com.ibm.aglets.AgletContextImpl.receiveAglet(Unknown Source)
at com.ibm.aglets.MAFAgentSystem_AgletsImpl$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.aglets.MAFAgentSystem_AgletsImpl.receive_agent(Unknown Source
)
at com.ibm.maf.atp.ConnectionHandler.handleDispatchRequest(Unknown Sourc
e)
at com.ibm.maf.atp.ConnectionHandler.handleRequest(Unknown Source)
at com.ibm.maf.atp.ConnectionHandler.handle(Unknown Source)
at com.ibm.maf.atp.ConnectionHandler.run(Unknown Source)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1