A
A
Alexander2021-12-21 15:23:10
Java
Alexander, 2021-12-21 15:23:10

Why doesn't GlassFish 6.2.3 see javax.faces.webapp.FacesServlet?

Hello! Please help, glassfish refuses to accept servlet's faces mapping in the web.xml file.
The following lines:

<servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>


Without this config, everything works fine, but, of course, it does not display jsf elements. And when I add mapping, the following error occurs:
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1577)
at org.glassfish.web.loader .WebappClassLoader.loadClass(WebappClassLoader.java:1427)
at org.apache.catalina.core.StandardWrapper.loadServletClass(StandardWrapper.java:1391)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1257)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1239)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5343)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5588)
at com.sun.enterprise.web.WebModule.start(WebModule.java:510)
at org.apache.catalina.core.ContainerBase.addChildInternal (ContainerBase.java:877)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:860)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:644)
at com.sun. enterprise.web.WebContainer.loadWebModule(WebContainer.java:2020)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1666)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java: 82)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:98)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:267)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:328)
at com.sun.enterprise.v3.server.ApplicationLifecycle .deploy(ApplicationLifecycle.java:480)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:199)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:467)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:516)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:512)
at java.base/ java.security.AccessController.doPrivileged(Native Method)
at java.base/javax.security.auth.Subject.doAs(Subject.java:361)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:511)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:542)
at com.sun.enterprise .v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:534)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/javax.security.auth.Subject.doAs(Subject.java :361)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:533)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1441)
at com.sun. enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1823)
at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:140)
at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:573
) (AutoDeployer.java:460)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:388)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:379)
at org.glassfish. deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:209)
at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
at java.base/java.util.TimerThread.run(Timer.java :506)


Tried other versions of glassfish, but it's not any better...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-12-22
@SharkVale

In general, they answered me on stackoverflow. I'll leave this answer here in case someone suddenly encounters the same problem)
GlassFish 6.2.3 implements Jakarta EE 9.1 and Faces 3.0. These use the Jakarta namespace. Your servlet declaration should therefor be:

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
</servlet>

Note that instead of defining a servlet in web.xml, you can also make use of the @FacesConfig annotation in your application. This will default map all your views to .xhtml.

D
Dmitry Roo, 2021-12-21
@xez

java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
Means jvm can't find required class in classpath
Try putting it there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question