Home > Enterprise >  GlassFish 6.2.3 does not see javax.faces.webapp.FacesServlet
GlassFish 6.2.3 does not see javax.faces.webapp.FacesServlet

Time:12-23

I am using glassfish6.2.3 on my local computer. If I add these lines to web.xml

 <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>

then 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) at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(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)

Otherwise, everything works fine, but the jsf-elements are not displayed

CodePudding user response:

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.

  • Related