java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servl

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servl相关的知识,希望对你有一定的参考价值。

严重: action: null
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/action-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servlet.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicationContext(ContextLoaderPlugIn.java:354)
at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplicationContext(ContextLoaderPlugIn.java:295)
at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoaderPlugIn.java:225)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:869)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
1.struts-config.xml里已配置了这些了。
<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
<message-resources parameter="com.library.ApplicationResources" />
<!-- 加载spring -->
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/classes/spring-config.xml" />
</plug-in>
2.web.xml也配置了
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/spring-config.xml</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
还是报那个错,关键是我根本没用那个xml文件。跪求帮助啊。

你就建那么一个文件嘛。
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"
>
</beans>

这个文件是springframework 默认读的。
参考技术A /WEB-INF/action-servlet.xml
这个文件找不到所以报IO异常,建议你检查下这个文件。
参考技术B <load-on-startup>1</load-on-startup> 参考技术C <load-on-startup>1</load-on-startup> 去掉 参考技术D classes应该放的是编译后的文件,把spring-config.xml换个位置再试试追问

我试过放在WEB-INF/的下面,不过还是报错……

追答

要是只放在WebRoot下面呢?不过可以肯定的是你的错误是找不到spring-config.xml。你把文件多换下位置试试咯。

本回答被提问者采纳

Activiti 初级入门项目

刚刚使用了activity做了一个项目,第一次就腆着脸给写出来吧!!!

审批流肯定要创建流程图,再编辑器上装bpm插件  

 

 

 技术图片

 

 装完就可以使用了

技术图片

 

 要创建在resources/processes/新建个文件夹叫processes 不然会报错:

Caused by: java.io.FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist
    at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:195)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:495)
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:296)
    at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1305)
    at org.springframework.context.support.GenericApplicationContext.getResources(GenericApplicationContext.java:238)
    at org.activiti.spring.boot.AbstractProcessEngineConfiguration.discoverProcessDefinitionResources(AbstractProcessEngineConfiguration.java:80)
    at org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration.baseSpringProcessEngineConfiguration(AbstractProcessEngineAutoConfiguration.java:75)
    at org.activiti.spring.boot.DataSourceProcessEngineAutoConfiguration$DataSourceProcessEngineConfiguration.springProcessEngineConfiguration(DataSourceProcessEngineAutoConfiguration.java:57)
    at org.activiti.spring.boot.DataSourceProcessEngineAutoConfiguration$DataSourceProcessEngineConfiguration$$EnhancerBySpringCGLIB$$baa326a5.CGLIB$springProcessEngineConfiguration$1(<generated>)
    at org.activiti.spring.boot.DataSourceProcessEngineAutoConfiguration$DataSourceProcessEngineConfiguration$$EnhancerBySpringCGLIB$$baa326a5$$FastClassBySpringCGLIB$$cc2270af.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
    at org.activiti.spring.boot.DataSourceProcessEngineAutoConfiguration$DataSourceProcessEngineConfiguration$$EnhancerBySpringCGLIB$$baa326a5.springProcessEngineConfiguration(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 86 common frames omitted

Caused by: java.io.FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist 不存在这个文件夹

解决方法2在配置文件中配置:

在application.properties文件加配置

# spring-activiti

# 自动部署验证设置:true-开启(默认)、false-关闭

spring.activiti.check-process-definitions=false

技术图片

 

 如上流程图就是这么简单 但是这文件可以用文本方式打开代码如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1587032668414" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
  <process id="apply" isClosed="false" isExecutable="true" name="创建申请" processType="None">
    <startEvent id="_2" name="StartEvent">
      <extensionElements>
        <activiti:executionListener class="com.cmbchina.ccd.itpm.listener.SubmitListener" event="start"/>
      </extensionElements>
    </startEvent>
    <userTask activiti:assignee="${zgsp}" activiti:exclusive="true" id="_7" name="主管审批"/>
    <exclusiveGateway gatewayDirection="Unspecified" id="_9" name="ExclusiveGateway"/>
    <sequenceFlow id="_10" sourceRef="_7" targetRef="_9"/>
    <userTask activiti:assignee="${assignee}" activiti:exclusive="true" id="_11" name="项目管理员审批">
      <multiInstanceLoopCharacteristics activiti:collection="${pmoList}" activiti:elementVariable="assignee" isSequential="false">
        <completionCondition><![CDATA[${nrOfCompletedInstances/nrOfInstances > 0}]]></completionCondition>
      </multiInstanceLoopCharacteristics>
    </userTask>
    <sequenceFlow id="_12" name="通过" sourceRef="_9" targetRef="_11">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${condition==1}]]></conditionExpression>
    </sequenceFlow>
    <userTask activiti:assignee="${xmszgsp}" activiti:exclusive="true" id="_13" name="项目室主管审批"/>
    <exclusiveGateway gatewayDirection="Unspecified" id="_14" name="ExclusiveGateway"/>
    <sequenceFlow id="_16" name="通过" sourceRef="_14" targetRef="_13">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${condition==1}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="_17" name="EndEvent"/>
    <sequenceFlow id="_22" sourceRef="_2" targetRef="_7"/>
    <sequenceFlow id="_23" sourceRef="_11" targetRef="_14"/>
    <sequenceFlow id="_24" sourceRef="_13" targetRef="_17"/>
    <sequenceFlow id="_25" name="不通过" sourceRef="_14" targetRef="_17">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${condition==0}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="_26" name="不通过" sourceRef="_9" targetRef="_17">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${condition==0}]]></conditionExpression>
    </sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
    <bpmndi:BPMNPlane bpmnElement="apply">
      <bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
        <omgdc:Bounds height="32.0" width="32.0" x="45.0" y="35.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_7" id="Shape-_7">
        <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="25.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_9" id="Shape-_9" isMarkerVisible="false">
        <omgdc:Bounds height="32.0" width="32.0" x="430.0" y="30.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_11" id="Shape-_11">
        <omgdc:Bounds height="55.0" width="85.0" x="620.0" y="20.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_13" id="Shape-_13">
        <omgdc:Bounds height="55.0" width="85.0" x="405.0" y="295.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_14" id="Shape-_14" isMarkerVisible="false">
        <omgdc:Bounds height="32.0" width="32.0" x="635.0" y="190.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_17" id="Shape-_17">
        <omgdc:Bounds height="32.0" width="32.0" x="430.0" y="190.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="_24" id="BPMNEdge__24" sourceElement="_13" targetElement="_17">
        <omgdi:waypoint x="446.0" y="295.0"/>
        <omgdi:waypoint x="446.0" y="222.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_12" id="BPMNEdge__12" sourceElement="_9" targetElement="_11">
        <omgdi:waypoint x="461.0" y="45.0"/>
        <omgdi:waypoint x="545.0" y="45.0"/>
        <omgdi:waypoint x="620.0" y="45.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="6.0" width="4.0" x="0.0" y="-2.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_23" id="BPMNEdge__23" sourceElement="_11" targetElement="_14">
        <omgdi:waypoint x="650.0" y="75.0"/>
        <omgdi:waypoint x="650.0" y="130.0"/>
        <omgdi:waypoint x="650.0" y="191.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_26" id="BPMNEdge__26" sourceElement="_9" targetElement="_17">
        <omgdi:waypoint x="445.0" y="61.0"/>
        <omgdi:waypoint x="445.0" y="126.0"/>
        <omgdi:waypoint x="445.0" y="190.0312805773287"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="-1.0" width="0.0" x="0.0" y="10.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_25" id="BPMNEdge__25" sourceElement="_14" targetElement="_17">
        <omgdi:waypoint x="636.0" y="205.0"/>
        <omgdi:waypoint x="529.0" y="205.0"/>
        <omgdi:waypoint x="461.9687194226713" y="205.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_16" id="BPMNEdge__16" sourceElement="_14" targetElement="_13">
        <omgdi:waypoint x="650.0" y="221.0"/>
        <omgdi:waypoint x="650.0" y="313.0"/>
        <omgdi:waypoint x="490.0" y="313.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_22" id="BPMNEdge__22" sourceElement="_2" targetElement="_7">
        <omgdi:waypoint x="76.96871942267131" y="50.0"/>
        <omgdi:waypoint x="133.0" y="50.0"/>
        <omgdi:waypoint x="215.0" y="50.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_7" targetElement="_9">
        <omgdi:waypoint x="300.0" y="45.0"/>
        <omgdi:waypoint x="360.0" y="45.0"/>
        <omgdi:waypoint x="431.0" y="45.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

这这里面有牵涉到多个项目管理员审批 一个人通过就是通过了 这属于多实例的一种,当时处理起来我有点不知道怎么处理 所以搜寻了很多的资料 (这可能是我不知道怎么搜索所以花费了不少时间)

最终就用了一句话

<![CDATA[${nrOfCompletedInstances/nrOfInstances > 0}]]>
这里的nrOfCompletedInstances 相当于处理人数nrOfInstances:需要处理的人数
我的需求是只要有一人处理就行 那就商大于0就OK 要是都需要处理 那就是 商恒等于0 哈哈原来这么简单
我这个应该只是工作流中的九牛一毛 里面有很多学问。有机会多多和博友交流
嘻嘻

以上是关于java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servl的主要内容,如果未能解决你的问题,请参考以下文章

在 Android 中解码 jpeg