我用myeclipse把我的工程部署到tomcat上并运行之后报下面的错误 哪位大哥帮忙看下怎么回事啊
信息: The listener "com.briup.run.web.listener.SessionListener" is already configured for this context. The duplicate definition has been ignored.
contextInitialized...
java.io.IOException: 系统找不到指定的路径。
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at com.briup.run.web.listener.ContextListener.contextInitialized(ContextListener.java:37)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
....
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2010-3-25 10:34:19 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
问题补充:<?xml version="1.0" encoding="UTF-8"?>
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">
index.jsp
struts2
org.apache.struts2.dispatcher.FilterDispatcher
struts2
/*
FORWARD
REQUEST
INCLUDE
encoding
com.briup.run.web.filter.EncodingFilter
encoding
/*
authImg
com.briup.run.web.servlet.AuthImg
checkName
com.briup.run.web.servlet.checkName
authImg
/pages/authimg
checkName
/pages/check
com.briup.run.web.listener.ContextListener
com.briup.run.web.listener.SessionListener
mydwr
uk.ltd.getahead.dwr.DWRServlet
mydwr
/dwr/*
这是我的web.xml感觉也没错啊
问题补充:
lovewhzlq 写道
有两个问题
1.com.briup.run.web.listener.ContextListener在web.xml文件中配置了两次
2.com.briup.run.web.listener.ContextListener.contextInitialized(ContextListener.java:37)
这个监听器创建文件出错
现在应该可以排除第一个问题 如果是第二种情况 监听器创建文件出错 那该怎么解决 麻烦大哥详细的给说下
问题补充:public class ContextListener implements ServletContextListener {
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
ServletContext context=arg0.getServletContext();
String path=context.getRealPath("/data/count.dat"); //获得应用程序的根目录
File f=new File(path);
try{
FileOutputStream fos=new FileOutputStream(f);
Integer count=(Integer)context.getAttribute("count");
fos.write(count);
fos.close();
context.removeAttribute("count");
}catch(Exception e){
e.printStackTrace();
}
}
public void contextInitialized(ServletContextEvent arg0) {
// TODO Auto-generated method stub
ServletContext context=arg0.getServletContext();
String path=context.getRealPath("/data/count.dat"); //获得应用程序的根目录
System.out.println("contextInitialized...");
File f=new File(path);
try{
if(!f.exists())
f.createNewFile();
FileInputStream file=new FileInputStream(f);
int count=file.read();
if(count==-1)
count=0;
file.close();
context.setAttribute("count", count);
}catch(Exception e){
e.printStackTrace();
}
}
问题补充:
lovewhzlq 写道
出错的代码粘出来分析嘛在上面了 那是contextlistener的代码
问题补充:
lovewhzlq 写道
出错的代码粘出来分析嘛还在吗 帮看看是哪里写的不对