NutzCN Logo
问答 activiti 转成eclipse编译一直不能通过
发布于 2299天前 作者 herexu 1503 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

Setup.java
wk-web/src/main/java/cn/wizzer/app/web/commons/core
line 1015
The method getContextPath() is undefined for the type ServletContext

RouteFilter.java
wk-web/src/main/java/cn/wizzer/app/web/commons/filter
line 22
The method setCharacterEncoding(String) is undefined for the type HttpServletResponse

27 回复

servlet版本设置到2.5+

web.xml里面的版本

web.xml里面没看到设置的地方

web.xml贴一下看看

  • 这个是wk-parent里面的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <display-name>NutzWk</display-name>

    <!-- Shiro -->
    <listener>
        <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
    </listener>
    <filter>
        <filter-name>ShiroFilter</filter-name>
        <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>ShiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <!-- Custom Route -->
    <filter>
        <filter-name>route</filter-name>
        <filter-class>cn.wizzer.app.web.commons.filter.RouteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>route</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- Nutz Mvc -->
    <filter>
        <filter-name>nutz</filter-name>
        <filter-class>org.nutz.mvc.NutFilter</filter-class>
        <init-param>
            <param-name>modules</param-name>
            <param-value>cn.wizzer.app.web.commons.core.Module</param-value>
        </init-param>
        <init-param>
            <param-name>ignore</param-name>
            <param-value>^(.+[.])(jsp|png|gif|jpg|js|css|jspx|jpeg|html|mp3|mp4|ico)$</param-value>
        </init-param>
        <init-param>
            <param-name>exclusions</param-name>
            <param-value>/assets/*,/druid/*,/upload/*,/apidoc/*</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>nutz</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <!-- druid -->
    <servlet>
        <servlet-name>DruidStatView</servlet-name>
        <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
        <init-param>
            <param-name>allow</param-name>
            <param-value>127.0.0.1</param-value>
        </init-param>
        <init-param>
            <param-name>exclusions</param-name>
            <param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*,/assets/*,/upload/*,/apidoc/*</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>DruidStatView</servlet-name>
        <url-pattern>/druid/*</url-pattern>
    </servlet-mapping>

    <error-page>
        <error-code>403</error-code>
        <location>/WEB-INF/error/403.html</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/WEB-INF/error/404.html</location>
    </error-page>
</web-app>

是的,activiti的分支

servlet api最高只能设置到3.1.0

我又改回了3.1.0了,还是不行

<dependency>
		  <groupId>javax.servlet</groupId>
		  <artifactId>javax.servlet-api</artifactId>
		  <version>3.1.0</version>
		</dependency>

估计是间接依赖了servlet 2.5, 然后3+的servlet api的artifactId是不一样的,导致没有直接覆盖

执行mvn dependency:tree输出个依赖树看看

wk-web中的jar包依赖树

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ wk-web ---
[INFO] cn.wizzer.app:wk-web:war:4.0.1-SNAPSHOT
[INFO] +- cn.wizzer:wk-framework:jar:4.0.1-SNAPSHOT:compile
[INFO] +- cn.wizzer:wk-code-generator:jar:4.0.1-SNAPSHOT:provided
[INFO] |  +- org.atteo:evo-inflector:jar:1.0.1:provided
[INFO] |  +- commons-cli:commons-cli:jar:1.2:provided
[INFO] |  \- org.apache.velocity:velocity:jar:1.7:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] +- org.nutz:nutz:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutz-plugins-daocache:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutz-plugins-cache:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutz-integration-quartz:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutz-integration-jedis:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutz-plugins-wkcache:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutzwx:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutz-plugins-views:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutz-integration-activiti:jar:1.r.63-SNAPSHOT:compile
[INFO] +- com.vdurmont:emoji-java:jar:3.2.0:compile
[INFO] +- org.quartz-scheduler:quartz:jar:2.2.3:compile
[INFO] |  \- c3p0:c3p0:jar:0.9.1.1:compile
[INFO] +- org.apache.shiro:shiro-web:jar:1.2.5:compile
[INFO] +- org.apache.shiro:shiro-core:jar:1.2.5:compile
[INFO] |  \- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.21:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- cn.apiclub.tool:simplecaptcha:jar:1.2.2:compile
[INFO] +- com.alibaba:druid:jar:1.0.28:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.41:compile
[INFO] +- net.sourceforge.jtds:jtds:jar:1.3.1:compile
[INFO] +- com.google.zxing:javase:jar:3.2.1:compile
[INFO] |  +- com.google.zxing:core:jar:3.2.1:compile
[INFO] |  \- com.beust:jcommander:jar:1.48:compile
[INFO] +- net.sf.ehcache:ehcache:jar:2.10.3:compile
[INFO] +- redis.clients:jedis:jar:2.9.0:compile
[INFO] |  \- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] +- org.apache.commons:commons-email:jar:1.4:compile
[INFO] +- com.sun.mail:javax.mail:jar:1.5.5:compile
[INFO] +- javax.activation:activation:jar:1.1.1:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- org.apache.shiro:shiro-ehcache:jar:1.3.2:compile
[INFO] +- commons-beanutils:commons-beanutils-core:jar:1.8.3:compile
[INFO] +- com.ibeetl:beetl:jar:2.5.2:compile
[INFO] |  \- org.antlr:antlr4-runtime:jar:4.2:compile
[INFO] |     +- org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1:compile
[INFO] |     \- org.antlr:antlr4-annotations:jar:4.2:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- commons-logging:commons-logging:jar:1.1:compile
[INFO] +- org.brickred:socialauth:jar:4.12:compile
[INFO] +- org.json:json:jar:20160212:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- maven:dom4j:jar:1.7-20060614:test
[INFO] +- io.jsonwebtoken:jjwt:jar:0.6.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.1:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.1:compile
[INFO] +- com.rabbitmq:amqp-client:jar:4.0.0:compile
[INFO] +- org.nutz:nutz-integration-rabbitmq:jar:1.r.63-SNAPSHOT:compile
[INFO] +- org.nutz:nutz-plugins-mock:jar:1.r.63-SNAPSHOT:test
[INFO] +- bouncycastle:bcprov-jdk16:jar:140:compile
[INFO] +- org.activiti:activiti-engine:jar:5.22.0:compile
[INFO] |  +- org.mybatis:mybatis:jar:3.3.0:compile
[INFO] |  +- joda-time:joda-time:jar:2.6:compile
[INFO] |  \- org.slf4j:jcl-over-slf4j:jar:1.7.6:compile
[INFO] +- org.activiti:activiti-bpmn-converter:jar:5.22.0:compile
[INFO] +- org.activiti:activiti-bpmn-layout:jar:5.22.0:compile
[INFO] |  \- org.tinyjee.jgraphx:jgraphx:jar:1.10.4.1:compile
[INFO] +- org.activiti:activiti-bpmn-model:jar:5.22.0:compile
[INFO] +- org.activiti:activiti-image-generator:jar:5.22.0:compile
[INFO] +- org.activiti:activiti-process-validation:jar:5.22.0:compile
[INFO] +- org.activiti:activiti-json-converter:jar:5.22.0:compile
[INFO] |  \- math.geom2d:javaGeom:jar:0.11.1:compile
[INFO] +- org.activiti:activiti-modeler:jar:5.22.0:compile
[INFO] |  +- org.activiti:activiti-common-rest:jar:5.22.0:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.1.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.1.5.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-aop:jar:4.1.5.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-expression:jar:4.1.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:4.1.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-tx:jar:4.1.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-web:jar:4.1.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-webmvc:jar:4.1.5.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-config:jar:3.2.3.RELEASE:compile
[INFO] |  |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  |  \- org.springframework.security:spring-security-core:jar:3.2.3.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-crypto:jar:3.2.3.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-web:jar:3.2.3.RELEASE:compile
[INFO] |  +- org.apache.xmlgraphics:batik-parser:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-util:jar:1.7:compile
[INFO] |  |  \- org.apache.xmlgraphics:batik-xml:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-transcoder:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:fop:jar:0.94:compile
[INFO] |  |  |  +- org.apache.xmlgraphics:xmlgraphics-commons:jar:1.2:compile
[INFO] |  |  |  +- commons-io:commons-io:jar:1.1:compile
[INFO] |  |  |  +- org.apache.avalon.framework:avalon-framework-api:jar:4.3.1:compile
[INFO] |  |  |  \- org.apache.avalon.framework:avalon-framework-impl:jar:4.3.1:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-dom:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-gvt:jar:1.7:compile
[INFO] |  |  \- xml-apis:xml-apis-ext:jar:1.3.04:compile
[INFO] |  +- org.apache.xmlgraphics:batik-bridge:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-anim:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-script:jar:1.7:compile
[INFO] |  |  |  \- org.apache.xmlgraphics:batik-js:jar:1.7:compile
[INFO] |  |  \- xml-apis:xml-apis:jar:1.3.04:compile
[INFO] |  +- org.apache.xmlgraphics:batik-codec:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-css:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile
[INFO] |  \- org.apache.xmlgraphics:batik-svggen:jar:1.7:compile
[INFO] \- com.fasterxml.uuid:java-uuid-generator:jar:3.1.3:compile
[INFO] ------------------------------------------------------------------------

额, 依赖树里面没有

用了tomcat 7???

电脑中就一个tomcat8.5

在命令行下试了一下, mvn clean package 无报错, 所以还是eclipse配置的问题

·mvn clean package·

[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default) @ wk-web ---
[INFO] Building jar: D:\project\NutzWk\wk-app\wk-web\target\nutzwk.jar
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) @ wk-web ---
[INFO] Packaging webapp
[INFO] Assembling webapp [wk-web] in [D:\project\NutzWk\wk-app\wk-web\target\nutzwk]
[INFO] Processing war project
[INFO] Copying webapp webResources [D:\project\NutzWk\wk-app\wk-web\src/main/resources] to [D:\project\NutzWk\wk-app\wk-web\target\nutzwk]
[INFO] Copying webapp resources [D:\project\NutzWk\wk-app\wk-web\src\main\webapp]
[INFO] Building jar: D:\project\NutzWk\wk-app\wk-web\target\nutzwk\WEB-INF\lib\wk-web-4.0.1-SNAPSHOT.jar
[INFO] Webapp assembled in [2584 msecs]
[INFO] Building war: D:\project\NutzWk\wk-app\wk-web\target\nutzwk.war
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] NutzWk 4.0.1-SNAPSHOT .............................. SUCCESS [  0.216 s]
[INFO] wk-app ............................................. SUCCESS [  0.012 s]
[INFO] wk-web 4.0.1-SNAPSHOT .............................. SUCCESS [ 18.557 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.971 s
[INFO] Finished at: 2018-07-30T21:02:13+08:00
[INFO] ------------------------------------------------------------------------

这eclipse会有什么毛病了了了

换个最新版的tomcat 8.5

已经是最新的了,2018-06-13 Tomcat Native 1.2.17 Released

话说, 直接run in server 呗, 看看是不是还报错

OMG,启动成功了,但是编译还是错的

eclipse疯了吧...

怎么办哈,是不是要弃坑了

有一种可能性, 展开项目之后, 有JRE System Library, Maven Dependences, 等库, 逐个打开, 看看有无低版本的servlet api依赖

有时候重启eclipse就好了,哈哈😄

逐个目录看了jar包,没有低版本的servlet api依赖
重启eclipse还是编译不通过

弃坑了,不挣扎了

添加回复
请先登陆
回到顶部