java.lang.classnotfoundexception:jakarta.faces.context.facescontextfactory

发布于 2025-02-13 22:57:24 字数 21864 浏览 0 评论 0原文

我现在试图解决此问题三天,而没有成功。 我从事JSF项目工作了几个星期,遇到了问题,几天前我的tomcat不再有任何事情都没有开始。因此,我尝试修复它,甚至重新安装Tomcat,Eclipse并再次设置该项目,几乎没有成功。现在tomcat再次开始,但它向我展示了:

浏览器中的错误消息 它说:

“ HTTP状态404 - 找不到
类型:状态报告
消息:请求的资源[/immobiliendatenbank/mainboard.xhtml]不可用
描述:原始服务器没有找到目标资源的当前表示形式,也不愿意透露一个存在。 apache tomcat/10.0.13“

我不知道为什么,并尝试了堆栈溢出和其他网站的许多建议,这些建议被发布给有类似问题但无效的人。

以下是该项目的更多详细信息,我认为可能会提出线索:

console log:

Critical error during deployment: 
java.lang.NoClassDefFoundError: jakarta/faces/context/FacesContextFactory
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:467)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1428)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1252)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:467)
    at jakarta.faces.FactoryFinderInstance.getImplGivenPreviousImpl(FactoryFinderInstance.java:410)
    at jakarta.faces.FactoryFinderInstance.getImplementationInstance(FactoryFinderInstance.java:338)
    at jakarta.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:183)
    at jakarta.faces.FactoryFinder.getFactory(FactoryFinder.java:264)
    at com.sun.faces.config.processor.FactoryConfigProcessor.lambda$verifyFactoriesExist$0(FactoryConfigProcessor.java:289)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:283)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:198)
    at com.sun.faces.config.ConfigManager.lambda$initialize$0(ConfigManager.java:263)
    at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:261)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:206)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4715)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:886)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:795)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
Caused by: java.lang.ClassNotFoundException: jakarta.faces.context.FacesContextFactory
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 60 more

我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ===========================================================================
  web.xml - Last update ==> <display-name>
  Verzeichnis: {Projekt}/WebContent/WEB-INF/
  Version für TomEE 9
============================================================================ -->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>Immobiliendatenbak</display-name>
  <description>web xml fuer die Immobiliendatenbank 
 
  </description>
  <welcome-file-list>
    <welcome-file>mainBoard.xhtml</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
   
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>jakarta.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>
    <url-pattern>*.xhtml</url-pattern>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
 
  <session-config>
    <session-timeout>35</session-timeout>
  </session-config>
  <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html;charset=UTF-8</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>txt</extension>
    <mime-type>text/plain;charset=UTF-8</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>png</extension>
    <mime-type>image/png</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>svg</extension>
    <mime-type>image/svg+xml</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>ttf</extension>
    <mime-type>application/font-sfnt</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>jpg</extension>
    <mime-type>image/jpeg</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>gif</extension>
    <mime-type>image/gif</mime-type>
  </mime-mapping>
  <context-param>
    <param-name>jakarta.faces.ENABLE_CDI_RESOLVER_CHAIN</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>jakarta.faces.validator.ENABLE_VALIDATE_WHOLE_BEAN</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>jakarta.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>0</param-value>
  </context-param>
  <context-param>
    <description>true: Kommentare entfernen. (Ist eine Alternative zu ui:remove)
    </description>
    <param-name>jakarta.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>jakarta.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.jsf;*.xhtml</param-value>
  </context-param>
  <context-param>
    <description>Valid values: Development, Production, SystemTest and
                               UnitTest
    </description>
    <param-name>jakarta.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>
  <context-param>
    <description>If true, rendered HTML code will be formatted, so that it is
     'human-readable' i.e. additional line separators and whitespace will be
      written, that do not influence the HTML code. Default is 'true'
    </description>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param>
 
</web-app>

我的faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config>

<!-- ===========================================================================
  faces-config.xml - JSF 3.0 Konfigurationsdatei
  Verzeichnis: {Projekt}/WebContent/WEB-INF/
  Version: 2021-12-04
============================================================================ -->

<faces-config version="2.3" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                            
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee  
              http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"> 
 
  <application>
    
    <locale-config>
      <default-locale>de</default-locale>
      <supported-locale>en</supported-locale>
    </locale-config>
     
  </application> 
  <navigation-rule>   
    <from-view-id>/insertBoard.xhtml</from-view-id>
    
    
    <navigation-case>
      <from-outcome>user</from-outcome>
      <to-view-id>/user.xhtml</to-view-id>
    </navigation-case>
    
    <navigation-case>
      <from-outcome>admin</from-outcome>
      <to-view-id>/admin.xhtml</to-view-id>
      <redirect/>
    </navigation-case>    
  </navigation-rule>

  <managed-bean>
    <managed-bean-name>mb_db</managed-bean-name>
    <managed-bean-class>net.lehre_online.bw.DatabaseConection</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>

    <managed-property>
      <description>true: Connections werden über einen Connection pool 
                         verwaltet
      </description>
      <property-name>use_pool</property-name>
      <value>false</value>      
    </managed-property>
        
    <managed-property>
      <property-name>user</property-name>            
      <value>user</value>      
    </managed-property>
    
    <managed-property>
      <property-name>pw</property-name>      
      <value>password</value><!--  FAlls PAsswort bei der MySql Datenbank -->
    </managed-property>
    
    <managed-property>
      <property-name>constr</property-name>
      <value>jdbc:mysql://localhost:3306/db</value>
    </managed-property>
    
     <managed-property>
      <property-name>logfile</property-name>
      <value>browse.log</value>
    </managed-property>    
  </managed-bean>
  
</faces-config>

以及我右键在eclipse中右键单击的XHTML网站之一(运行为 - &gt;在服务器上运行):

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>

<!-- ===========================================================================
login.xhtml - Startseite für Navigationsbeispiel                  
============================================================================ -->

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>

<h:body>
    <ui:composition template="/masterLayout.xhtml">

        <ui:define name="title">Immobiliensuche</ui:define>

        <ui:define name="content">
            <h:form>



                <h4>Bitte geben Sie alle benötiigten Daten ein die uns helfen
                    könnten Ihre Traumimobilie zu finden.</h4>


                <div class="container overflow-hidden">
                    <div class="row gy-9">

                        <!-- Dropdown auswhl möglichkeiten -->
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="Immo-wrapping">Immobilienart:</span>
                            <p:selectOneMenu class="coll-5" id="auswahlImmobilienart"
                                value="#{MbSuchmaske.immobilienart}">
                                <f:selectItem itemLabel="Klicken zum auswählen!" itemValue="" />
                                <f:selectItem itemLabel="Eigentumswohnung"
                                    itemValue="Eigentumswohnung" />
                                <f:selectItem itemLabel="Einfamilienhaus"
                                    itemValue="Einfamilienhaus" />
                                <f:selectItem itemLabel="Mehrfamilienhaus"
                                    itemValue="Mehrfamilienhaus" />
                                <f:selectItem itemLabel="Reihenhaus" itemValue="Reihenhaus" />
                                <f:selectItem itemLabel="Grundstück" itemValue="Grundstück" />

                            </p:selectOneMenu>
                        </div>
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="Immo-wrapping">Stadt:</span>
                            <p:selectOneMenu id="stadtAuswahl" value="#{MbSuchmaske.stadt}">
                                <f:selectItem itemLabel="Klicken zum auswählen!" itemValue="" />
                                <f:selectItem itemLabel="Berlin" itemValue="Berlin" />
                                <f:selectItem itemLabel="Hamburg" itemValue="Hamburg" />
                                <f:selectItem itemLabel="München" itemValue="München" />
                                <f:selectItem itemLabel="Köln" itemValue="Köln" />

                            </p:selectOneMenu>
                        </div>
                        <h3>Zum verfeinern der Suche:</h3>
                        <H5></H5>
                        <h4>Die Grundfläche:</h4>
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Minimale Grundfläche</span> <label for="customRange2"
                                class="form-label"></label>
                            <h:inputHidden id="minGrundflaeche_id" min="0" max="10000"
                                value="#{MbSuchmaske.minGrundflaeche}" />
                            <p:slider for="minGrundflaeche_id"
                                display="output_minGrundflaeche" minValue="0" maxValue="10000"
                                class="form-range" displayTemplate="{value} m²" />
                            <h:outputText id="output_minGrundflaeche"
                                value="#{MbSuchmaske.minGrundflaeche}" />
                        </div>

                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Maximale Grundfläche</span> <label for="customRange2"
                                class="form-label"></label>
                            <h:inputHidden id="maxGrundflaeche_id" min="0" max="10000"
                                value="#{MbSuchmaske.maxGrundflaeche}" />
                            <p:slider for="maxGrundflaeche_id"
                                display="output_maxGrundflaeche" minValue="0" maxValue="10000"
                                class="form-range" displayTemplate="{value} m²" />
                            <h:outputText id="output_maxGrundflaeche"
                                value="#{MbSuchmaske.maxGrundflaeche}" />
                        </div>
                        <h4>Die Wohnfläche:</h4>
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Minimale Wohnfläche</span> <label for="customRange2" class="form-label"></label>
                            <h:inputHidden id="minWohnflaeche_id" min="0" max="1000"
                                value="#{MbSuchmaske.minWohnflaeche}" />
                            <p:slider for="minWohnflaeche_id" display="output_minWohnflaeche"
                                minValue="0" maxValue="1000" class="form-range"
                                displayTemplate="{value} m²" />
                            <h:outputText id="output_minWohnflaeche"
                                value="#{MbSuchmaske.minWohnflaeche}" />
                        </div>

                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Maximale Wohnfläche</span> <label for="customRange2" class="form-label"></label>
                            <h:inputHidden id="maxWohnflaeche_id" min="0" max="1000"
                                value="#{MbSuchmaske.maxWohnflaeche}" />
                            <p:slider for="maxWohnflaeche_id" display="output_maxWohnflaeche"
                                minValue="0" maxValue="1000" class="form-range"
                                displayTemplate="{value} m²" />
                            <h:outputText id="output_maxWohnflaeche"
                                value="#{MbSuchmaske.maxWohnflaeche}" />
                        </div>

                        <h4>Preis</h4>
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Maximaler Immobilienpreis</span> <label for="customRange2"
                                class="form-label"></label>
                            <h:inputHidden id="preis_id" min="0" max="1000000"
                                value="#{MbSuchmaske.preis}" />
                            <p:slider for="preis_id" display="output_preis" minValue="0"
                                maxValue="1000000" class="form-range"
                                displayTemplate="{value} €" />
                            <h:outputText id="output_preis" value="#{MbSuchmaske.preis}" />
                        </div>

                    </div>

                </div>




                <div class="container overflow-hidden">
                    <div class="row gy-9">

                        <h:commandButton value="Suchen!"
                            actionListener="#{MbSuchmaske.suchErgebnis}"
                            action="resultBoard.xhtml" />
                    </div>
                </div>

            </h:form>

        </ui:define>
    </ui:composition>

</h:body>
</html>

我使用Eclipse IDE for Enterprise Java和Web开发人员的版本:2022-03(4.23.0)
Apache Tomcat 10.0.13

我希望任何人都可以帮助我。

I'm now trying to fix this for three days without success.
I was working on a JSF Project for a few weeks and had non problems and without knowingly changing anything a few days ago my tomcat did not start anymore. So I tried fixing it and even reinstalled tomcat, eclipse and set up the project again with little success. Now tomcat starts again but it shows me this:

Error message in browser
It says:

"HTTP Status 404 – not found
Type: Status Report
Message: The requested resource [/Immobiliendatenbank/mainBoard.xhtml] is not available
Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/10.0.13"

I don't know why and tried so many suggestions from stack overflow and other sites which got posted to people with similar problems but nothing works.

Here are more details of the project that I think might give a clue:

Console Log:

Critical error during deployment: 
java.lang.NoClassDefFoundError: jakarta/faces/context/FacesContextFactory
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:467)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1428)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1252)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:467)
    at jakarta.faces.FactoryFinderInstance.getImplGivenPreviousImpl(FactoryFinderInstance.java:410)
    at jakarta.faces.FactoryFinderInstance.getImplementationInstance(FactoryFinderInstance.java:338)
    at jakarta.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:183)
    at jakarta.faces.FactoryFinder.getFactory(FactoryFinder.java:264)
    at com.sun.faces.config.processor.FactoryConfigProcessor.lambda$verifyFactoriesExist$0(FactoryConfigProcessor.java:289)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:283)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:198)
    at com.sun.faces.config.ConfigManager.lambda$initialize$0(ConfigManager.java:263)
    at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:261)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:206)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4715)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:886)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:795)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
Caused by: java.lang.ClassNotFoundException: jakarta.faces.context.FacesContextFactory
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 60 more

My web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ===========================================================================
  web.xml - Last update ==> <display-name>
  Verzeichnis: {Projekt}/WebContent/WEB-INF/
  Version für TomEE 9
============================================================================ -->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>Immobiliendatenbak</display-name>
  <description>web xml fuer die Immobiliendatenbank 
 
  </description>
  <welcome-file-list>
    <welcome-file>mainBoard.xhtml</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
   
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>jakarta.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>
    <url-pattern>*.xhtml</url-pattern>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
 
  <session-config>
    <session-timeout>35</session-timeout>
  </session-config>
  <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html;charset=UTF-8</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>txt</extension>
    <mime-type>text/plain;charset=UTF-8</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>png</extension>
    <mime-type>image/png</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>svg</extension>
    <mime-type>image/svg+xml</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>ttf</extension>
    <mime-type>application/font-sfnt</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>jpg</extension>
    <mime-type>image/jpeg</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>gif</extension>
    <mime-type>image/gif</mime-type>
  </mime-mapping>
  <context-param>
    <param-name>jakarta.faces.ENABLE_CDI_RESOLVER_CHAIN</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>jakarta.faces.validator.ENABLE_VALIDATE_WHOLE_BEAN</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>jakarta.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>0</param-value>
  </context-param>
  <context-param>
    <description>true: Kommentare entfernen. (Ist eine Alternative zu ui:remove)
    </description>
    <param-name>jakarta.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>jakarta.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.jsf;*.xhtml</param-value>
  </context-param>
  <context-param>
    <description>Valid values: Development, Production, SystemTest and
                               UnitTest
    </description>
    <param-name>jakarta.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>
  <context-param>
    <description>If true, rendered HTML code will be formatted, so that it is
     'human-readable' i.e. additional line separators and whitespace will be
      written, that do not influence the HTML code. Default is 'true'
    </description>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param>
 
</web-app>

My faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config>

<!-- ===========================================================================
  faces-config.xml - JSF 3.0 Konfigurationsdatei
  Verzeichnis: {Projekt}/WebContent/WEB-INF/
  Version: 2021-12-04
============================================================================ -->

<faces-config version="2.3" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                            
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee  
              http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"> 
 
  <application>
    
    <locale-config>
      <default-locale>de</default-locale>
      <supported-locale>en</supported-locale>
    </locale-config>
     
  </application> 
  <navigation-rule>   
    <from-view-id>/insertBoard.xhtml</from-view-id>
    
    
    <navigation-case>
      <from-outcome>user</from-outcome>
      <to-view-id>/user.xhtml</to-view-id>
    </navigation-case>
    
    <navigation-case>
      <from-outcome>admin</from-outcome>
      <to-view-id>/admin.xhtml</to-view-id>
      <redirect/>
    </navigation-case>    
  </navigation-rule>

  <managed-bean>
    <managed-bean-name>mb_db</managed-bean-name>
    <managed-bean-class>net.lehre_online.bw.DatabaseConection</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>

    <managed-property>
      <description>true: Connections werden über einen Connection pool 
                         verwaltet
      </description>
      <property-name>use_pool</property-name>
      <value>false</value>      
    </managed-property>
        
    <managed-property>
      <property-name>user</property-name>            
      <value>user</value>      
    </managed-property>
    
    <managed-property>
      <property-name>pw</property-name>      
      <value>password</value><!--  FAlls PAsswort bei der MySql Datenbank -->
    </managed-property>
    
    <managed-property>
      <property-name>constr</property-name>
      <value>jdbc:mysql://localhost:3306/db</value>
    </managed-property>
    
     <managed-property>
      <property-name>logfile</property-name>
      <value>browse.log</value>
    </managed-property>    
  </managed-bean>
  
</faces-config>

And one of the xhtml sites which I right click on in Eclipse (Run As --> Run on Server):

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>

<!-- ===========================================================================
login.xhtml - Startseite für Navigationsbeispiel                  
============================================================================ -->

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>

<h:body>
    <ui:composition template="/masterLayout.xhtml">

        <ui:define name="title">Immobiliensuche</ui:define>

        <ui:define name="content">
            <h:form>



                <h4>Bitte geben Sie alle benötiigten Daten ein die uns helfen
                    könnten Ihre Traumimobilie zu finden.</h4>


                <div class="container overflow-hidden">
                    <div class="row gy-9">

                        <!-- Dropdown auswhl möglichkeiten -->
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="Immo-wrapping">Immobilienart:</span>
                            <p:selectOneMenu class="coll-5" id="auswahlImmobilienart"
                                value="#{MbSuchmaske.immobilienart}">
                                <f:selectItem itemLabel="Klicken zum auswählen!" itemValue="" />
                                <f:selectItem itemLabel="Eigentumswohnung"
                                    itemValue="Eigentumswohnung" />
                                <f:selectItem itemLabel="Einfamilienhaus"
                                    itemValue="Einfamilienhaus" />
                                <f:selectItem itemLabel="Mehrfamilienhaus"
                                    itemValue="Mehrfamilienhaus" />
                                <f:selectItem itemLabel="Reihenhaus" itemValue="Reihenhaus" />
                                <f:selectItem itemLabel="Grundstück" itemValue="Grundstück" />

                            </p:selectOneMenu>
                        </div>
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="Immo-wrapping">Stadt:</span>
                            <p:selectOneMenu id="stadtAuswahl" value="#{MbSuchmaske.stadt}">
                                <f:selectItem itemLabel="Klicken zum auswählen!" itemValue="" />
                                <f:selectItem itemLabel="Berlin" itemValue="Berlin" />
                                <f:selectItem itemLabel="Hamburg" itemValue="Hamburg" />
                                <f:selectItem itemLabel="München" itemValue="München" />
                                <f:selectItem itemLabel="Köln" itemValue="Köln" />

                            </p:selectOneMenu>
                        </div>
                        <h3>Zum verfeinern der Suche:</h3>
                        <H5></H5>
                        <h4>Die Grundfläche:</h4>
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Minimale Grundfläche</span> <label for="customRange2"
                                class="form-label"></label>
                            <h:inputHidden id="minGrundflaeche_id" min="0" max="10000"
                                value="#{MbSuchmaske.minGrundflaeche}" />
                            <p:slider for="minGrundflaeche_id"
                                display="output_minGrundflaeche" minValue="0" maxValue="10000"
                                class="form-range" displayTemplate="{value} m²" />
                            <h:outputText id="output_minGrundflaeche"
                                value="#{MbSuchmaske.minGrundflaeche}" />
                        </div>

                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Maximale Grundfläche</span> <label for="customRange2"
                                class="form-label"></label>
                            <h:inputHidden id="maxGrundflaeche_id" min="0" max="10000"
                                value="#{MbSuchmaske.maxGrundflaeche}" />
                            <p:slider for="maxGrundflaeche_id"
                                display="output_maxGrundflaeche" minValue="0" maxValue="10000"
                                class="form-range" displayTemplate="{value} m²" />
                            <h:outputText id="output_maxGrundflaeche"
                                value="#{MbSuchmaske.maxGrundflaeche}" />
                        </div>
                        <h4>Die Wohnfläche:</h4>
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Minimale Wohnfläche</span> <label for="customRange2" class="form-label"></label>
                            <h:inputHidden id="minWohnflaeche_id" min="0" max="1000"
                                value="#{MbSuchmaske.minWohnflaeche}" />
                            <p:slider for="minWohnflaeche_id" display="output_minWohnflaeche"
                                minValue="0" maxValue="1000" class="form-range"
                                displayTemplate="{value} m²" />
                            <h:outputText id="output_minWohnflaeche"
                                value="#{MbSuchmaske.minWohnflaeche}" />
                        </div>

                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Maximale Wohnfläche</span> <label for="customRange2" class="form-label"></label>
                            <h:inputHidden id="maxWohnflaeche_id" min="0" max="1000"
                                value="#{MbSuchmaske.maxWohnflaeche}" />
                            <p:slider for="maxWohnflaeche_id" display="output_maxWohnflaeche"
                                minValue="0" maxValue="1000" class="form-range"
                                displayTemplate="{value} m²" />
                            <h:outputText id="output_maxWohnflaeche"
                                value="#{MbSuchmaske.maxWohnflaeche}" />
                        </div>

                        <h4>Preis</h4>
                        <div class="input-group flex-nowrap">
                            <span class="input-group-text col-4" id="addon-wrapping">
                                Maximaler Immobilienpreis</span> <label for="customRange2"
                                class="form-label"></label>
                            <h:inputHidden id="preis_id" min="0" max="1000000"
                                value="#{MbSuchmaske.preis}" />
                            <p:slider for="preis_id" display="output_preis" minValue="0"
                                maxValue="1000000" class="form-range"
                                displayTemplate="{value} €" />
                            <h:outputText id="output_preis" value="#{MbSuchmaske.preis}" />
                        </div>

                    </div>

                </div>




                <div class="container overflow-hidden">
                    <div class="row gy-9">

                        <h:commandButton value="Suchen!"
                            actionListener="#{MbSuchmaske.suchErgebnis}"
                            action="resultBoard.xhtml" />
                    </div>
                </div>

            </h:form>

        </ui:define>
    </ui:composition>

</h:body>
</html>

I use Eclipse IDE for Enterprise Java and Web Developers with Version: 2022-03 (4.23.0)
Apache Tomcat 10.0.13

I hope anyone can help me with this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

王权女流氓 2025-02-20 22:57:24

该错误与您的应用程序中的jakarta.faces-api库有关。您需要使用依赖性管理机制来指定此依赖关系。如果您使用Eclipse构建应用程序,并且不要使用Maven,我认为您需要将其添加到Eclipse中的应用程序依赖项中。

附带说明,将库将库复制到tomcat/lib文件夹并不是提供依赖关系的最佳方法。即使您不使用Maven,并且您的依赖项和构建由Eclipse管理,库仍应将其包装到您的应用程序的Web-Inf/lib目录。

The error is related to the absence of jakarta.faces-api library in your application. You need to specify this dependency using your dependency management mechanism. If you build your application using Eclipse and don't use Maven, I assume you need to add it to your application dependencies in Eclipse.

As a side note, copying libraries to the tomcat/lib folder is not the best way to provision dependencies. Even if you don't use Maven and your dependencies and builds are managed by Eclipse, the libraries should still be packaged to the WEB-INF/lib directory of your application.

云朵有点甜 2025-02-20 22:57:24

嘿,在您的项目中添加这两个依赖项,并说您的补救措施。

<dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>6.0.0</version>
    </dependency>
    <dependency>
        <groupId>jakarta.faces</groupId>
        <artifactId>jakarta.faces-api</artifactId>
        <version>4.0.1</version>
    </dependency>

Hey add these two dependencies in your project and voila your remedy.

<dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>6.0.0</version>
    </dependency>
    <dependency>
        <groupId>jakarta.faces</groupId>
        <artifactId>jakarta.faces-api</artifactId>
        <version>4.0.1</version>
    </dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文