java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.iss.whdc.sys.EncodingFilter.<clinit>(EncodingFilter.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:255)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 34 more
2008-11-16 9:57:44 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-11-16 9:57:44 org.apache.catalina.core.StandardContext start
严重: Context [/HFSCM] startup failed due to previous errors
log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
log4j:WARN Please initialize the log4j system properly.
2008-11-16 9:58:14 org.apache.struts.action.ActionServlet initChain
信息: Loading chain catalog from jar:file:/C:/Java/tomcat6/webapps/webstruts/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml
2008-11-16 9:58:15 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8088
2008-11-16 9:58:15 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2008-11-16 9:58:15 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/140 config=null
2008-11-16 9:58:15 org.apache.catalina.startup.Catalina start
信息: Server startup in 45229 ms
12 个解决方案
#1
好像是过滤器类 出错 不知如何配置??
#2
你把过滤器的配置和调用的部分代码发给我看看!
#3
上面的兄弟 有没有qq 或者什么通讯类的
#4
我也不知道什么是过滤器类 这是我在网上下的hfscm源码 想把它配置到我的项目中 运行看看 就是运行不起来 帮忙看看
hfscm.JPG
hfscm.JPG
#5
package com.iss.whdc.sys;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
/**
* 名称:中文转码过滤器
* 功能:
* @author: James
* @version: 1.0
* Creation date: 2007-4-29
*
*/
public class EncodingFilter implements Filter
{
/** 日志对象 */
protected static Logger logger = Logger.getLogger(EncodingFilter.class);
/**
* The default character encoding to set for requests that pass through this filter
*/
protected String encoding = null;
/**
* Should a character encoding specified by the client be ignored
*/
protected boolean ignore = true;
/**
* Take this filter out of service.
*/
public void destroy()
{
this.encoding = null;
}
/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code>null</code>.
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong>encoding </strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request)
{
return (this.encoding);
}
/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
try
{
// Conditionally select and set the character encoding to be used
if (this.ignore || (request.getCharacterEncoding() == null))
{
String encoding = this.selectEncoding(request);
if (encoding != null)
{
request.setCharacterEncoding(encoding);
}
}
logger.info("remoteAddr:"+request.getRemoteAddr());
if (request instanceof HttpServletRequest)
{
logger.info("requestURI:"+((HttpServletRequest) request).getRequestURI());
}
// Pass control on to the next filter
chain.doFilter(request, response);
}
catch (IOException e)
{
e.printStackTrace();
throw e;
}
catch (ServletException e)
{
e.printStackTrace();
throw e;
}
}
/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) throws ServletException
{
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null
|| value.equalsIgnoreCase("true")
|| value.equalsIgnoreCase("yes"))
{
this.ignore = true;
}
else
{
this.ignore = false;
}
}
}
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
/**
* 名称:中文转码过滤器
* 功能:
* @author: James
* @version: 1.0
* Creation date: 2007-4-29
*
*/
public class EncodingFilter implements Filter
{
/** 日志对象 */
protected static Logger logger = Logger.getLogger(EncodingFilter.class);
/**
* The default character encoding to set for requests that pass through this filter
*/
protected String encoding = null;
/**
* Should a character encoding specified by the client be ignored
*/
protected boolean ignore = true;
/**
* Take this filter out of service.
*/
public void destroy()
{
this.encoding = null;
}
/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code>null</code>.
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong>encoding </strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request)
{
return (this.encoding);
}
/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
try
{
// Conditionally select and set the character encoding to be used
if (this.ignore || (request.getCharacterEncoding() == null))
{
String encoding = this.selectEncoding(request);
if (encoding != null)
{
request.setCharacterEncoding(encoding);
}
}
logger.info("remoteAddr:"+request.getRemoteAddr());
if (request instanceof HttpServletRequest)
{
logger.info("requestURI:"+((HttpServletRequest) request).getRequestURI());
}
// Pass control on to the next filter
chain.doFilter(request, response);
}
catch (IOException e)
{
e.printStackTrace();
throw e;
}
catch (ServletException e)
{
e.printStackTrace();
throw e;
}
}
/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) throws ServletException
{
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null
|| value.equalsIgnoreCase("true")
|| value.equalsIgnoreCase("yes"))
{
this.ignore = true;
}
else
{
this.ignore = false;
}
}
}
#6
兄弟从你的错误提示中已经可以看出来啦,java.lang.NoClassDefFoundError: org/apache/log4j/Logger,这是找不到你的类呀,你把log4j.jar文件添加到你的工程里不就可以了吗?
#7
哈哈 是啊 我已经添加啦
但是启动tomcat的时候还是出现一系列的错误信息
严重: Exception starting filter EncodingFilter
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.iss.whdc.sys.EncodingFilter.<clinit>(EncodingFilter.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:255)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 34 more
2008-11-16 16:36:57 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-11-16 16:36:57 org.apache.catalina.core.StandardContext start
严重: Context [/HFSCM] startup failed due to previous errors
在WebRoot文件夹中有大量的红叉!!!
但是启动tomcat的时候还是出现一系列的错误信息
严重: Exception starting filter EncodingFilter
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.iss.whdc.sys.EncodingFilter.<clinit>(EncodingFilter.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:255)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 34 more
2008-11-16 16:36:57 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-11-16 16:36:57 org.apache.catalina.core.StandardContext start
严重: Context [/HFSCM] startup failed due to previous errors
在WebRoot文件夹中有大量的红叉!!!
#8
import org.apache.log4j.Logger;
找不到这个类
你把那个jar包扔到那里去了?什么目录下?
找不到这个类
你把那个jar包扔到那里去了?什么目录下?
#9
我看了一下 好象 WEB-INF下面的lib 文件夹没掉啦 下面的jar都找不到
#10
你的环境肯定有问题,还有你将web.xml的相关配置发给我看看。。。
#11
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<resource-ref>
<description>Oracle Connection Pool</description>
<res-ref-name>jdbc/scmjc</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!--Filter to set character encoding to gb2312-->
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.iss.whdc.sys.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter>
<filter-name>PrivilegeFilter</filter-name>
<filter-class>com.iss.whdc.sys.PrivilegeFilter</filter-class>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<servlet-name>action</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<servlet-name>action</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>
/WEB-INF/struts-config.xml,
/WEB-INF/struts-config-system.xml,
/WEB-INF/struts-config-baseinfo.xml,
/WEB-INF/struts-config-qualitycheck.xml,
/WEB-INF/struts-config-manageroom.xml,
/WEB-INF/struts-config-outroom.xml,
/WEB-INF/struts-config-inroom.xml,
/WEB-INF/struts-config-arrival.xml,
/WEB-INF/struts-config-inventory.xml,
/WEB-INF/struts-config-report.xml,
/WEB-INF/struts-config-account.xml,
/WEB-INF/struts-config-movehome.xml,
</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>
<!--Error Page
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/403.jsp</location>
</error-page>-->
</web-app>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<resource-ref>
<description>Oracle Connection Pool</description>
<res-ref-name>jdbc/scmjc</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!--Filter to set character encoding to gb2312-->
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.iss.whdc.sys.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter>
<filter-name>PrivilegeFilter</filter-name>
<filter-class>com.iss.whdc.sys.PrivilegeFilter</filter-class>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<servlet-name>action</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<servlet-name>action</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>
/WEB-INF/struts-config.xml,
/WEB-INF/struts-config-system.xml,
/WEB-INF/struts-config-baseinfo.xml,
/WEB-INF/struts-config-qualitycheck.xml,
/WEB-INF/struts-config-manageroom.xml,
/WEB-INF/struts-config-outroom.xml,
/WEB-INF/struts-config-inroom.xml,
/WEB-INF/struts-config-arrival.xml,
/WEB-INF/struts-config-inventory.xml,
/WEB-INF/struts-config-report.xml,
/WEB-INF/struts-config-account.xml,
/WEB-INF/struts-config-movehome.xml,
</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>
<!--Error Page
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/403.jsp</location>
</error-page>-->
</web-app>
#12
我也是出现类似问题
#1
好像是过滤器类 出错 不知如何配置??
#2
你把过滤器的配置和调用的部分代码发给我看看!
#3
上面的兄弟 有没有qq 或者什么通讯类的
#4
我也不知道什么是过滤器类 这是我在网上下的hfscm源码 想把它配置到我的项目中 运行看看 就是运行不起来 帮忙看看
hfscm.JPG
hfscm.JPG
#5
package com.iss.whdc.sys;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
/**
* 名称:中文转码过滤器
* 功能:
* @author: James
* @version: 1.0
* Creation date: 2007-4-29
*
*/
public class EncodingFilter implements Filter
{
/** 日志对象 */
protected static Logger logger = Logger.getLogger(EncodingFilter.class);
/**
* The default character encoding to set for requests that pass through this filter
*/
protected String encoding = null;
/**
* Should a character encoding specified by the client be ignored
*/
protected boolean ignore = true;
/**
* Take this filter out of service.
*/
public void destroy()
{
this.encoding = null;
}
/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code>null</code>.
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong>encoding </strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request)
{
return (this.encoding);
}
/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
try
{
// Conditionally select and set the character encoding to be used
if (this.ignore || (request.getCharacterEncoding() == null))
{
String encoding = this.selectEncoding(request);
if (encoding != null)
{
request.setCharacterEncoding(encoding);
}
}
logger.info("remoteAddr:"+request.getRemoteAddr());
if (request instanceof HttpServletRequest)
{
logger.info("requestURI:"+((HttpServletRequest) request).getRequestURI());
}
// Pass control on to the next filter
chain.doFilter(request, response);
}
catch (IOException e)
{
e.printStackTrace();
throw e;
}
catch (ServletException e)
{
e.printStackTrace();
throw e;
}
}
/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) throws ServletException
{
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null
|| value.equalsIgnoreCase("true")
|| value.equalsIgnoreCase("yes"))
{
this.ignore = true;
}
else
{
this.ignore = false;
}
}
}
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
/**
* 名称:中文转码过滤器
* 功能:
* @author: James
* @version: 1.0
* Creation date: 2007-4-29
*
*/
public class EncodingFilter implements Filter
{
/** 日志对象 */
protected static Logger logger = Logger.getLogger(EncodingFilter.class);
/**
* The default character encoding to set for requests that pass through this filter
*/
protected String encoding = null;
/**
* Should a character encoding specified by the client be ignored
*/
protected boolean ignore = true;
/**
* Take this filter out of service.
*/
public void destroy()
{
this.encoding = null;
}
/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code>null</code>.
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong>encoding </strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request)
{
return (this.encoding);
}
/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
try
{
// Conditionally select and set the character encoding to be used
if (this.ignore || (request.getCharacterEncoding() == null))
{
String encoding = this.selectEncoding(request);
if (encoding != null)
{
request.setCharacterEncoding(encoding);
}
}
logger.info("remoteAddr:"+request.getRemoteAddr());
if (request instanceof HttpServletRequest)
{
logger.info("requestURI:"+((HttpServletRequest) request).getRequestURI());
}
// Pass control on to the next filter
chain.doFilter(request, response);
}
catch (IOException e)
{
e.printStackTrace();
throw e;
}
catch (ServletException e)
{
e.printStackTrace();
throw e;
}
}
/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) throws ServletException
{
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null
|| value.equalsIgnoreCase("true")
|| value.equalsIgnoreCase("yes"))
{
this.ignore = true;
}
else
{
this.ignore = false;
}
}
}
#6
兄弟从你的错误提示中已经可以看出来啦,java.lang.NoClassDefFoundError: org/apache/log4j/Logger,这是找不到你的类呀,你把log4j.jar文件添加到你的工程里不就可以了吗?
#7
哈哈 是啊 我已经添加啦
但是启动tomcat的时候还是出现一系列的错误信息
严重: Exception starting filter EncodingFilter
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.iss.whdc.sys.EncodingFilter.<clinit>(EncodingFilter.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:255)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 34 more
2008-11-16 16:36:57 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-11-16 16:36:57 org.apache.catalina.core.StandardContext start
严重: Context [/HFSCM] startup failed due to previous errors
在WebRoot文件夹中有大量的红叉!!!
但是启动tomcat的时候还是出现一系列的错误信息
严重: Exception starting filter EncodingFilter
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.iss.whdc.sys.EncodingFilter.<clinit>(EncodingFilter.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:255)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 34 more
2008-11-16 16:36:57 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-11-16 16:36:57 org.apache.catalina.core.StandardContext start
严重: Context [/HFSCM] startup failed due to previous errors
在WebRoot文件夹中有大量的红叉!!!
#8
import org.apache.log4j.Logger;
找不到这个类
你把那个jar包扔到那里去了?什么目录下?
找不到这个类
你把那个jar包扔到那里去了?什么目录下?
#9
我看了一下 好象 WEB-INF下面的lib 文件夹没掉啦 下面的jar都找不到
#10
你的环境肯定有问题,还有你将web.xml的相关配置发给我看看。。。
#11
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<resource-ref>
<description>Oracle Connection Pool</description>
<res-ref-name>jdbc/scmjc</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!--Filter to set character encoding to gb2312-->
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.iss.whdc.sys.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter>
<filter-name>PrivilegeFilter</filter-name>
<filter-class>com.iss.whdc.sys.PrivilegeFilter</filter-class>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<servlet-name>action</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<servlet-name>action</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>
/WEB-INF/struts-config.xml,
/WEB-INF/struts-config-system.xml,
/WEB-INF/struts-config-baseinfo.xml,
/WEB-INF/struts-config-qualitycheck.xml,
/WEB-INF/struts-config-manageroom.xml,
/WEB-INF/struts-config-outroom.xml,
/WEB-INF/struts-config-inroom.xml,
/WEB-INF/struts-config-arrival.xml,
/WEB-INF/struts-config-inventory.xml,
/WEB-INF/struts-config-report.xml,
/WEB-INF/struts-config-account.xml,
/WEB-INF/struts-config-movehome.xml,
</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>
<!--Error Page
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/403.jsp</location>
</error-page>-->
</web-app>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<resource-ref>
<description>Oracle Connection Pool</description>
<res-ref-name>jdbc/scmjc</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!--Filter to set character encoding to gb2312-->
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.iss.whdc.sys.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter>
<filter-name>PrivilegeFilter</filter-name>
<filter-class>com.iss.whdc.sys.PrivilegeFilter</filter-class>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<servlet-name>action</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<servlet-name>action</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PrivilegeFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>
/WEB-INF/struts-config.xml,
/WEB-INF/struts-config-system.xml,
/WEB-INF/struts-config-baseinfo.xml,
/WEB-INF/struts-config-qualitycheck.xml,
/WEB-INF/struts-config-manageroom.xml,
/WEB-INF/struts-config-outroom.xml,
/WEB-INF/struts-config-inroom.xml,
/WEB-INF/struts-config-arrival.xml,
/WEB-INF/struts-config-inventory.xml,
/WEB-INF/struts-config-report.xml,
/WEB-INF/struts-config-account.xml,
/WEB-INF/struts-config-movehome.xml,
</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>
<!--Error Page
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/403.jsp</location>
</error-page>-->
</web-app>
#12
我也是出现类似问题