Results 1 to 2 of 2
  1. #1
    savantics is offline Member
    Join Date
    Dec 2010
    Location
    Chicago area
    Posts
    2
    Rep Power
    0

    Default possible overlapping jars in spring annotated mvc/spring security project

    Hello,

    I am building a new java spring web application. It requires the usual stuff, security, database access, and some ajax functionality.

    I am using Spring MVC (org.springframework 3.0.3.VERSION) and Spring Security (org.springframework.security 2.0.6.VERSION). I am also using some of the spring JDBC support from 2.x (org.springframework.spring 2.5.6)

    I implemented a few simple use cases as non-annotated Spring Controllers they work fine and the security is configured and seems to be working. so far so good. Actually it is at this point it was a working application. but with no ajax component. and of course, this is what the users want and need.

    So next I attempted to incorporate some kind of AJAX support. It sure looks like JQuery and JSON are the way to go. All the examples I find seem to assume annotated Controllers, so I figure I should bite the bullet and convert my working but non-annotated mvc controllers to annotated versions. However, if this is not a valid assumption, I would appreciate hearing why not and I would also appreciate being pointed in the direction of a good working example of ajax with non-annotated spring mvc controllers which is something I was not able to find.

    So assuming that I need to move to annotated controllers before I can incorporate ajax functionality, I am working through the process of modifying my non-annotated Controllers to annotated Controllers.

    My most recent error when deploying my war file on a tomcat server is this:

    Java Code:
    javax.servlet.ServletException: Servlet.init() for servlet cpl threw exception
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	java.lang.Thread.run(Thread.java:619)
    
    
    root cause 
    
    java.lang.NoSuchFieldError: APPLICATION_CONTEXT_ID_PREFIX
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:430)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	java.lang.Thread.run(Thread.java:619)
    so I have been researching this particular error, and it would seem that I need to investigate either missing or overlapping jars.

    if I were to first look for missing jars, it would seem that this is a fundamental component of spring mvc so I must have it somewhere. perhaps more than one jar. So I am now assuming that I have this package or my non-annotated Spring mvc wouldn't be working either. So now I think I have an overlapping jar issue.

    This is a maven project with several poms , the parent pom being named cpl-webapp, and the com.atg.resource.cpl being the groupId for my project. so I will just include the dependency:tree results associated with the parent.

    Java Code:
    [INFO] [dependency:tree {execution: default-cli}]
    [INFO] com.atg.resource.cpl.webapp:cpl-webapp:war:1.0-SNAPSHOT
    [INFO] +- com.atg.resource.cpl.model:cpl-model:jar:1.0-SNAPSHOT:compile
    [INFO] |  +- com.atg.resource.cpl.util:cpl-common:jar:1.0-SNAPSHOT:compile
    [INFO] |  +- commons-lang:commons-lang:jar:2.5:compile
    [INFO] |  +- org.hibernate:hibernate-annotations:jar:3.3.0.ga:compile
    [INFO] |  |  \- javax.persistence:persistence-api:jar:1.0:compile
    [INFO] |  \- org.hibernate:hibernate:jar:3.2.5.ga:compile
    [INFO] |     +- net.sf.ehcache:ehcache:jar:1.2.3:compile
    [INFO] |     +- asm:asm-attrs:jar:1.5.3:compile
    [INFO] |     \- antlr:antlr:jar:2.7.6:compile
    [INFO] +- com.atg.resource.cpl.persist:cpl-persist:jar:1.0-SNAPSHOT:compile
    [INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.3.0.ga:compile
    [INFO] |  +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:compile
    [INFO] |  +- org.springframework:spring:jar:2.5.6:compile
    [INFO] |  +- net.sourceforge.jtds:jtds:jar:1.2.5:compile
    [INFO] |  \- org.apache.commons.dbcp:commons-dbcp:jar:1.2.2:compile
    [INFO] +- com.atg.resource.cpl.service:cpl-service:jar:1.0-SNAPSHOT:compile
    [INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
    [INFO] |  +- jaxen:jaxen:jar:1.1.1:compile
    [INFO] |  |  +- jdom:jdom:jar:1.0:compile
    [INFO] |  |  \- xom:xom:jar:1.0:compile
    [INFO] |  |     +- xerces:xmlParserAPIs:jar:2.6.2:compile
    [INFO] |  |     +- xalan:xalan:jar:2.6.0:compile
    [INFO] |  |     \- com.ibm.icu:icu4j:jar:2.6.1:compile
    [INFO] |  +- com.gnostice.pdfone:PDFOne:jar:1.1.1:compile
    [INFO] |  \- org.apache.pdfbox:pdfbox:jar:1.2.1:compile
    [INFO] |     +- org.apache.pdfbox:fontbox:jar:1.2.1:compile
    [INFO] |     \- org.apache.pdfbox:jempbox:jar:1.2.1:compile
    [INFO] +- org.springframework:spring-context:jar:3.0.3.RELEASE:compile
    [INFO] |  +- org.springframework:spring-aop:jar:3.0.3.RELEASE:compile
    [INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
    [INFO] |  +- org.springframework:spring-beans:jar:3.0.3.RELEASE:compile
    [INFO] |  +- org.springframework:spring-core:jar:3.0.3.RELEASE:compile
    [INFO] |  +- org.springframework:spring-expression:jar:3.0.3.RELEASE:compile
    [INFO] |  \- org.springframework:spring-asm:jar:3.0.3.RELEASE:compile
    [INFO] +- org.springframework:spring-webmvc:jar:3.0.3.RELEASE:compile
    [INFO] |  +- org.springframework:spring-context-support:jar:3.0.3.RELEASE:compile
    [INFO] |  \- org.springframework:spring-web:jar:3.0.3.RELEASE:compile
    [INFO] +- org.springframework.webflow:spring-js:jar:2.2.1.RELEASE:compile
    [INFO] |  +- commons-logging:commons-logging:jar:1.1.1:compile
    [INFO] |  \- org.springframework.webflow:spring-js-resources:jar:2.2.1.RELEASE:compile
    [INFO] +- org.slf4j:slf4j-api:jar:1.5.10:compile
    [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.5.10:runtime
    [INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.10:runtime (scope not updated to compile)
    [INFO] +- log4j:log4j:jar:1.2.16:runtime (scope not updated to compile)
    [INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.5.3:compile
    [INFO] |  \- org.codehaus.jackson:jackson-core-asl:jar:1.5.3:compile
    [INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
    [INFO] +- org.hibernate:hibernate-validator:jar:4.0.2.GA:compile
    [INFO] |  +- javax.xml.bind:jaxb-api:jar:2.1:compile
    [INFO] |  |  +- javax.xml.stream:stax-api:jar:1.0-2:compile
    [INFO] |  |  \- javax.activation:activation:jar:1.1:compile
    [INFO] |  \- com.sun.xml.bind:jaxb-impl:jar:2.1.3:compile
    [INFO] +- cglib:cglib:jar:2.1_3:compile
    [INFO] |  \- asm:asm:jar:1.5.3:compile
    [INFO] +- commons-pool:commons-pool:jar:1.2:compile
    [INFO] |  +- commons-collections:commons-collections:jar:2.1:compile
    [INFO] |  +- xml-apis:xml-apis:jar:1.0.b2:compile
    [INFO] |  \- xerces:xercesImpl:jar:2.0.2:compile
    [INFO] +- org.apache.geronimo.specs:geronimo-servlet_2.5_spec:jar:1.2:provided
    [INFO] +- javax.servlet:jstl:jar:1.2:compile
    [INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided
    [INFO] +- taglibs:standard:jar:1.1.2:compile
    [INFO] +- taglibs:string:jar:1.1.0:compile
    [INFO] +- ognl:ognl:jar:2.7.3:compile
    [INFO] |  \- jboss:javassist:jar:3.7.ga:compile
    [INFO] +- org.aspectj:aspectjrt:jar:1.6.1:compile
    [INFO] +- com.itextpdf.itext:iText:jar:5.0.4:compile
    [INFO] +- junit:junit:jar:4.4:test
    [INFO] +- org.springframework.security:spring-security-core:jar:2.0.6.RELEASE:compile
    [INFO] |  +- org.springframework:spring-support:jar:2.0.8:runtime
    [INFO] |  \- commons-codec:commons-codec:jar:1.3:compile
    [INFO] +- org.springframework.security:spring-security-core-tiger:jar:2.0.6.RELEASE:compile
    [INFO] +- org.springframework.security:spring-security-acl:jar:2.0.6.RELEASE:compile
    [INFO] |  \- org.springframework:spring-jdbc:jar:2.0.8:compile
    [INFO] |     \- org.springframework:spring-dao:jar:2.0.8:compile
    [INFO] \- org.springframework.security:spring-security-taglibs:jar:2.0.6.RELEASE:compile

    Note that within the org.springframework.security jars, I have tried excluding all the spring 2.0.8 jars. this made no difference so I put them back in.

    I am not very sure how to analyze and identify overlapping jars. My instinct would be to look for duplicate jar names with different versions. One thing I tried to determine (without finding a difinitive answer) is whether the 2.5.6 JDBC stuff exists somewhere in 3.0.3 where I can swap out the old with something new? But the trail on that jar seems to stop at 2.5.6.

    I didn't want to load this post up with a lot of extraneous stuff, but assume pretty classic Dispatcher Servlet config in my web.xml. Keep in mind that this was recently working in a non-annotated controller approach. Here is my current cpl-servlet.xml as modified for annotations, just in case its useful

    Java Code:
    <?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:p="http://www.springframework.org/schema/p"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    	http://www.springframework.org/schema/context
    	http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    	
    	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    	</bean>
    
    	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    	</bean>
    
    	<context:component-scan base-package="com.atg.resource.cpl.web.spring.controller" />
    	
    	<context:annotation-config/>
    	
    	<bean id="viewResolver"
    		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="viewClass"
    			value="org.springframework.web.servlet.view.JstlView" />
    		<property name="prefix" value="/WEB-INF/views/" />
    		<property name="suffix" value=".jsp" />
    	</bean>
    	
    </beans>
    I am of course hoping that someone out there with better knowledge of what is in which jars will be able to eyeball and identify the issue. But if there are resources that give advice or list tools for analyzing or finding overlapping jars, that would be welcome information too.

    thank you in advance,

  2. #2
    savantics is offline Member
    Join Date
    Dec 2010
    Location
    Chicago area
    Posts
    2
    Rep Power
    0

    Default

    I have resolved this issue.
    my problems stemmed from two version mixing issues.
    i upgraded spring security to 3.0.5.RELEASE
    and made all spring jars consistent.

    It would now appear that I have Spring MVC, Hibernate and Spring Security working, at least superficially.

    here is the results of an mvn dependency:tree

    Java Code:
    [INFO] ------------------------------------------------------------------------
    [INFO] [dependency:tree {execution: default-cli}]
    [INFO] com.atg.resource.cpl.webapp:cpl-webapp:war:1.0-SNAPSHOT
    [INFO] +- com.atg.resource.cpl.model:cpl-model:jar:1.0-SNAPSHOT:compile
    [INFO] |  +- com.atg.resource.cpl.util:cpl-common:jar:1.0-SNAPSHOT:compile
    [INFO] |  +- commons-lang:commons-lang:jar:2.5:compile
    [INFO] |  +- org.hibernate:hibernate-annotations:jar:3.3.0.ga:compile
    [INFO] |  |  \- javax.persistence:persistence-api:jar:1.0:compile
    [INFO] |  \- org.hibernate:hibernate:jar:3.2.5.ga:compile
    [INFO] |     +- net.sf.ehcache:ehcache:jar:1.2.3:compile
    [INFO] |     +- asm:asm-attrs:jar:1.5.3:compile
    [INFO] |     \- antlr:antlr:jar:2.7.6:compile
    [INFO] +- com.atg.resource.cpl.persist:cpl-persist:jar:1.0-SNAPSHOT:compile
    [INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.3.0.ga:compile
    [INFO] |  +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:compile
    [INFO] |  +- org.springframework:spring-core:jar:3.0.3.RELEASE:compile
    [INFO] |  +- org.springframework:spring-orm:jar:3.0.3.RELEASE:compile
    [INFO] |  +- net.sourceforge.jtds:jtds:jar:1.2.5:compile
    [INFO] |  \- org.apache.commons.dbcp:commons-dbcp:jar:1.2.2:compile
    [INFO] +- com.atg.resource.cpl.service:cpl-service:jar:1.0-SNAPSHOT:compile
    [INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
    [INFO] |  +- jaxen:jaxen:jar:1.1.1:compile
    [INFO] |  |  +- jdom:jdom:jar:1.0:compile
    [INFO] |  |  \- xom:xom:jar:1.0:compile
    [INFO] |  |     +- xerces:xmlParserAPIs:jar:2.6.2:compile
    [INFO] |  |     +- xalan:xalan:jar:2.6.0:compile
    [INFO] |  |     \- com.ibm.icu:icu4j:jar:2.6.1:compile
    [INFO] |  +- com.gnostice.pdfone:PDFOne:jar:1.1.1:compile
    [INFO] |  \- org.apache.pdfbox:pdfbox:jar:1.2.1:compile
    [INFO] |     +- org.apache.pdfbox:fontbox:jar:1.2.1:compile
    [INFO] |     \- org.apache.pdfbox:jempbox:jar:1.2.1:compile
    [INFO] +- org.springframework:spring-context:jar:3.0.3.RELEASE:compile
    [INFO] |  +- org.springframework:spring-aop:jar:3.0.3.RELEASE:compile
    [INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
    [INFO] |  +- org.springframework:spring-beans:jar:3.0.3.RELEASE:compile
    [INFO] |  +- org.springframework:spring-expression:jar:3.0.3.RELEASE:compile
    [INFO] |  \- org.springframework:spring-asm:jar:3.0.3.RELEASE:compile
    [INFO] +- org.springframework:spring-webmvc:jar:3.0.3.RELEASE:compile
    [INFO] |  +- org.springframework:spring-context-support:jar:3.0.3.RELEASE:compile
    [INFO] |  \- org.springframework:spring-web:jar:3.0.3.RELEASE:compile
    [INFO] +- org.springframework.webflow:spring-js:jar:2.2.1.RELEASE:compile
    [INFO] |  +- commons-logging:commons-logging:jar:1.1.1:compile
    [INFO] |  \- org.springframework.webflow:spring-js-resources:jar:2.2.1.RELEASE:compile
    [INFO] +- org.slf4j:slf4j-api:jar:1.5.10:compile
    [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.5.10:runtime
    [INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.10:runtime (scope not updated to compile)
    [INFO] +- log4j:log4j:jar:1.2.16:runtime (scope not updated to compile)
    [INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.5.3:compile
    [INFO] |  \- org.codehaus.jackson:jackson-core-asl:jar:1.5.3:compile
    [INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
    [INFO] +- org.hibernate:hibernate-validator:jar:4.0.2.GA:compile
    [INFO] |  +- javax.xml.bind:jaxb-api:jar:2.1:compile
    [INFO] |  |  +- javax.xml.stream:stax-api:jar:1.0-2:compile
    [INFO] |  |  \- javax.activation:activation:jar:1.1:compile
    [INFO] |  \- com.sun.xml.bind:jaxb-impl:jar:2.1.3:compile
    [INFO] +- cglib:cglib:jar:2.1_3:compile
    [INFO] |  \- asm:asm:jar:1.5.3:compile
    [INFO] +- commons-pool:commons-pool:jar:1.2:compile
    [INFO] |  +- commons-collections:commons-collections:jar:2.1:compile
    [INFO] |  +- xml-apis:xml-apis:jar:1.0.b2:compile
    [INFO] |  \- xerces:xercesImpl:jar:2.0.2:compile
    [INFO] +- org.apache.geronimo.specs:geronimo-servlet_2.5_spec:jar:1.2:provided
    [INFO] +- javax.servlet:jstl:jar:1.2:compile
    [INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided
    [INFO] +- taglibs:standard:jar:1.1.2:compile
    [INFO] +- taglibs:string:jar:1.1.0:compile
    [INFO] +- ognl:ognl:jar:2.7.3:compile
    [INFO] |  \- jboss:javassist:jar:3.7.ga:compile
    [INFO] +- org.aspectj:aspectjrt:jar:1.6.1:compile
    [INFO] +- com.itextpdf.itext:iText:jar:5.0.4:compile
    [INFO] +- junit:junit:jar:4.4:test
    [INFO] +- org.springframework.security:spring-security-core:jar:3.0.5.RELEASE:compile
    [INFO] |  +- org.springframework:spring-tx:jar:3.0.3.RELEASE:compile
    [INFO] |  \- org.aspectj:aspectjweaver:jar:1.6.8:compile
    [INFO] +- org.springframework.security:spring-security-web:jar:3.0.5.RELEASE:compile
    [INFO] +- org.springframework.security:spring-security-config:jar:3.0.5.RELEASE:compile
    [INFO] +- org.springframework.security:spring-security-acl:jar:3.0.5.RELEASE:compile
    [INFO] |  \- org.springframework:spring-jdbc:jar:3.0.3.RELEASE:compile
    [INFO] \- org.springframework.security:spring-security-taglibs:jar:3.0.5.RELEASE:compile

Similar Threads

  1. GAE + Spring Security
    By kievari in forum Advanced Java
    Replies: 0
    Last Post: 12-12-2010, 10:19 PM
  2. Spring Security + Crowd
    By Cbani in forum Advanced Java
    Replies: 4
    Last Post: 09-14-2010, 03:01 PM
  3. spring security tutorial
    By devstarter in forum New To Java
    Replies: 1
    Last Post: 03-01-2010, 07:51 PM
  4. Custom role in spring security
    By ngoc61 in forum Web Frameworks
    Replies: 1
    Last Post: 08-07-2009, 04:39 AM
  5. spring security and struts2
    By ngoc61 in forum Web Frameworks
    Replies: 0
    Last Post: 03-09-2009, 10:26 AM

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
  •