comp.lang.ada
 help / color / mirror / Atom feed
From: John Kern <jkern3@NOSPAM.visteon.com>
Subject: Calling JGNAT task from a Java applet?
Date: Wed, 24 Apr 2002 11:23:52 -0400
Date: 2002-04-24T11:23:52-04:00	[thread overview]
Message-ID: <3CC6CE08.20B944B2@NOSPAM.visteon.com> (raw)

Has anyone ever succeeded in calling an Ada task from a Java applet?  I
get
the following runtime error when invoking my Java program containing:

-------[snip]-------------from my applet Java code----
controller control;		\\ control is of type controller
public viod run()
{
   control.init();		\\ init should initialize the Ada runtime Adainit
				\\ from ada_testcontroller.adainit

with the line:
D:\WSU\ECE7990\ControlProject\GUI>appletviewer otest.html
java.lang.NoClassDefFoundError: jgnat/adalib/GNAT_libc
        at controller.init(controller.adb:41)
        at PhysicalPlant.run(PhysicalPlant.java, Compiled Code)
        at java.lang.Thread.run(Thread.java:472)

followed when exiting the applet by:

java.security.AccessControlException: access denied
(java.lang.RuntimePermission modifyThread )
        at
java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java, Compiled Code)
        at
java.security.AccessController.checkPermission(AccessController.java,
 Compiled Code)
        at
java.lang.SecurityManager.checkPermission(SecurityManager.java,
Compi
led Code)
        at
sun.applet.AppletSecurity.checkAccess(AppletSecurity.java:106)
        at java.lang.Thread.checkAccess(Thread.java:1036)
        at java.lang.Thread.stop(Thread.java:560)
        at PhysicalPlant.stop(PhysicalPlant.java:727)
        at sun.applet.AppletPanel.run(AppletPanel.java:371)
        at java.lang.Thread.run(Thread.java:472)

This is my controller.ads
-------------------------------------
pragma Extensions_Allowed (On);
with Java; use Java;

package Controller is

   task Controller_Task;
   
   procedure Init;
   
end Controller;
pragma Export (Java, Controller, "controller");
pragma Extensions_Allowed (Off);
---------------------------------------

This is my controller.adb:
------------------------------------------
pragma Extensions_Allowed (On);
with Ada.Text_IO;   use Ada.Text_IO;
with Ada.Calendar;  use Ada.Calendar;
with Sensor_Interface;
with Actuator_Interface;

package body Controller is
   Start: Time;

   task body Controller_Task is
      Interval: constant Duration := 1.0;
      Next: Time := Clock + Interval;
   begin
      Start := Clock;
      loop
         delay until Next;
		 Ada.Text_IO.put('*' & ascii.BEL);
	
Ada.Text_IO.put_line(sensor_interface.position'image(sensor_interface.read_p
osition));
		 Next := Next + Interval;
      end loop;
   end Controller_Task;

   procedure Init is
      procedure Adainit;
      pragma Import (Ada, Adainit, "ada_testcontroller.adainit");
   begin
      Adainit;
   end Init;

end Controller;
pragma Extensions_Allowed (Off);
---------------------------------------------

And this program testcontroller.adb
------------------------------------------
with Controller;		use Controller;
procedure testcontroller is
begin
   null;
end testcontroller;
-------------------------------------------

runs fine with the commands:

D:\WSU\ECE7990\ControlProject\GUI>java -version
java version "1.2.2"
Classic VM (build JDK-1.2.2_011, native threads, symcjit)

D:\WSU\ECE7990\ControlProject\GUI>java testcontroller
* 0.00000E+00
* 0.00000E+00
* 0.00000E+00
^C
D:\WSU\ECE7990\ControlProject\GUI>


It seems like I can only get a runtime ada_testcontroller.class
(containing
adainit) when I build the testcontroller program, but it is not
otherwise
necessary for building the Java applet.  I'm not sure what is being
referred
to by the initial error message:
jgnat/adalib/GNAT_libc
because my e:\gnat\jgnat-1.1p\lib\jgnat\adalib directory has no
subdirectories nor a GNAT_libc file.

Can anybody supply additional insight?

TIA



                 reply	other threads:[~2002-04-24 15:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox