我已经使用struts运行了Web应用程序。我无法运行我在启动Apache tomcat错误时遇到错误的应用程序,并且在运行Web应用程序时它也会抛出错误。我已经发布了下面的错误日志并对此有所帮助。我是Netbeans的新手 启动Apache tomcat服务器时出错
Feb 04, 2016 3:19:55 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:257)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:383)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:104)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
运行Web应用程序时出错:
Undeploying ...
undeploy?path=/Loyalty4Salon
OK - Undeployed application at context path /Loyalty4Salon
In-place deployment at /home/revathy/Documents/Esa netbeans/loyalty_salon/loyalty_salon/build/web
Deployment is in progress...
deploy?config=file%3A%2Ftmp%2Fcontext2062383266810619779.xml&path=/Loyalty4Salon
FAIL - Deployed application at context path /Loyalty4Salon but context failed to start
/home/revathy/Documents/Esa netbeans/loyalty_salon/loyalty_salon/nbproject/build-impl.xml:1125: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 2 seconds)
这是struts-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
</global-forwards>
<action-mappings>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<message-resources parameter="com/myapp/struts/ApplicationResource"/>
<!-- ========================= Tiles plugin ===============================-->
<!--
This plugin initialize Tiles definition factory. This later can takes some
parameters explained here after. The plugin first read parameters from
web.xml, thenoverload them with parameters defined here. All parameters
are optional.
The plugin should be declared in each struts-config file.
- definitions-config: (optional)
Specify configuration file names. There can be several comma
separated file names (default: ?? )
- moduleAware: (optional - struts1.1)
Specify if the Tiles definition factory is module aware. If true
(default), there will be one factory for each Struts module.
If false, there will be one common factory for all module. In this
later case, it is still needed to declare one plugin per module.
The factory will be initialized with parameters found in the first
initialized plugin (generally the one associated with the default
module).
true : One factory per module. (default)
false : one single shared factory for all modules
- definitions-parser-validate: (optional)
Specify if xml parser should validate the Tiles configuration file.
true : validate. DTD should be specified in file header (default)
false : no validation
Paths found in Tiles definitions are relative to the main context.
-->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>
<!-- ========================= Validator plugin ================================= -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
这是struts.xml
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_index.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="c_cpnDetail"
class="com.Customer.Action"
method="c_cpnDetail" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/cmpny_couponDetail.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="coupon_index"
class="com.Customer.Action"
method="couponCode" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_create.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="createCoupon"
class="com.Customer.Action"
method="create_Coupon" >
<interceptor-ref name="tokenSession"/>
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/pjpeg
</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="invalid.token" type="redirect">coupon</result>
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_index.jsp</result>
<result name="error">/error.jsp</result>
<result name="input">/ImageFileUploadError.jsp</result>
</action>
<!--<action name="couponAssignPage"
class="com.Customer.Action"
method="advSrch" >
<result name="success">./coupon_Assign.jsp</result>
<result name="error">./error.jsp</result>
</action> -->
<action name="couponAssignPage"
class="com.Customer.Action"
method="cpn_assignPage" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_Assign.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="cpn_getUsers"
class="com.Customer.Action"
method="cpn_getUsers" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_Assign.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="coupon_assign"
class="com.Customer.Action"
method="assign_coupon" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_index.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="couponAssign"
class="com.Customer.Action"
method="coupon_assign">
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_index.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="csvExport"
class="com.Customer.Action"
method="csvExport">
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/csvDownload.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="search_usr"
class="com.Customer.Action"
method="srch_usr1" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_assign.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="deleteCoupon"
class="com.Customer.Action"
method="dltCoupon" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_index.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="del_cpn"
class="com.Customer.Action"
method="bulk_cpn_del" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_index.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="c_edit"
class="com.Customer.Action"
method="editCouponretrieve" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_edit.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="editCoupon"
class="com.Customer.Action"
method="editCoupon" >
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/pjpeg
</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_index.jsp</result>
<result name="error">/error.jsp</result>
<result name="input">/ImageFileUploadError.jsp</result>
</action>
<action name="couponSearchPage"
class="com.Customer.Action"
method="couponSearchPage" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/Coupon_search.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="couponSearch"
class="com.Customer.Action"
method="coupon_search" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/coupon_searchResult.jsp</result>
<result name="error">/error.jsp</result>
</action>
<!-- Super Admin-->
<action name="create_company"
class="com.Customer.Action"
method="create_company" >
<result name="success">/sa_cmpny_create.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="gen_key"
class="com.Customer.Action"
method="couponCode" >
<result name="success">/sa_cmpny_create.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_cmpnyDetail"
class="com.Customer.Action"
method="sa_cmpnyDetail" >
<result name="success">/sa_cmpnyDetail.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_userDetail"
class="com.Customer.Action"
method="sa_userDetail" >
<result name="success">/sa_cmpnyDetail.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_createCmpny"
class="com.Customer.Action"
method="sa_createCmpny" >
<result name="invalid.token" type="redirect">sa_companyList</result>
<result name="logoutPage">/sa_login.jsp</result>
<interceptor-ref name="tokenSession"/>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/sa_cmpny_list.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_companyList"
class="com.Customer.Action"
method="sa_listCmpny">
<result name="success">/sa_cmpny_list.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="sa_subCmpnyList"
class="com.Customer.Action"
method="sa_listSubCmpny" >
<result name="success">/sa_subcmpny_list.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_cmpny_status"
class="com.Customer.Action"
method="sa_cmpny_status" >
<result name="success">/sa_cmpny_list.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_subcmpny_status"
class="com.Customer.Action"
method="sa_subcmpny_status" >
<result name="success">/sa_subcmpny_list.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_cmpny_delete"
class="com.Customer.Action"
method="sa_cmpny_delete" >
<result name="success">/sa_cmpny_list.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_subcmpny_delete"
class="com.Customer.Action"
method="sa_subcmpny_delete" >
<result name="success">/sa_subcmpny_list.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_cmpny_editRetrieve"
class="com.Customer.Action"
method="sa_cmpny_editRetrieve" >
<result name="success">/sa_cmpny_edit.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_subcmpny_editRetrieve"
class="com.Customer.Action"
method="sa_subcmpny_editRetrieve" >
<result name="success">/sa_subcmpny_edit.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_cmpny_edit"
class="com.Customer.Action"
method="sa_cmpny_edit" >
<result name="success">/sa_cmpny_list.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_cmpny_planedit"
class="com.Customer.Action"
method="sa_cmpny_planedit" >
<result name="success">/sa_cmpny_list.jsp</result>
<result name="error">/error.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="sa_subcmpny_edit"
class="com.Customer.Action"
method="sa_subcmpny_edit" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/sa_subcmpny_list.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="sa_login"
class="com.Customer.Action"
method="sa_login" >
<interceptor-ref name="tokenSession"/>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="invalid.token" type="redirect">/sa_login.jsp</result>
<result name="sa_success">/sa_start.jsp</result>
<result name="success">/start.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
<!--<result name="graph">./Graph.jsp</result>-->
<result name="error">/error.jsp</result>
</action>
<action name="logout"
class="com.Customer.Action"
method="logout" >
<result name="sa_success">/sa_start.jsp</result>
<result name="success">/sa_login.jsp</result>
<!--<result name="success">/sample.jsp</result>-->
<result name="Success">/start.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="sa_logout"
class="com.Customer.Action"
method="sa_logout">
<result name="success">/sa_login.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="settings"
class="com.Customer.Action"
method="settings" >
<result name="success">/sa_start.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
<result name="error">/error.jsp</result>
</action>
<!--REV SOURCE-->
<!--Deals action result -->
<action name="importCsv" class="com.Customer.Action" method="importcsv">
<result name="success">/index.jsp</result>
<result name="error">/error.jsp</result>
<result name="wrong_csv">/index.jsp</result>
<result name="logoutPage">/sa_login.jsp</result>
</action>
<action name="click_Deals"
class="com.Customer.Struts_Action"
method="click_Deals" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/list_Deals.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="addDeals"
class="com.Customer.Deals"
method="execute">
<interceptor-ref name="tokenSession"/>
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/pjpeg
</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="invalid.token" type="redirect">click_Deals</result>
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/Deals_submit.jsp</result>
<result name="reached-deals">/list_Deals.jsp</result>
<result name="input">/ImageFileUploadError.jsp</result>
</action>
<action name="addDeals_first"
class="com.Customer.Deals"
method="execute_list">
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/Deals_submit.jsp</result>
<result name="reached-deals">/list_Deals.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="d_status"
class="com.Customer.Struts_Action"
method="d_status" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/list_Deals.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="activate_deal"
class="com.Customer.Struts_Action"
method="bulk_activate_deal" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/list_Deals.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="inactivate_deal"
class="com.Customer.Struts_Action"
method="bulk_inactivate_deal" >
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/list_Deals.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="edit_Deal"
class="com.Customer.Struts_Action"
method="edit_Deal">
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/Deals_edit.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="editDealsData"
class="com.Customer.Struts_Action"
method="edit_Deal_Data">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/pjpeg
</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/list_Deals.jsp</result>
<result name="input">/ImageFileUploadError.jsp</result>
</action>
<action name="Delete_Deal"
class="com.Customer.Struts_Action"
method="Delete_Deal">
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/list_Deals.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="del_deal"
class="com.Customer.Struts_Action"
method="bulk_del_deal">
<result name="logoutPage">/sa_login.jsp</result>
<result name="success">/list_Deals.jsp</result>
<result name="error">/error.jsp</result>
</action>
答案 0 :(得分:0)
如果没有Struts2 核心库,则无法部署Struts2 Web应用程序。在web.xml
中声明的过滤器类不能通过Web应用程序类加载器在类路径中找到。
<web-app id="WebApp_9" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- ... -->
</web-app>
如何解决此类问题。首先,您可以尝试在互联网上搜索课程org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
。即使Google的第一个结果指向web.xml
,也有大量可用信息,但没有关于框架使用的核心库。好的,尝试在struts.apache.org上搜索班级名称,并给出第二个结果Create Struts 2 Web Application Using Maven To Manage Artifacts and To Build The Application。它是用Maven作为构建工具创建的。如果你不熟悉它,你应该阅读maven.apache.org。在pom.xml
中,它使用依赖
<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>X.X.X.X</version> </dependency>
当然用当前的Struts 2版本替换X.X.X.X. Maven的 将获得struts2-core jar和其他jar文件struts2-core 需要(传递依赖)。
Netbeans完全支持Maven:
NetBeans包括自6.7以来的完整Maven支持,包括7.0+中的Maven 3支持。您可以在IDE中打开任何Maven项目并立即开始编码。
有关详细信息,请参阅NetBeans.org wiki page。
如果您不知道如何找到项目的依赖项,则应阅读常见问题解答。
How to find dependencies on public Maven repositories?
You could use the following search engines:
根据您需要的版本2.3.12
,您会在search for struts2-core
找到2.3.24.1所有必需的库。我现在推荐最新的稳定版本library for accessing their JSON API。
您可以在项目中使用Maven下载所需的库并将其添加到依赖项中。如果您决定手动管理项目依赖项,则可以获取有关maven站点上struts2-core
依赖项的信息。