我用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
java中:系统找不到指定的路径。
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
6条回答 默认 最新
- wanghaolovezlq 2010-03-25 11:13关注
修改下代码
public void contextInitialized(ServletContextEvent arg0) {
// TODO Auto-generated method stub
ServletContext context=arg0.getServletContext();
String path=context.getRealPath("/data/count.dat"); //获得应用程序
的根目录
//先创建目录String dir=context.getRealPath("/data");
new File(dir).mkdir();
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();
}
}本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 #MATLAB仿真#车辆换道路径规划
- ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
- ¥15 数据可视化Python
- ¥15 要给毕业设计添加扫码登录的功能!!有偿
- ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
- ¥15 微信公众号自制会员卡没有收款渠道啊
- ¥100 Jenkins自动化部署—悬赏100元
- ¥15 关于#python#的问题:求帮写python代码
- ¥20 MATLAB画图图形出现上下震荡的线条
- ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘