Michi
Michi

Reputation: 577

Winrun4j: Exceeded maximum classpath size

My project has many dependencies and I tell winrun4j to include all of them by setting

classpath.1=D:\lib\*.jar

in the ini file.

The service log is telling me that that winrun4j is expanding classpath and generating a classpath:

[info] Expanding Classpath: D:\lib\*.jar
[info] Expanding Classpath: D:\lib\activation-1.1.1.jar
[info] Expanding Classpath: D:\lib\activemq-client-5.10.2.jar
[...]
[...]many, many other libs here
[...]
[warn] Exceeded maximum classpath size
[info] Generated Classpath: D:\lib\activation-.1.1.jar;D:\lib\activemq-client-5.10.2.jar;[...]

Why is winrun4j generating a classpath like this? Shouldn't it be enough to just take

D:\lib\*.jar

?

Any ideas for a workaround to get the service running with that many dependencies?

Upvotes: 2

Views: 496

Answers (3)

davidxxx
davidxxx

Reputation: 131346

It is winrun4j problem known for a long time, not solved and discussed here :

Exceeds maximum classpath length #59

https://github.com/poidasmith/winrun4j/issues/59

and here :

Add an INI option to disable classpath glob expansion #67

https://github.com/poidasmith/winrun4j/issues/67

Unfortunately, you have not many possibilities. As the issue 59 suggests, you could set the working directory to be the module directory. You could spare some characters.

D:\lib\activation-.1.1.jar; would become lib\activation-.1.1.jar;. You could also check that all dependencies are needed.

If it not enough, you should seriously look for a alternative such as JSmooth or Launch4J.

Upvotes: 3

dpr
dpr

Reputation: 10964

Instead of putting all dependencies into the libs folder and adding them to the classpath you could build a fat-JAR that contains all of your dependent libraries in a single JAR file.

How to achieve this very much depends on the build system you use (e.g. gradle or maven). Or you could take a look at spring-boot which works with fat-JARs by default.

Upvotes: 1

Sabir Khan
Sabir Khan

Reputation: 10142

This is winrun4j specific issue as you can see in winrun4j code that this message is hard coded , Classpath.cpp Github

// Check for too many results
    if(*current >= max) {
        if(!g_classpathMaxWarned) {
            Log::Warning("Exceeded maximum classpath size");
            g_classpathMaxWarned = true;
        }
        return;
}

From code, I am not able to figure out exact value for max but there are unit tests at code base that set it to 260.

I think, this is relevant question from where MAX_PATH is coming into picture.

As pointed in another answer, issue is not resolved as limit is hard coded.

Upvotes: 1

Related Questions