Announcement Announcement Module
Collapse
No announcement yet.
java.lang.NoSuchFieldError: APPLICATION_CONTEXT_ID_PREFIX (yet again!) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.NoSuchFieldError: APPLICATION_CONTEXT_ID_PREFIX (yet again!)

    Hi,

    New with Spring here.

    Using STS 2.7.1, I created a MVC project from the provided template. I could run it without problems in Tomcat 6 (controlled within STS).

    This is obviously a Maven project. It needs to use a jar which is not available in a public repository (LexEVS runtime - https://cabig-kc.nci.nih.gov/Vocab/K...LexEVS_6.0_API).

    As such, I thought I needed to add it to my local repository (using M2Eclipse shipped with STS). To do so, I ran this command on the command line:

    Code:
    mvn install:install-file -DgroupId=org.lexevs.local -DartifactId=lexruntime -Dpackaging=jar -Dversion=6.0.RELEASE -Dfile=E:\LexEVS\6_0\runtime\lbRuntime.jar -DgeneratePom=true
    It seemed to work well and it was indeed included in the repository.

    I then added it as a dependency. I added it manually to the POM (see bellow). It seemed to be ok so I created a JUnit test. I can run it without problems.

    Now when I try to run the project on Tomcat, I get the error above. Keeping everything the same, If I remove only the "LexEVS" entry from the POM, everything works well. If I add it, it brings the error above.

    POM:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    	<groupId>org.u936</groupId>
    	<artifactId>transform_proto</artifactId>
    	<name>abc</name>
    	<packaging>war</packaging>
    	<version>1.0.0-BUILD-SNAPSHOT</version>
    	<properties>
    		<java-version>1.6</java-version>
    		<org.springframework-version>3.0.5.RELEASE</org.springframework-version>
    		<org.springframework.roo-version>1.0.2.RELEASE</org.springframework.roo-version>
    		<org.aspectj-version>1.6.9</org.aspectj-version>
    		<org.slf4j-version>1.5.10</org.slf4j-version>
    	</properties>
    	<dependencies>
            
            <!-- LexEVS -->
    		<dependency>
    			<groupId>org.lexevs.local</groupId>
    			<artifactId>lexruntime</artifactId>
    			<version>6.0.RELEASE</version>
    		</dependency>
    		
    		<!-- Spring -->
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-context</artifactId>
    			<version>${org.springframework-version}</version>
    			<exclusions>
    				<!-- Exclude Commons Logging in favor of SLF4j -->
    				<exclusion>
    					<groupId>commons-logging</groupId>
    					<artifactId>commons-logging</artifactId>
    				 </exclusion>
    			</exclusions>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-webmvc</artifactId>
    			<version>${org.springframework-version}</version>
    		</dependency>
    		<!-- Roo dependencies -->
    		<dependency>
    			<groupId>org.springframework.roo</groupId>
    			<artifactId>org.springframework.roo.annotations</artifactId>
    			<version>${org.springframework.roo-version}</version>
    			<scope>provided</scope>
    		</dependency>
    				
    		<!-- AspectJ -->
    		<dependency>
    			<groupId>org.aspectj</groupId>
    			<artifactId>aspectjrt</artifactId>
    			<version>${org.aspectj-version}</version>
    		</dependency>	
    		
    		<!-- Logging -->
    		<dependency>
    			<groupId>org.slf4j</groupId>
    			<artifactId>slf4j-api</artifactId>
    			<version>${org.slf4j-version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.slf4j</groupId>
    			<artifactId>jcl-over-slf4j</artifactId>
    			<version>${org.slf4j-version}</version>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.slf4j</groupId>
    			<artifactId>slf4j-log4j12</artifactId>
    			<version>${org.slf4j-version}</version>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>log4j</groupId>
    			<artifactId>log4j</artifactId>
    			<version>1.2.15</version>
    			<exclusions>
    				<exclusion>
    					<groupId>javax.mail</groupId>
    					<artifactId>mail</artifactId>
    				</exclusion>
    				<exclusion>
    					<groupId>javax.jms</groupId>
    					<artifactId>jms</artifactId>
    				</exclusion>
    				<exclusion>
    					<groupId>com.sun.jdmk</groupId>
    					<artifactId>jmxtools</artifactId>
    				</exclusion>
    				<exclusion>
    					<groupId>com.sun.jmx</groupId>
    					<artifactId>jmxri</artifactId>
    				</exclusion>
    			</exclusions>
    			<scope>runtime</scope>
    		</dependency>
    
    		<!-- @Inject -->
    		<dependency>
    			<groupId>javax.inject</groupId>
    			<artifactId>javax.inject</artifactId>
    			<version>1</version>
    		</dependency>
    				
    		<!-- Servlet -->
    		<dependency>
    			<groupId>javax.servlet</groupId>
    			<artifactId>servlet-api</artifactId>
    			<version>2.5</version>
    			<scope>provided</scope>
    		</dependency>
    		<dependency>
    			<groupId>javax.servlet.jsp</groupId>
    			<artifactId>jsp-api</artifactId>
    			<version>2.1</version>
    			<scope>provided</scope>
    		</dependency>
    		<dependency>
    			<groupId>javax.servlet</groupId>
    			<artifactId>jstl</artifactId>
    			<version>1.2</version>
    		</dependency>
    	
    		<!-- Test -->
    		<dependency>
    			<groupId>junit</groupId>
    			<artifactId>junit</artifactId>
    			<version>4.7</version>
    			<scope>test</scope>
    		</dependency>
            
    	</dependencies>
    	<repositories>
    		<!-- For testing against latest Spring snapshots -->
    		<repository>
    			<id>org.springframework.maven.snapshot</id>
    			<name>Spring Maven Snapshot Repository</name>
    			<url>http://maven.springframework.org/snapshot</url>
    			<releases><enabled>false</enabled></releases>
    			<snapshots><enabled>true</enabled></snapshots>
    		</repository>
    		<!-- For developing against latest Spring milestones -->
    		<repository>
    			<id>org.springframework.maven.milestone</id>
    			<name>Spring Maven Milestone Repository</name>
    			<url>http://maven.springframework.org/milestone</url>
    			<snapshots><enabled>false</enabled></snapshots>
    		</repository>
    	</repositories>
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-compiler-plugin</artifactId>
    				<configuration>
    					<source>${java-version}</source>
    					<target>${java-version}</target>
    				</configuration>
    			</plugin>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-war-plugin</artifactId>
    				<configuration>
    					<warName>abc</warName>
    				</configuration>
    			</plugin>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-dependency-plugin</artifactId>
    				<executions>
    					<execution>
    						<id>install</id>
    						<phase>install</phase>
    						<goals>
    							<goal>sources</goal>
    						</goals>
    					</execution>
    				</executions>
    			</plugin>
    			<plugin>
    				<groupId>org.codehaus.mojo</groupId>
    				<artifactId>aspectj-maven-plugin</artifactId>
    				<!-- Have to use version 1.2 since version 1.3 does not appear to work with ITDs -->
    				<version>1.2</version>
    				<dependencies>
    					<!-- You must use Maven 2.0.9 or above or these are ignored (see MNG-2972) -->
    					<dependency>
    						<groupId>org.aspectj</groupId>
    						<artifactId>aspectjrt</artifactId>
    						<version>${org.aspectj-version}</version>
    					</dependency>
    					<dependency>
    						<groupId>org.aspectj</groupId>
    						<artifactId>aspectjtools</artifactId>
    						<version>${org.aspectj-version}</version>
    					</dependency>
    				</dependencies>
    				<executions>
    					<execution>
    						<goals>
    							<goal>compile</goal>
    							<goal>test-compile</goal>
    						</goals>
    					</execution>
    				</executions>
    				<configuration>
    					<outxml>true</outxml>
    					<source>${java-version}</source>
    					<target>${java-version}</target>
    				</configuration>
    			</plugin>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-surefire-plugin</artifactId>
    				<configuration>
    					<junitArtifactName>junit:junit</junitArtifactName>
    					<excludes>
    						<exclude>**/*_Roo_*</exclude>
    					</excludes>
    				</configuration>
    			</plugin>
    			<plugin>
    				<groupId>org.codehaus.mojo</groupId>
    				<artifactId>tomcat-maven-plugin</artifactId>
    				<version>1.0-beta-1</version>
    			</plugin>						
    		</plugins>
    	</build>
    </project>
    Now, I read around and figured this was often due to clashing version of same dependencies but... this is a 3rd party jar added manually to the local repository. And the JUnit works...

    Any help, insight or resource to deal with this would be great.

    Thanks in advance for your help.

    Let me know if I can provide more info to help.

    J.

  • #2
    Just as a quick follow-up,

    I verified that the jar is copied in the lib folder for Tomcat and it is. I tried to use the mvn install command with a different groupe/artifact/version (with and without the release) without success.

    In fact, starting back from a fresh spring source mvc template, I can execute it on tomcat 6 (hello.jsp is displayed with the appropriate date). Then, just adding the pom entry brings the error.

    Hopefully someone has some insight or could direct me to a more appropriate venue to ask this question.

    Thank you very much

    J.

    Comment


    • #3
      Can be considered as solved.

      Using a very useful tool : Tattletale (http://www.jboss.org/tattletale), I was able to identify duplicate packages that were causing the problem (included in the jar I was trying to add from the local repository).

      I hope this might be of some help for others too.

      J.

      Comment

      Working...
      X