This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 139048 - misconfigured XML parser factory for qa-functional tests
Summary: misconfigured XML parser factory for qa-functional tests
Status: RESOLVED WORKSFORME
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jesse Glick
URL: http://hg.netbeans.org/main/file/tip/...
Keywords: TEST
: 140876 141158 (view as bug list)
Depends on: 157004
Blocks:
  Show dependency tree
 
Reported: 2008-07-04 15:58 UTC by Lukas Jungmann
Modified: 2009-01-21 01:08 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
output from the test run (144.36 KB, text/plain)
2008-07-04 16:07 UTC, Lukas Jungmann
Details
test project's build output (986.49 KB, text/plain)
2008-07-08 14:05 UTC, Lukas Jungmann
Details
Error from wsimport (3.42 KB, text/plain)
2008-07-21 16:49 UTC, Milan Kuchtiak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Jungmann 2008-07-04 15:58:21 UTC
All project related action are failing 

test description:

-open existing Java SE application
-set ant verbosity level to "Debug"
-build project
-wait 5 seconds
-check text in output window - it should contain "BUILD SUCCESSFUL"

=>
  expected: test passes
  actual: test fails in build action with:
...
    [junit] javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
    [junit]         at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:113)
    [junit]         at org.apache.tools.ant.util.JAXPUtils.newParserFactory(JAXPUtils.java:120)
    [junit]         at org.apache.tools.ant.util.JAXPUtils.getNSParserFactory(JAXPUtils.java:104)
    [junit]         at org.apache.tools.ant.util.JAXPUtils.getNamespaceXMLReader(JAXPUtils.java:172)
    [junit]         at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:185)
    [junit]         at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:86)
    [junit]         at org.apache.tools.ant.module.bridge.impl.NbAntlib.process(NbAntlib.java:73)
    [junit]         at org.apache.tools.ant.module.bridge.impl.BridgeImpl.addCustomDefs(BridgeImpl.java:390)
    [junit]         at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:195)
    [junit]         at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:481)
    [junit]         at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
...


to reproduce:

lukas@ubuntu-m9:/space/hg/main$ cd websvc.kit/
lukas@ubuntu-m9:/space/hg/main/websvc.kit$ ant clean test-qa-functional -Dtest.config=parsers


workaround: either run tests with -Djava.endorsed,dirs=/path/to/xerces-2.8.0.jar or put xerces.jar to
$JAVA_HOME/jre/endorsed directory
Comment 1 Lukas Jungmann 2008-07-04 16:07:33 UTC
Created attachment 63951 [details]
output from the test run
Comment 2 Jesse Glick 2008-07-08 00:35:59 UTC
The problem is that javax.xml.parsers.SecuritySupport.getResourceAsStream(null,
"META-INF/services/javax.xml.parsers.SAXParserFactory") calls ClassLoader.getSystemResourceAsStream(...) which returns
non-null (from the app class loader, which sees ide9/modules/ext/xerces.jar) even though the resulting class (in
org.apache.xerces) is invisible to the bootstrap class loader - so newInstance(null, ..., false) is called, and
Class.forName(...) correctly throws CNFE.
Comment 3 Jesse Glick 2008-07-08 01:23:01 UTC
I am trying to work around in core-main #93f3c3fb63d8. The fix is pretty hacky and I am not comfortable with it but I
don't see any better solution.
Comment 4 Jaroslav Tulach 2008-07-08 08:21:18 UTC
I had similar problem in NbModuleSuite. Whenever somebody included xerces on classpath, NetBeans refused to start. I 
did some different tricks in NetBeans DOM and SAX factories. Probably I played with context classloader until I was 
able to start: http://hg.netbeans.org/core-main/rev/badd42b05bc7
Comment 5 Jesse Glick 2008-07-08 13:36:49 UTC
The problem in this case is different, I think. System properties request the factories in core.startup, but these are
not visible to the Ant class loader, and they are ignored by JAXP, which falls back to the usual META-INF/services
search. The problem here is that the CCL does not delegate to the "system" class loader, i.e. -classpath. (Intentionally
- we try to run Ant in a controlled environment.) JAXP is unprepared for this situation.
Comment 6 Lukas Jungmann 2008-07-08 14:04:26 UTC
Thanks, original issue is fixed - I can build, run, deploy etc. all project types now except those which calls ie.
wsimport task - ant's output is attached.

Should I file a new issue for that or it's enough to just reopen this one (steps to reproduce remain the same - I've
updated a test project in #6414769ab162)?

Comment 7 Lukas Jungmann 2008-07-08 14:05:52 UTC
Created attachment 64083 [details]
test project's build output
Comment 8 Jesse Glick 2008-07-08 14:10:01 UTC
It looks like the same issue, just in a different JAXP package.
Comment 9 Jesse Glick 2008-07-08 14:18:17 UTC
Should be generalized in core-main #5a19718c2ad5 to work on all JAXP-related services.
Comment 10 Quality Engineering 2008-07-09 04:11:06 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #308 build
Changeset: http://hg.netbeans.org/main/rev/93f3c3fb63d8
User: Jesse Glick <jglick@netbeans.org>
Log: #139048: work around complex class loading problem in JAXP.
Comment 11 Quality Engineering 2008-07-10 04:12:30 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #310 build
Changeset: http://hg.netbeans.org/main/rev/5a19718c2ad5
User: Jesse Glick <jglick@netbeans.org>
Log: #139048 generalized to all of JAXP, not just the parsers package.
Comment 12 Lukas Jungmann 2008-07-14 17:08:35 UTC
well, tests are fixed but the problem is that ws support in the IDE becomes broken :-(

what I mean is that in tests everything works fine but when you run only standalone IDE and create new ws client in java
se project then wsimport fails with:

...
wsimport-client-MyWebService:
C:\NetBeansProjects\JavaApplication2\build\generated\wsimport\client\mywebservice\wsdl is not found and thus excluded
from the dependency check
parsing WSDL...


javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found
        at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
        at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
        at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
        at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
        at com.sun.xml.ws.api.streaming.XMLStreamReaderFactory.<clinit>(XMLStreamReaderFactory.java:87)
        at com.sun.xml.ws.api.addressing.WSEndpointReference.<init>(WSEndpointReference.java:166)
        at com.sun.xml.ws.api.addressing.AddressingVersion.<init>(AddressingVersion.java:436)
...

note that MXParserFactory is on the classpath...

I'll check whether using some JAXP properties for running tests will help (as discussed with Jarda last week) and will
update this issue
Comment 13 Milan Kuchtiak 2008-07-14 17:35:54 UTC
To reproduce the issue - please, create rather the WS Client in Web Application.
E.g. use this wsdl url : http://www.webservicex.net/CurrencyConvertor.asmx?wsdl
Then, the wsimport ant task fails as described by Lukas.

(In J2SE problem there is another problem now with missing libraries in wsimport ant task)

Note: the problem seems to be reprodicible in jdk1.5 only.
Comment 14 Lukas Jungmann 2008-07-14 20:14:19 UTC
strange things happens...

I've reverted #93f3c3fb63d8 in my local workspace and IDE as well as tests seems to be happy, at least on my
1.5.0_16-rev-b03
Comment 15 Jesse Glick 2008-07-15 02:19:08 UTC
If I comment out the workaround then I go back to the old behavior - a failure to find Xerces.

javax.xml.stream.XMLInputFactory is another case. Here, both the API and the impl are part of jaxws, not the JRE.
(Specifically, jsr173_api.jar and sjsxp.jar.) The BEA-designed API uses as a fallback class name a class which is not
part of the RI (!), or indeed the NetBeans IDE, so you _have_ to use the version specified in META-INF/services. The
FactoryFinder clone also differs from that used in JAXP - it has different logic for finding M-I/s resources. The result
is that the workaround for JAXP services does not work for StAX and in fact makes things worse.

One fix that appears to work is:

if (name.equals("META-INF/services/javax.xml.stream.XMLInputFactory")) {
  return super.getResourceAsStream(name);
} else if (name.startsWith("META-INF/services/javax.xml.")) {
  // as before...

but I am looking for a cleaner fix.
Comment 16 Jesse Glick 2008-07-15 02:59:25 UTC
Can't find any better fix so going with the removal of the workaround just for StAX (core-main #8e2336205ff3). Seems to
work both in interactive IDE and from your test in both JDK 5 and 6. Note that your test fails even though the build
does succeed in the tested IDE; something wrong with your OW capture operator, perhaps.
Comment 17 Quality Engineering 2008-07-17 04:47:36 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #324 build
Changeset: http://hg.netbeans.org/main/rev/8e2336205ff3
User: Jesse Glick <jglick@netbeans.org>
Log: Disabling #139048 fix for StAX.
Comment 18 Milan Kuchtiak 2008-07-21 16:49:00 UTC
We've got a different error when running wsimport (JAX_WS 2.1) in J2SEProject.
See the attachment.

This is related somehow to this fix in org.apache.tools.ant.module.bridge.AntBridge.  
Comment 19 Milan Kuchtiak 2008-07-21 16:49:56 UTC
Created attachment 65152 [details]
Error from wsimport
Comment 20 Milan Kuchtiak 2008-07-21 16:52:55 UTC
One important note:
This only happens with jdk1.6 (update 10), not jdk1.5.
Comment 21 Milan Kuchtiak 2008-07-21 17:50:44 UTC
I am sorry.
The issue 140966 was likely caused by incorrect JAXB separation from JAX-WS.
Comment 22 Martin Grebac 2008-07-22 13:37:30 UTC
*** Issue 141158 has been marked as a duplicate of this issue. ***
Comment 23 Martin Grebac 2008-07-22 13:37:40 UTC
*** Issue 140876 has been marked as a duplicate of this issue. ***