-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using setExtraClasspath("lib/extra/*") does not work on Microsoft Windows #3489
Comments
What version of Java are you using? |
Do you have a |
I'm using java 1.8. Because I'm working on a standalone app, I'm declaring it like here: |
@joakime or @nomeaning25 if you have a windowsNT machine can you report what the result of a very simple program that just calls new File("lib/ext/*").getCanonicalPath() is? I am assuming windowsNT doesn't like the *. |
@janbartel you are right. The problem is with .getCanonicalPath() on windows when the file path is called with "*". The problem is when new Resource is initialized: https://github.com/eclipse/jetty.project/blob/cd304eb65b28bce8583cf3b71ed1e73dca6d4916/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java line 282 The solution would probably be to remove * when creating new resource. |
Windows doesn't like the splat The old File file = new File("lib/ext/*");
System.out.println("File: " + file);
File absFile = file.getAbsoluteFile();
System.out.println("absFile: " + absFile);
File canFile = file.getCanonicalFile();
System.out.println("canFile: " + canFile); Results in ...
Even if you try to work with it as a File file = new File("lib/ext/*");
System.out.println("File: " + file);
File absFile = file.getAbsoluteFile();
System.out.println("absFile: " + absFile);
Path path = absFile.toPath();
System.out.println("path: " + path); Results in ...
However, not all is lost, you might be able to just use the Example: WebAppContext context = new WebAppContext();
WebAppClassLoader cl = new WebAppClassLoader(context);
context.setClassLoader(cl);
cl.addJars(Resource.newResource("lib/ext"));
// ... other initialization here ..
// dump state at a later point to see what's actually in the webapp's own classloader.
context.dump(System.out); |
+ Moving Resource.newResource() to later point Signed-off-by: Joakim Erdfelt <[email protected]>
Opened PR #3495 to allow this to work on MS Windows. |
@joakime your solution works for me. The jars are added to classpath. |
…-splat-windows Issue #3489 - Allowing JAR directory references on Windows
A general fix for Windows has been applied (to branch |
This Bug is not fixed completely. I just ran into the following exception for the same scenario:-Using setExtraClasspath("lib/extra/*") does not work on Microsoft Windows I have the fix ready though.... |
@sonyDeswal this is the java doc:
So directories should end with '/' character. |
In that case my jars were not loaded, as a result spring initialization was failing with ClassNotFound Exception. On Jun 13, 2020 4:39 PM, Jan Bartel <[email protected]> wrote:
@sonyDeswal this is the java doc:
* @param extraClasspath Comma or semicolon separated path of filenames or URLs
* pointing to directories or jar files. Directories should end
* with '/'.
So directories should end with '/' character.
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
|
As I understand, it is missing "getJars(Dir..)" in case of a directory as a resource. It is just adding the dir path as a resource,thus jars under that dir are not added to classpath. I can fix that too...
On Saturday, June 13, 2020, 11:31:20 PM GMT+5:30, <[email protected]> wrote:
In that case my jars were not loaded, as a result spring initialization was failing with ClassNotFound Exception.
On Jun 13, 2020 4:39 PM, Jan Bartel <[email protected]> wrote:
@sonyDeswal this is the java doc:
* @param extraClasspath Comma or semicolon separated path of filenames or URLs
* pointing to directories or jar files. Directories should end
* with '/'.
So directories should end with '/' character.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Trying to add extra Jars to classpath using:
context.setExtraClasspath("lib/extra/*");
Which was added in #150
The error I get is:
The jars are not added to class path since i still get class not found exception.
I am using jetty version 9.4.15.v20190215 embedding it with maven plugin.
The text was updated successfully, but these errors were encountered: