[SOLVED] An unexpected error occurred while trying to open jar

Issue

I have a spring batch project exported as a runable Jar file, it has 4 main methods, only one main is working, the other main needs referenced jar jai-codec-1.1.3.jar, but when I put the jar in the classpath, the first main also could not working and it gives error message “An unexpected error occurred while trying to open jar”

here is my mainfest file:

Manifest-Version: 1.0 Class-Path: JARS/spring-jdbc-3.1.1.RELEASE.jar
JARS/spring-context-3.2.3.RELEASE.jar JARS/log4j-1.2.14.jar
JARS/spring-tx-3.2.3.RELEASE.jar JARS/spring-core-3.2.3.RELEASE.jar
JARS/spring-beans-3.2.3.RELEASE.jar JARS/commons-logging-1.1.1.jar
JARS/spring-aop-3.2.3.RELEASE.jar JARS/aopalliance-1.0.jar
JARS/spring-expression-3.2.3.RELEASE.jar JARS/commons-dbcp-1.4.jar
JARS/commons-pool-1.5.4.jar JARS/ojdbc6-11.2.0.3.jar
JARS/commons-lang3-3.0.jar JARS/itextpdf-5.5.1.jar
JARS/jdom2-2.0.5.jar JARS/jai-codec-1.1.3.jar

I found out that it is not because the specific jar file, it is because the length of the classpath is exceeded the limit, is there a way to put more jars in the MAINFEST file classpath?

also I have defined all @autowired service and component classes but it still not working in jar, it only works when I defined those as bean in spring-config.

Anyone can Help me to figure out why?

Solution

Problem solved. I am not sure if it is the limitation of classpath size in MAINFEST file, but it really matters when it was too long, I changed all jar name as 1, 2 , 3… and be able to put all jars in the classpath, and it works. Please leave your comments if you have different opinion on this, Thanks.

Answered By – user3666635

Answer Checked By – Robin (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *