[
https://issues.apache.org/jira/browse/DERBY-6637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14043366#comment-14043366
]
Knut Anders Hatlen commented on DERBY-6637:
-------------------------------------------
The tests pass if I run them with the flag "-Djava.security.policy=<NONE>" to
disable the security manager.
There seems to be a bug in IBM's XPath implementation that makes it fail with a
runtime exception when constructing an error message, and the underlying
XPathExpressionException is shadowed by the runtime exception (a
java.util.MissingResourceException).
Can be seen by executing this code snippet:
{code}
XPathFactory.newInstance().newXPath().compile("1+1").evaluate(
new InputSource(new StringReader("<doc/>")),
XPathConstants.NODESET);
{code}
With IBM 7.1, without a security manager, I see the expected error:
{noformat}
org.apache.xpath.XPathException: Can not convert #NUMBER to a NodeList!
at org.apache.xpath.objects.XObject.error(Unknown Source)
at org.apache.xpath.objects.XObject.nodelist(Unknown Source)
at org.apache.xpath.jaxp.XPathExpressionImpl.xObjectToObject(Unknown
Source)
at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(Unknown Source)
at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(Unknown Source)
at Derby6637.main(Derby6637.java:10)
{noformat}
If I enable the security manager, a runtime exception is thrown instead by the
method that's generating the XPathException:
{noformat}
java.util.MissingResourceException: Could not load any resource
bundles.org.apache.xpath.res.XPATHErrorResources
at org.apache.xml.res.XMLMessages.loadResourceBundle(Unknown Source)
at org.apache.xpath.res.XPATHMessages.createXPATHMessage(Unknown Source)
at org.apache.xpath.objects.XObject.error(Unknown Source)
at org.apache.xpath.objects.XObject.nodelist(Unknown Source)
at org.apache.xpath.jaxp.XPathExpressionImpl.xObjectToObject(Unknown
Source)
at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(Unknown Source)
at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(Unknown Source)
at Derby6637.main(Derby6637.java:10)
{noformat}
With Oracle's JVMs, the "Can not convert #NUMBER to a NodeList" exception is
thrown both with and without security manager. I believe that is the correct
behaviour.
The reason why this is causing problems after DERBY-6624, is that we now
evaluate XPath queries with the NODESET argument even though we don't know for
sure that a NODESET will be returned. We expect an exception to be raised in
that case, and retry with a different type. The exception we expect is an
XPathExpressionException, not a MissingResourceException, so that logic fails
on the IBM VMs when a security manager is used.
The problem can also be observed before DERBY-6624. For example, if I execute
this ij script on 10.10.2.0
{code:sql}
connect 'jdbc:derby:memory:db;create=true';
create table t(x xml);
insert into t values xmlparse(document '<doc/>' preserve whitespace);
-- Expect a failure because the XPath expression contains a syntax error:
select xmlexists('1+' passing by ref x) from t;
{code}
and execute it on IBM 7.1, I see this expected exception if I run without a
security manager:
{noformat}
ij> select xmlexists('1+' passing by ref x) from t;
ERROR 10000: Encountered error while evaluating XML query expression for
xmlexists operator: A location path was expected, but the end of the XPath
expression was found instead.
{noformat}
However, if I run the same script with a security manager and a security policy
that grants java.security.AllPermission to derby.jar and derbytools.jar, I get
a missing resource exception:
{noformat}
ij> select xmlexists('1+' passing by ref x) from t;
ERROR 10000: Encountered error while evaluating XML query expression for
xmlexists operator: Could not load any resource
bundles.org.apache.xpath.res.XPATHErrorResources
{noformat}
In this case the bug doesn't cause any big problems. The query is supposed to
fail in any case, we just don't get the details when the security manager is
enabled because the MissingResourceException hides the original exception.
Oracle's JVMs raise the former exception in both cases.
> test errors failures in lang.XMLTypeAndOpsTest, XMLBindingTest and
> XMLConcurrencyTest with ibm jvms
> ---------------------------------------------------------------------------------------------------
>
> Key: DERBY-6637
> URL: https://issues.apache.org/jira/browse/DERBY-6637
> Project: Derby
> Issue Type: Bug
> Components: Test
> Affects Versions: 10.11.0.0
> Environment: windows and linux, with ibm 1.6, 1.7
> Reporter: Myrna van Lunteren
> Assignee: Knut Anders Hatlen
> Attachments: derby.log, error-stacktrace.out
>
>
> With trunk built at revision 1604994, I see errors and failures like the
> following:
> 1)
> testXMLQuery(org.apache.derbyTesting.functionTests.tests.lang.XMLTypeAndOpsTest)java.sql.SQLException:
> Encountered error while evaluating XML query expression for XMLQUERY
> operator: Could not load any resource
> bundles.org.apache.xpath.res.XPATHErrorResources
> at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
> at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
> at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
> at
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown
> Source)
> at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown
> Source)
> at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedResultSet.closeOnTransactionError(Unknown
> Source)
> at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(Unknown
> Source)
> at org.apache.derby.impl.jdbc.EmbedResultSet.next(Unknown Source)
> at
> org.apache.derbyTesting.junit.JDBC.assertFullResultSetMinion(JDBC.java:1075)
> at
> org.apache.derbyTesting.junit.JDBC.assertFullResultSet(JDBC.java:1025)
> at org.apache.derbyTesting.junit.JDBC.assertFullResultSet(JDBC.java:982)
> at
> org.apache.derbyTesting.functionTests.tests.lang.XMLTypeAndOpsTest.testXMLQuery(XMLTypeAndOpsTest.java:1618)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
> at
> org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:118)
> at
> org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:440)
> at
> org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:457)
> at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
> at junit.extensions.TestSetup.run(TestSetup.java:25)
> at
> org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> Caused by: ERROR 10000: Encountered error while evaluating XML query
> expression for XMLQUERY operator: Could not load any resource
> bundles.org.apache.xpath.res.XPATHErrorResources
> at org.apache.derby.iapi.error.StandardException.newException(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown
> Source)
> ... 49 more
> Caused by: java.util.MissingResourceException: Could not load any resource
> bundles.org.apache.xpath.res.XPATHErrorResources
> at
> org.apache.xml.res.XMLMessages.loadResourceBundle(XMLMessages.java:189)
> at
> org.apache.xpath.res.XPATHMessages.createXPATHMessage(XPATHMessages.java:53)
> at org.apache.xpath.objects.XObject.error(XObject.java:701)
> at org.apache.xpath.objects.XObject.nodelist(XObject.java:455)
> at
> org.apache.xpath.jaxp.XPathExpressionImpl.getResultAsType(XPathExpressionImpl.java:357)
> at
> org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:100)
> at
> org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:184)
> at org.apache.derby.iapi.types.SqlXmlUtil.evaluate(Unknown Source)
> at org.apache.derby.iapi.types.SqlXmlUtil.evalXQExpression(Unknown
> Source)
> at org.apache.derby.iapi.types.XML.XMLQuery(Unknown Source)
> at
> org.apache.derby.exe.acf63284d8x0146xcb97x285bx000029929fd62.e0(Unknown
> Source)
> at org.apache.derby.impl.services.reflect.DirectCall.invoke(Unknown
> Source)
> at
> org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.doProjection(Unknown
> Source)
> at
> org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(Unknown
> Source)
> at
> org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(Unknown
> Source)
> ... 41 more
> See for instance this windows/ibm1.6 result:
> http://people.apache.org/~myrnavl/derby_test_results/main/windows/testlog/ibm16/1604993-suites.All_diff.txt
--
This message was sent by Atlassian JIRA
(v6.2#6252)