[
https://issues.jboss.org/browse/JBIDE-7290?page=com.atlassian.jira.plugin...
]
Denis Golovin edited comment on JBIDE-7290 at 3/8/11 9:05 PM:
--------------------------------------------------------------
It is actually issue with
org.eclipse.wst.server.core.internal.ServerPreferenceModifyListener which is listening to
preferences changes and just tries to find /instance/org.eclipse.wst.server.core node in
changed preference node lines 38-39. When it gets to the line 40 runtimes cannot be null
because node method creates node if it cannot find it. Then it goes to the line 48 and
tries to get preference 'runtimes' and sure gets empty string which DOM parser
cannot parse. It reports an error in
com.sun.org.apache.xerces.internal.util.DefaultErrorHandler at the line 95.
{noformat}
// Source of org.eclipse.wst.server.core.internal.ServerPreferenceModifyListener
28 public class ServerPreferenceModifyListener extends PreferenceModifyListener {
29
30 private static final String LOCKED_ATTRIBUTE_NAME = "locked"; //$NON-NLS-1$
31 private static final String RUNTIMES_PREFERENCE_NAME = "runtimes";
//$NON-NLS-1$
32 private static final String RUNTIME_NODE_NAME = "runtime"; //$NON-NLS-1$
33
34 /* (non-Javadoc)
35 * @see
org.eclipse.core.runtime.preferences.PreferenceModifyListener#preApply(org.eclipse.core.runtime.preferences.IEclipsePreferences)
36 */
37 public IEclipsePreferences preApply(IEclipsePreferences node) {
38 Preferences instance = node.node(InstanceScope.SCOPE);
39 Preferences runtimes = instance.node(ServerPlugin.PLUGIN_ID);
40 if (runtimes != null)
41 removeLockedServerRuntimePreference(runtimes); //$NON-NLS-1$
42 return super.preApply(node);
43 }
44
45 private void removeLockedServerRuntimePreference(Preferences preferences) {
46 try {
47 Document doc = DocumentBuilderFactory.newInstance()
48 .newDocumentBuilder().parse(new InputSource(new
StringReader(preferences.get(RUNTIMES_PREFERENCE_NAME, "")))); //$NON-NLS-1$
49 NodeList nodeList = doc.getElementsByTagName(RUNTIME_NODE_NAME);
50 for (int s = 0; s < nodeList.getLength(); s++) {
51 Node node = nodeList.item(s);
52 if (node.getNodeType() == Node.ELEMENT_NODE) {
53 NamedNodeMap attributes = node.getAttributes();
54 Node locked = attributes.getNamedItem(LOCKED_ATTRIBUTE_NAME);
55 if (locked != null && Boolean.parseBoolean(locked.getNodeValue()))
56 node.getParentNode().removeChild(node);
57 }
58 }
59 StringWriter runtimes = new StringWriter();
60 TransformerFactory.newInstance().newTransformer().transform(new
DOMSource(doc), new StreamResult(runtimes));
61 preferences.remove(RUNTIMES_PREFERENCE_NAME);
62 preferences.put(RUNTIMES_PREFERENCE_NAME, runtimes.toString());
63 } catch (Exception e) {
64 //there is no defined runtime environment
65 return;
66 }
67
68 }
69
70 }
{noformat}
was (Author: dgolovin):
It is actually issue with
org.eclipse.wst.server.core.internal.ServerPreferenceModifyListener which is listening to
preferences changes and just tries to find /instance/org.eclipse.wst.server.core node in
changed preference node lines 38-39. When it gets to the line 40 runtimes cannot be null
because node method creates node if it cannot find it. Then it goes to the line 48 and
tries to get preference 'runtimes' and sure gets empty string which DOM parser
cannot parse. It reports an error in
com.sun.org.apache.xerces.internal.util.DefaultErrorHandler at the line 95.
// Source of org.eclipse.wst.server.core.internal.ServerPreferenceModifyListener
28 public class ServerPreferenceModifyListener extends PreferenceModifyListener {
29
30 private static final String LOCKED_ATTRIBUTE_NAME = "locked"; //$NON-NLS-1$
31 private static final String RUNTIMES_PREFERENCE_NAME = "runtimes";
//$NON-NLS-1$
32 private static final String RUNTIME_NODE_NAME = "runtime"; //$NON-NLS-1$
33
34 /* (non-Javadoc)
35 * @see
org.eclipse.core.runtime.preferences.PreferenceModifyListener#preApply(org.eclipse.core.runtime.preferences.IEclipsePreferences)
36 */
37 public IEclipsePreferences preApply(IEclipsePreferences node) {
38 Preferences instance = node.node(InstanceScope.SCOPE);
39 Preferences runtimes = instance.node(ServerPlugin.PLUGIN_ID);
40 if (runtimes != null)
41 removeLockedServerRuntimePreference(runtimes); //$NON-NLS-1$
42 return super.preApply(node);
43 }
44
45 private void removeLockedServerRuntimePreference(Preferences preferences) {
46 try {
47 Document doc = DocumentBuilderFactory.newInstance()
48 .newDocumentBuilder().parse(new InputSource(new
StringReader(preferences.get(RUNTIMES_PREFERENCE_NAME, "")))); //$NON-NLS-1$
49 NodeList nodeList = doc.getElementsByTagName(RUNTIME_NODE_NAME);
50 for (int s = 0; s < nodeList.getLength(); s++) {
51 Node node = nodeList.item(s);
52 if (node.getNodeType() == Node.ELEMENT_NODE) {
53 NamedNodeMap attributes = node.getAttributes();
54 Node locked = attributes.getNamedItem(LOCKED_ATTRIBUTE_NAME);
55 if (locked != null && Boolean.parseBoolean(locked.getNodeValue()))
56 node.getParentNode().removeChild(node);
57 }
58 }
59 StringWriter runtimes = new StringWriter();
60 TransformerFactory.newInstance().newTransformer().transform(new
DOMSource(doc), new StreamResult(runtimes));
61 preferences.remove(RUNTIMES_PREFERENCE_NAME);
62 preferences.put(RUNTIMES_PREFERENCE_NAME, runtimes.toString());
63 } catch (Exception e) {
64 //there is no defined runtime environment
65 return;
66 }
67
68 }
69
70 }
Find out the reason of "[Fatal Error] :1:1: Premature end of
file" in tests
---------------------------------------------------------------------------
Key: JBIDE-7290
URL:
https://issues.jboss.org/browse/JBIDE-7290
Project: Tools (JBoss Tools)
Issue Type: Task
Components: testing, UpStream
Affects Versions: 3.2.0.Beta2
Reporter: Denis Golovin
Assignee: Denis Golovin
Fix For: 3.2.x, 3.3.x
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira