Skip to content

Conversation

@slawekjaranowski
Copy link
Member

@slawekjaranowski slawekjaranowski commented Jan 18, 2026

A web application may include classes provided by dependency artifacts. Class references defined in web.xml are now recognized as main used classes.


Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

A web application may include classes provided by dependency artifacts.
Class references defined in web.xml are now recognized as main used classes.
@slawekjaranowski slawekjaranowski self-assigned this Jan 18, 2026
@slawekjaranowski slawekjaranowski added the enhancement New feature or request label Jan 18, 2026
throws IOException, SAXException, XPathExpressionException, ParserConfigurationException {

DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to set the namespace feature to true here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I set:

        documentBuilderFactory.setNamespaceAware(true);

xpath stops working .... we can have web.xml in both namespace ... javaee - old and jakartaee

it will be more complicated to build xpath

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the the xpath stops working, then the xpath is wrong. You likely have two errors that are cancelling each other out, but that's very brittle.

web.xml in both namespaces is a problem, and that's a big reason not to change namespaces with new versions. It causes exactly this sort of problem.

You can match on the local-name() instead or rearrange the code to use separate paths for the two different namespaces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done use namespace with local-name


try {
return processWebXml(webXml, excludedClasses);
} catch (ParserConfigurationException | XPathExpressionException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both of these would indicate a bug in the code. IN the the XPath case that's because the XPath expression is fully within this code and not passed in from the environment. Assuming I'm right about that, this could reasonably be a runtime exception.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have already IOException in method definition so can be used ... I can change to runtime ... but will be the same
as you write such exceptions should not occur at all

This comment was marked as off-topic.

throws IOException, SAXException, XPathExpressionException, ParserConfigurationException {

DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the the xpath stops working, then the xpath is wrong. You likely have two errors that are cancelling each other out, but that's very brittle.

web.xml in both namespaces is a problem, and that's a big reason not to change namespaces with new versions. It causes exactly this sort of problem.

You can match on the local-name() instead or rearrange the code to use separate paths for the two different namespaces.

private XPathExpression[] getXPathExpression() throws XPathExpressionException {
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xpath = xPathFactory.newXPath();
return new XPathExpression[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed you have multiple XPath expressions here already, so you probably should just double them up, one for each namespace. You will need to provide a NamespaceContext object that binds the prefixes you use here to the actual namespace URIs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I use local-name I don't need a NamespaceContext.

I don't want to complicate it so much.
Goal is to take some values from web.xml not verifying it.

In case of wrong namespaces, missing namespaces in web.xml I don't want to break a build it and so ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did as you propose:

You can match on the local-name() instead or rearrange the code to use separate paths for the two different namespaces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elharo any other remarks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants