2

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?

Michi
  • 487
  • 5
  • 20
  • The java command itself should allow for "*" wildcards in the classpath. So maybe that is a problem with winrun4j itself. Have you checked if that tool has some forum/bugtracker you could look into? – GhostCat Jan 03 '17 at 09:10

3 Answers3

3

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.

davidxxx
  • 125,838
  • 23
  • 214
  • 215
1

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.

Community
  • 1
  • 1
Sabir Khan
  • 9,826
  • 7
  • 45
  • 98
  • Thank you, but the log message only appears when the generated classpath length is way more than 260 chars. The logged generated classpath is cut after 3996 chars. – Michi Jan 03 '17 at 10:04
  • Thats the value that I am not sure of. I couldn't find that value in their code base, seems coming from some header file. – Sabir Khan Jan 03 '17 at 10:10
1

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.

dpr
  • 10,591
  • 3
  • 41
  • 71