Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Exception Starting roo project from mvn tomcat:run

  1. #1
    Join Date
    Apr 2010
    Posts
    8

    Default Exception Starting roo project from mvn tomcat:run

    I get the following exception when running mvn tomcat:run from the command line. The project runs fine inside the Springsource Tool Suite. I MUST be missing some jars or different versions of jars or something but I don't know what.

    SEVERE: Exception starting filter Spring OpenEntityManagerInViewFilter
    java.lang.ClassCastException: org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter cannot be cast to javax.
    servlet.Filter
    at org.apache.catalina.core.ApplicationFilterConfig.g etFilter(ApplicationFilterConfig.java:255)
    at org.apache.catalina.core.ApplicationFilterConfig.s etFilterDef(ApplicationFilterConfig.java:397)
    at org.apache.catalina.core.ApplicationFilterConfig.< init>(ApplicationFilterConfig.java:108)
    at org.apache.catalina.core.StandardContext.filterSta rt(StandardContext.java:3709)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4356)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.startup.Embedded.start(Embedde d.java:825)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.startCont ainer(AbstractRunMojo.java:385)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(A bstractRunMojo.java:144)
    at org.apache.maven.plugin.DefaultPluginManager.execu teMojo(DefaultPluginManager.java:483)
    ...
    May 25, 2010 11:27:27 AM org.apache.catalina.core.StandardContext filterStart
    SEVERE: Exception starting filter CharacterEncodingFilter
    java.lang.ClassCastException: org.springframework.web.filter.CharacterEncodingFi lter cannot be cast to javax.servlet.Fil
    ter
    at org.apache.catalina.core.ApplicationFilterConfig.g etFilter(ApplicationFilterConfig.java:255)
    at org.apache.catalina.core.ApplicationFilterConfig.s etFilterDef(ApplicationFilterConfig.java:397)
    at org.apache.catalina.core.ApplicationFilterConfig.< init>(ApplicationFilterConfig.java:108)
    at org.apache.catalina.core.StandardContext.filterSta rt(StandardContext.java:3709)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4356)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.startup.Embedded.start(Embedde d.java:825)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.startCont ainer(AbstractRunMojo.java:385)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(A bstractRunMojo.java:144)
    ...
    May 25, 2010 11:27:27 AM org.apache.catalina.core.StandardContext filterStart
    SEVERE: Exception starting filter etagFilter
    java.lang.ClassCastException: org.springframework.web.filter.ShallowEtagHeaderFi lter cannot be cast to javax.servlet.Fil
    ter
    at org.apache.catalina.core.ApplicationFilterConfig.g etFilter(ApplicationFilterConfig.java:255)
    at org.apache.catalina.core.ApplicationFilterConfig.s etFilterDef(ApplicationFilterConfig.java:397)
    at org.apache.catalina.core.ApplicationFilterConfig.< init>(ApplicationFilterConfig.java:108)
    at org.apache.catalina.core.StandardContext.filterSta rt(StandardContext.java:3709)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4356)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.startup.Embedded.start(Embedde d.java:825)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.startCont ainer(AbstractRunMojo.java:385)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(A bstractRunMojo.java:144)
    ...
    May 25, 2010 11:27:27 AM org.apache.catalina.core.StandardContext filterStart
    SEVERE: Exception starting filter httpMethodFilter
    java.lang.ClassCastException: org.springframework.web.filter.HiddenHttpMethodFil ter cannot be cast to javax.servlet.Filt
    er
    at org.apache.catalina.core.ApplicationFilterConfig.g etFilter(ApplicationFilterConfig.java:255)
    at org.apache.catalina.core.ApplicationFilterConfig.s etFilterDef(ApplicationFilterConfig.java:397)
    at org.apache.catalina.core.ApplicationFilterConfig.< init>(ApplicationFilterConfig.java:108)
    at org.apache.catalina.core.StandardContext.filterSta rt(StandardContext.java:3709)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4356)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.startup.Embedded.start(Embedde d.java:825)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.startCont ainer(AbstractRunMojo.java:385)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(A bstractRunMojo.java:144)
    ...
    May 25, 2010 11:27:27 AM org.apache.catalina.core.StandardContext filterStart
    SEVERE: Exception starting filter UrlRewriteFilter
    java.lang.ClassCastException: org.tuckey.web.filters.urlrewrite.UrlRewriteFilter cannot be cast to javax.servlet.Filter
    at org.apache.catalina.core.ApplicationFilterConfig.g etFilter(ApplicationFilterConfig.java:255)
    at org.apache.catalina.core.ApplicationFilterConfig.s etFilterDef(ApplicationFilterConfig.java:397)
    at org.apache.catalina.core.ApplicationFilterConfig.< init>(ApplicationFilterConfig.java:108)
    at org.apache.catalina.core.StandardContext.filterSta rt(StandardContext.java:3709)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4356)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.startup.Embedded.start(Embedde d.java:825)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.startCont ainer(AbstractRunMojo.java:385)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(A bstractRunMojo.java:144)
    ...
    May 25, 2010 11:27:27 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error filterStart
    May 25, 2010 11:27:27 AM org.apache.catalina.core.StandardContext start
    SEVERE: Context [/mockbr] startup failed due to previous errors
    May 25, 2010 11:27:28 AM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    May 25, 2010 11:27:28 AM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080

    Any thoughts or ideas would be most helpful. thank you very much!

  2. #2
    Join Date
    Jan 2008
    Posts
    182

    Default

    Wild guess, but those filters do extend that class, so I'd say you have a couple of the j2ee.jar on your classpath. Your app server should be providing it, so if it is in your WEB-INF/lib then you want to remove it. (and make sure you clean the file from the app server deployment). It might have a different name depending on where it came from in the first place, but should be recognisable.

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Given this is coming from mvn tomcat:run, you might want to try mvn -up tomcat:run to update your Maven plugins.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  4. #4

    Default

    Hey ben,

    I am also facing the same issue stated above

    ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 56 in XML document from file D:\roooo\target\classes\META-INF\spring\applicationContext.xml is invalid; nested exception is org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.

    I tried doing a mvn -up tomcat:run but still I face the same issue.. Will be great if you can reply back on this..

    Thanks and Regards
    Naveen

  5. #5
    Join Date
    Apr 2010
    Posts
    8

    Default

    If I run the application from eclipse or I do a mvn tomcat:deploy to a running instance of tomcat I do not see the issue.

    If I simply do mvn tomcat:run (which, as I understand it, uses an instance of tomcat under mavens control) it gives the error. Very odd.

    As a work around, I just run it from eclipse or deploy to my on tomcat server.

  6. #6
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    @Nyronian, thanks for sharing your workaround. Roo just uses the Maven Tomcat plugin, we didn't write it. I see on 5 May 2010 1.0 was released on tomcat-maven-plugin, so maybe you might try editing your pom.xml to change the version from 1.0-beta-1 to 1.0? http://repo2.maven.org/maven2/org/co...en-plugin/1.0/

    If that works, would you mind logging a Jira ticket at http://jira.springframework.org/browse/ROO to remind us to upgrade the plugin version? Thanks
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  7. #7
    Join Date
    Sep 2007
    Posts
    20

    Default

    Hi @Nyronian and @Ben,

    I had the same issue recently and the 1.0. tomcat plugin upgrade did not help.

    First I found that while the 'mvn tomtom:run-war' works fine the dynamic 'mvn tomtom:run' fails with the above mentioned exceptions.

    Then by analyzing my pom dependency hierarchy I discovered a jetty:6.1.22 dependency that implicitly imports the servlet-api:2.5-20081211. I filtered out the later by adding an exclusion clause:
    Code:
       <dependency>
          <groupId>org.mortbay.jetty</groupId>
          <artifactId>jetty</artifactId>
          <version>6.1.22</version>
          <type>jar</type>
          <scope>compile</scope>
          <exclusions>
             <exclusion>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>servlet-api</artifactId>
             </exclusion>
          </exclusions>
       </dependency>
    which solved the problem for me.

    Hope this will help,
    Cheers, Chris

  8. #8

    Default Apache POI

    Hello,

    In my case, the Apache POI library was implicitly importing the javax.servlet:servlet-api:jar:2.3 into my dependency tree.

    I found this out analysing the dependency tree with mvn dependency:tree and then rectified the problem by adding an exclusion as mentioned in the above post under the poi dependency.

    I solved the problem thanks to this thread, just wanted to thank you folks. :-)

    Cheers,

  9. #9
    Join Date
    Sep 2010
    Posts
    3

    Default

    got same exception:

    SEVERE: Exception starting filter Spring OpenEntityManagerInViewFilter
    java.lang.ClassCastException: org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter cannot be cast to javax.servlet.Filter
    ....

    Searched for servlet ad dependency but there is no thing like servlet-api (only tiles servlet, and jsp servlet).

    I tried reverting to older version of project (which was working for sure), but still get this error!

    HELP PLEASE!

    EDIT: ok. got it working!

    I used some patch to render velocity with tiles and it used JspFactory from javax.servlet.jsp.JspFactory
    after removing few lines of code all is working!
    Last edited by pawloch; Nov 3rd, 2010 at 11:09 AM.

  10. #10

    Default Same issue after including CXF

    Hi folks,

    I'm now getting this error, but only after I add CXF as a dependency. As noted before, if I run this as "mvn tomcat:run-war" everything is fine, but not when I run "mvn tomcat:run" so I'm a bit lost. the servlet-api is only listed once as provided, and when I comment that out, "mvn tomcat:run" still fails with the same error.

    /Mark

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •