We help IT Professionals succeed at work.

spring maven example issues

gudii9
gudii9 asked
on
1,619 Views
Last Modified: 2017-03-28
Hi,

I am trying below example
http://www.mkyong.com/spring3/spring-3-hello-world-example/

when i do mvn clean install from comand prompt getting below error

spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)


when i do internally from STS(like eclipse) editor maven clean is happening fine. While doing maven install getting below errors

COMPILATION ERROR :
[INFO] -------------------------------------------------------------
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-core\4.3.3.RELEASE\spring-core-4.3.3.RELEASE.jar; invalid LOC header (bad signature)
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-context\4.3.3.RELEASE\spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-context\4.3.3.RELEASE\spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)
/C:/gpFolder/stsWorkspace/SpringDemo1_03122017/src/main/java/com/mkyong/core/App.java:[3,35] package org.springframework.context does not exist
/C:/gpFolder/stsWorkspace/SpringDemo1_03122017/src/main/java/com/mkyong/core/App.java:[4,43] package org.springframework.context.support does not exist
how to resolve

my code is

pom.xml is
<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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.springframework.samples</groupId>
	<artifactId>SpringDemo1_03122017</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<properties>
		<!-- Generic properties -->
		<java.version>1.6</java.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>4.3.3.RELEASE</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>4.3.3.RELEASE</version>
		</dependency>
		
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>4.3.3.RELEASE</version>
		</dependency>
		
	</dependencies>
</project>

Open in new window


App.java is

package com.mkyong.core;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				"SpringBeans.xml");

		HelloWorld obj = (HelloWorld) context.getBean("helloBean");
		obj.printHello();
	}
}

Open in new window

HelloWorld class is
package com.mkyong.core;

/**
 * Spring bean
 *
 */
public class HelloWorld {
	private String name;

	public void setName(String name) {
		this.name = name;
	}

	public void printHello() {
		System.out.println("Spring 3 : Hello ! " + name);
	}
}

Open in new window

please advise
Comment
Watch Question

Java Architect
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
now i see

invalid LOC header (bad signature)
Bart CremersJava Architect

Commented:
This still looks like a corrupt jar file somewhere
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.