Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

org.omnifaces.FACES_VIEWS_SCAN_PATHS only works when running with quarkus:dev #83

Open
newk5 opened this issue Jan 21, 2022 · 5 comments

Comments

@newk5
Copy link

newk5 commented Jan 21, 2022

Extensionless mapping only seems to work when running the application with quarkus:dev.

After packaging the app with: mvn package and running the final jar, it doesn't work. There is no error message, just shows an empty page saying "Not found"

@melloware
Copy link
Contributor

I have a feeling the bug is here:

@SuppressWarnings("unchecked")
	private static Set<String[]> getRootPathsAndExtensions(ServletContext servletContext) {
		Set<String[]> rootPaths = (Set<String[]>) servletContext.getAttribute(SCAN_PATHS);

		if (rootPaths == null) {
			rootPaths = new HashSet<>();
			rootPaths.add(new String[] { WEB_INF_VIEWS, null });
			Set<String> multiViewsPaths = new TreeSet<>(Collator.getInstance(ENGLISH)); // Makes sure ! is sorted before /.

			for (String rootPath : csvToList(servletContext.getInitParameter(FACES_VIEWS_SCAN_PATHS_PARAM_NAME))) {
				boolean multiViews = rootPath.endsWith("/*");

				if (multiViews) {
					rootPath = rootPath.substring(0, rootPath.lastIndexOf("/*"));
				}

				String[] rootPathAndExtension = rootPath.contains("*") ? rootPath.split(quote("*")) : new String[] { rootPath, null };
				rootPathAndExtension[0] = normalizeRootPath(rootPathAndExtension[0]);
				rootPaths.add(rootPathAndExtension);

				if (multiViews) {
					multiViewsPaths.add(rootPathAndExtension[0]);
				}
			}

			servletContext.setAttribute(SCAN_PATHS, unmodifiableSet(rootPaths));
			servletContext.setAttribute(MULTIVIEWS_PATHS, unmodifiableSet(multiViewsPaths));
		}

		return rootPaths;
	}

OmniFaces must not be scanning or calculating something correctly with Quarkus since Quarkus uses different paths /resources instead of /WEB-INF ?

@newk5
Copy link
Author

newk5 commented Jan 22, 2022

Yea it could be. Quarkus has 2 packaging modes, the new "fast-jar" mode which is the default and quarkus.package.type=uber-jar which creates an uber jar. For now, uber-jar packaging mode is broken with myfaces (see here ), so I'm using "fast-jar" mode, for anyone else looking into this, make sure you're not using quarkus.package.type=uber-jar

@melloware
Copy link
Contributor

Hey when I create a fast-jar iwth my Quarkus Faces showcase and run java -jar target/quarkus-app/quarkus-run.jar I am getting this error:

Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
        ... 15 more
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
        at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
        at org.omnifaces.util.Xml.createDocumentBuilder(Xml.java:83)

Have you seen this error before?

@melloware
Copy link
Contributor

weird i had to add

        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.12.1</version>
        </dependency>
        <dependency>
            <groupId>com.guicedee.services</groupId>
            <artifactId>xalan</artifactId>
            <version>1.2.0.3-jre17-rc1</version>
        </dependency>

to make it work.

@newk5
Copy link
Author

newk5 commented Jan 22, 2022

Strange, I never had that error, nor do I have any of those dependencies.
I am on JDK17 and Quarkus 2.6.2.Final, MF 2.3-next-M6, Omnifaces 3.11.2 with Omnifaces-quarkus 1.4.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants