Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Setting up Bundle-RequiredExecutionEnvironment causes access restriction errors
Setting up Bundle-RequiredExecutionEnvironment causes access restriction errors [message #336139] Tue, 26 May 2009 10:50 Go to next message
Ian Leslie is currently offline Ian LeslieFriend
Messages: 136
Registered: July 2009
Senior Member
I recently upgraded to eclipse 3.4 for my RCP application development
work. I decided to clean up my "No required execution environment has
been set" warnings. After adding the line
"Bundle-RequiredExecutionEnvironment: JavaSE-1.6" to all my plug-ins'
manefest files everything was OK except for one plug-in where I do some
XML manipulation using SAX2DOM and XPathAPI. In that class I get a bunch
of errors like this:

Access restriction: The constructor SAX2DOM() is not accessible due to
restriction on required library C:\Program
Files\Java\jdk1.6.0_13\jre\lib\rt.jar ReadClipboard.java com.lesliesoftware.wizardsfamiliar.deck.editor/src/com/lesli esoftware/wizardsfamiliar/deck/editor/clipboard line
230 Java Problem

When I edit the JRE System Library settings in the Project Properties |
Java Build Path | Libraries if I choose "Execution Environment JavaSE-1.6
(jdk1.6.0_13)" I get the compile errors. If I choose "Workspace default
JRE (jdk1.6.0_13)" the code compiles but I get an "The JRE container on
the classpath is not a perfect match to the 'JavaSE-1.6'" warning in my
mf file instead of the "No required execution environment has been set"
warning I am trying to fix.

Clearly my 1.6 JDK is a perfect match for the JavaSE-1.6 environment and
the preference page Java | Installed JREs | Execution Environment even
says as much. What is wrong with how I am trying to fix this?

Any help would be appreciated.

Ian

Code (I am using TagSoup to parse the HTML contents from the clip board
and then XPath to find content in the HTML to create my elements from):
---8<---
private void createSlotsFromHTMLTransfer (String contents) {

StringReader inputReader = null;
try {
// Create and configure the parser
Parser parser = new Parser ();
parser.setFeature
("http://xml.org/sax/features/namespace-prefixes", true); //$NON-NLS-1$

// Parse the HTML
SAX2DOM sax2dom = new SAX2DOM ();
parser.setContentHandler (sax2dom);
inputReader = new StringReader (contents);
InputSource inputSource = new InputSource (inputReader);
inputSource.setEncoding ("UTF-8"); //$NON-NLS-1$
parser.parse (inputSource);
Node doc = sax2dom.getDOM ();

if (TraceUtil.isOptionEnabled
(DebugOptions.CLIPBOARD_SAVEXML)) {
try {
// Prepare the DOM document for writing
Source source = new DOMSource(doc);

// Prepare the output file
File file = File.createTempFile ("clipboard", ".xml");
//$NON-NLS-1$ //$NON-NLS-2$
Result result = new StreamResult(file);

// Write the DOM document to the file
Transformer xformer =
TransformerFactory.newInstance().newTransformer();
xformer.transform(source, result);

TraceUtil.trace (DebugOptions.CLIPBOARD_SAVEXML,
"Clipboard contents saved to: " +
file.getAbsolutePath ()); //$NON-NLS-1$
} catch (TransformerConfigurationException e) {
TraceUtil.trace (DebugOptions.CLIPBOARD_SAVEXML,
e.getMessageAndLocation ());
} catch (TransformerException e) {
TraceUtil.trace (DebugOptions.CLIPBOARD_SAVEXML,
e.getMessageAndLocation ());
}
}

resetCurrentLine ();

String topLevelParents = "/html:html/html:body"; //$NON-NLS-1$
NodeList topLevelNodes = XPathAPI.selectNodeList (doc,
topLevelParents);

for (int index = 0; index < topLevelNodes.getLength ();
index++) {
Node curNode = topLevelNodes.item (index);

processContainingNode (curNode);
}

} catch (Exception exception) {
// Any exception indicates invalid data
EditorPlugin.getDefault ().getLog ().log
(DeckEditorError.clipboardFormatError (exception));
DND.error (DND.ERROR_INVALID_DATA);
mySlots = null;
} finally {
if (inputReader != null)
inputReader.close ();
}
}

--->8---
(SOLVED - mostly) Re: Setting up Bundle-RequiredExecutionEnvironment causes... [message #336186 is a reply to message #336139] Thu, 28 May 2009 12:08 Go to previous messageGo to next message
Ian Leslie is currently offline Ian LeslieFriend
Messages: 136
Registered: July 2009
Senior Member
Upon closer examination of the code I see that the SAX2DOM class is in
fact coming from an internal package and therefore I should not be using
it from there. I need to dl and setup Xalan so I can have public access
to that class - not rely on the fact that Sun used it internally. I wrote
that code in 2007 and did not realize I was even doing that. I guess the
access restriction actually was helpful.

The only thing that I do not understand is why when I choose "Workspace
default JRE (jdk1.6.0_13)" the code compiles without errors. Same JRE,
same access restrictions, same use of code I should not be.

Ian
Re: (SOLVED - mostly) Re: Setting up Bundle-RequiredExecutionEnvironment causes... [message #336198 is a reply to message #336186] Thu, 28 May 2009 16:39 Go to previous messageGo to next message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
"Ian Leslie" <ian.leslie@lesliesoftware.com> wrote in message
news:7ccbca9a59f06068168b56515c0076c6$1@www.eclipse.org...
> Upon closer examination of the code I see that the SAX2DOM class is in
> fact coming from an internal package and therefore I should not be using
> it from there. I need to dl and setup Xalan so I can have public access
> to that class - not rely on the fact that Sun used it internally. I wrote
> that code in 2007 and did not realize I was even doing that. I guess the
> access restriction actually was helpful.
>
> The only thing that I do not understand is why when I choose "Workspace
> default JRE (jdk1.6.0_13)" the code compiles without errors. Same JRE,
> same access restrictions, same use of code I should not be.

Pointing to a JRE is less restrictive than pointing to a specific operating
environment, I think. I think that if you point to a JRE it'll take
whatever is in there, whereas if you specify an operating environment it
forces you to comply to the minimum definition of that environment, which
may not include all the libraries that are physically present.
Re: (SOLVED - mostly) Re: Setting up Bundle-RequiredExecutionEnvironment causes... [message #336210 is a reply to message #336198] Fri, 29 May 2009 14:42 Go to previous message
Ian Leslie is currently offline Ian LeslieFriend
Messages: 136
Registered: July 2009
Senior Member
Yes, I can see that - makes seance. I did not notice that distinction in
the UI at the point were you choose the radio button between the default
JRE and the execution environment. But there is little point in
complaining about that. If I am setting up a specific execution
environment I should be well aware of that difference. In this case I
just was not:-)

Ian

Walter Harley wrote:

> "Ian Leslie" <ian.leslie@lesliesoftware.com> wrote in message
> I think that if you point to a JRE it'll take
> whatever is in there, whereas if you specify an operating environment it
> forces you to comply to the minimum definition of that environment, which
> may not include all the libraries that are physically present.
Previous Topic:How to clear entries in New Project Wizards?
Next Topic:Find fields with SearchEngine
Goto Forum:
  


Current Time: Sat Dec 20 03:05:57 GMT 2014

Powered by FUDForum. Page generated in 0.06514 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software