EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: CAJ Options
From: "David Dudley" <[email protected]>
To: "J. Lewis Muir" <[email protected]>, <[email protected]>
Date: Tue, 15 May 2007 15:49:42 -0500
I had an include file that wasn't included.  Fancy that ;-)

Still, have the following code
â-------------------------------------------
			try
			{
				URL codebase=this.getCodeBase();
				String host=codebase.getHost();
				
				System.out.println("Configuration starting");
				DefaultConfiguration conf=new DefaultConfiguration("applet");
				System.out.println("Context created");
				conf.setAttribute("class","com.cosylab.epics.caj.CAJContext");
				System.out.println("Attribute Added");
				
				System.out.println("Instance created");
				// Get the JCALibrary instance
				jca=JCALibrary.getInstance();
				System.out.println("Instance initialization passed");
				
//				System.setProperty("com.cosylab.epics.caj.CAJContext.addr_list",host);
//				System.setProperty("com.cosylab.epics.caj.CAJContext.auto_addr_list","false");
				
				conf.setAttribute("com.cosylab.epics.caj.CAJContext.addr_list",host);
				conf.setAttribute("com.cosylab.epics.caj.CAJContext.auto_addr_list","false");
				conf.setAttribute("com.cosylab.epics.caj.CAJContext.connection_timeout","30.0");
				conf.setAttribute("com.cosylab.epics.caj.CAJContext.beacon_period","15.0");
				conf.setAttribute("com.cosylab.epics.caj.CAJContext.repeater_port","5065");
				conf.setAttribute("com.cosylab.epics.caj.CAJContext.server_port","5064");
				conf.setAttribute("com.cosylab.epics.caj.CAJContext.max_array_bytes","16384");
				conf.setAttribute("com.cosylab.epics.caj.CAJContext.thread_pool_size","5");
				
				System.out.println("Creating context");
//				ctxt=jca.createContext(JCALibrary.CHANNEL_ACCESS_JAVA);
				ctxt=jca.createContext(conf);
				
				System.out.println("Context creation passed");
				
//				System.setProperty("com.cosylab.epics.caj.CAJContext.addr_list",host);
//				System.setProperty("com.cosylab.epics.caj.CAJContext.auto_addr_list","false");			
			}
			catch(Exception ex)
			{
				System.err.println("Initialization failed for " + dpm.dataSource+":\n" + ex + "\n");
				System.exit(1);
			}
â-------------------------------------------

and it's producing the following error.
â-------------------------------------------

Configuration starting
Context created
Attribute Added
Instance created
Instance initialization passed
Creating context
Initialization failed for Util1:Tot:KW:
gov.aps.jca.CAException: Unable to create context

java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.1)
	at java.security.AccessControlContext.checkPermission(Unknown Source)
	at java.security.AccessController.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkExit(Unknown Source)
	at java.lang.Runtime.exit(Unknown Source)
	at java.lang.System.exit(Unknown Source)
	at Applet1.initDPM(Applet1.java:295)
	at Applet1.init(Applet1.java:62)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

â-------------------------------------------
By looking at the code, you can see that it gets down to doing the actual createContext call before failing.

No, I'm not running it in the Sun Applet viewer.  Believe it or not, things were working fine in the viewer, and it would even read the properties file successfully.  Turns out the problem wasn't the properties file at all, but this one next in the code.

I'm using Eclipse to create a .jar file, and I've got a WEB page that invokes the applet in IE.

Curious and curiouser...
David Dudley

>>> "J. Lewis Muir" <[email protected]> 5/15/2007 3:40 PM >>>
David Dudley wrote:
> For some reason I get a "cannot find symbol" for the line
> 
>  DefaultConfiguration conf=new DefaultConfiguration("applet");
> 
> Can't seem to get past that line.

Hi, David.

Are you getting that error at compile time or run time? What is 
producing that error? Is there a stack trace? Are you running your 
applet with the Sun JDK's appletviewer program?

-lewis

>>>> "J. Lewis Muir" <[email protected]> 5/15/2007 1:35 PM >>>
> David Dudley wrote:
>> After putting a bunch more comments in my Applet file, what I find is that the call to JCALibrary.getInstance() completes successfully, but the call to jca.createContext() fails.
>>
>> My code is:
>> â-------------------------
>> 			try
>> 			{
>> 				URL codebase=this.getCodeBase();
>> 				String host=codebase.getHost();
>>
>> 				// Get the JCALibrary instance
>> 				jca=JCALibrary.getInstance();
>>
>> 				System.out.println("Instance initialization passed");
>> 				
>> 				System.setProperty("com.cosylab.epics.caj.CAJContext.addr_list",host);
>> 				System.setProperty("com.cosylab.epics.caj.CAJContext.auto_addr_list","false");
>>
>> 				// Create a thread safe context with default configuration values
>> 				ctxt=jca.createContext(JCALibrary.CHANNEL_ACCESS_JAVA);
>> 				
>> 				System.out.println("Context creation passed");
>> 				
>> 				System.setProperty("com.cosylab.epics.caj.CAJContext.addr_list",host);
>> 				System.setProperty("com.cosylab.epics.caj.CAJContext.auto_addr_list","false");
>> 				
>> 			}
>> 			catch(Exception ex)
>> 			{
>> 				System.err.println("Initialization failed for " + dpm.dataSource+":\n" + ex);
>> 				System.exit(1);
>> 			}
>> â-------------------------
>>
>> The console outputs:
>> Instance initialization passed
>> Initialization failed for Util1:Tot:KW:
>> java.security.AccessControlException: access denied (java.util.PropertyPermission com.cosylab.epics.caj.CAJContext.addr_list write)
>> java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.1)
>> 	at java.security.AccessControlContext.checkPermission(Unknown Source)
>> 	at java.security.AccessController.checkPermission(Unknown Source)
>> 	at java.lang.SecurityManager.checkPermission(Unknown Source)
>> 	at java.lang.SecurityManager.checkExit(Unknown Source)
>> 	at java.lang.Runtime.exit(Unknown Source)
>> 	at java.lang.System.exit(Unknown Source)
>> 	at Applet1.initDPM(Applet1.java:279)
>> 	at Applet1.init(Applet1.java:61)
>> 	at sun.applet.AppletPanel.run(Unknown Source)
>> 	at java.lang.Thread.run(Unknown Source)
>>
>>
>> Line 279 (the error line) is the line number of the System.exit(1) function call.
>>
>>
>> ideas??
>>
>> David Dudley
> 
> Hi, David.
> 
> It looks like it might be failing because the applet does not have write 
> permission to *set* the system property 
> "com.cosylab.epics.caj.CAJContext.addr_list" in the System.setProperty call.
> 
> You could try the approach I suggested earlier to see if it might work 
> instead:
> 
>    DefaultConfiguration conf = new DefaultConfiguration("applet");
>    conf.setAttribute("class", "com.cosylab.epics.caj.CAJContext");
>    ...
>    JCALibrary.getInstance().createContext(conf);
> 
> -lewis
> 
>>
>>>>> Kay-Uwe Kasemir <[email protected]> 5/15/2007 12:13 PM >>>
>> On May 15, 2007, at 12:16 , David Dudley wrote:
>>
>>> OK, all you JCA and CAJ people, here's a problem for you-
>>>
>>> I'm setting up JCA/CAJ to run through an applet.  How do I prevent  
>>> them
>>> from *attempting* to find the JCALibrary.properties file?
>>>
>>> When an applet tries to find the file, it creates an access security
>>> exception, since Applets, by nature, can't access the underlying file
>>> system.
>>>
>>> I tried doing System.setProperty commands to set
>>> 'com.cosylab.epics.caj.CAJContext' to values before the createContext,
>>> but the moment that createContext is accessed, I get an error.
>> Interesting.
>>
>> In jca-2.3.0/src/core/gov/aps/jca/JCALibrary.java
>> there's this code:
>>
>>      try {
>>          InputStream is = JCALibrary.class.getResourceAsStream 
>> ( "JCALibrary.properties" );
>>          if (is == null)
>>              throw new RuntimeException("resource not found.");
>>          _builtinProperties.load( is );
>>      } catch( Throwable ressourceEx ) {
>>        System.out.println( "Unable to load default configuration....);
>>      }
>>
>> I would think the worst that can happen is a println,
>> and your System.setProperty calls would actually win.
>>
>> But maybe that attempt to read a file does worse things
>> to an applet, something that the catch() doesn't catch?
>> I'd try to change that code section somewhat to see
>> what's happening in your case.
>>
>> -Kay
>>
>>
>>
> 
> 


BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:David Dudley
TEL;WORK:880-3740
ORG:;MIS
TEL;PREF;FAX:880-3741
EMAIL;WORK;PREF;NGW:[email protected]
N:Dudley;David
END:VCARD


Replies:
Re: CAJ Options J. Lewis Muir
References:
CAJ Options David Dudley
Re: CAJ Options David Dudley
Re: CAJ Options J. Lewis Muir

Navigate by Date:
Prev: Re: CAJ Options J. Lewis Muir
Next: Re: CAJ Options J. Lewis Muir
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: CAJ Options J. Lewis Muir
Next: Re: CAJ Options J. Lewis Muir
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Nov 2011 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·