Link to home
Create AccountLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

spring maven example issues

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
ASKER CERTIFIED SOLUTION
Avatar of Bart Cremers
Bart Cremers
Flag of Belgium image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of gudii9

ASKER

now i see

invalid LOC header (bad signature)
This still looks like a corrupt jar file somewhere