Skip to content
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

[JENKINS-48347] - Failed to locate JAR file by URL zip: #46

Closed
bcastellucci opened this issue Dec 1, 2017 · 9 comments
Closed

[JENKINS-48347] - Failed to locate JAR file by URL zip: #46

bcastellucci opened this issue Dec 1, 2017 · 9 comments
Assignees
Milestone

Comments

@bcastellucci
Copy link
Contributor

Greetings.

I am getting an exception from winp (v1.25, bundled with Jenkins LTS 2.73.3), specifically from Native.java, line 144.

I believe it is coming from the getJarFile() method. There is an if-statement on line 166 that returns null if the url doesn't start with jar: or wsjar:.

In my case the url starts with zip: so it is failing the test & coming up null.

Does this need a code fix or is there something I can do on my end to workaround the issue?


Dec 01, 2017 3:58:35 PM org.jvnet.winp.Native loadByUrl
WARNING: Failed to load DLL from static location
java.lang.RuntimeException: Failed to locate JAR file by URL zip:C:/[[[path redacted]]]/servers/AdminServer/tmp/_WL_user/Jenkins_LTS_2.73.3/frocxk/war/WEB-INF/lib/winp-1.25.jar!/winp.x64.dll
at org.jvnet.winp.Native.extractToStaticLocation(Native.java:144)
at org.jvnet.winp.Native.loadByUrl(Native.java:129)
at org.jvnet.winp.Native.load(Native.java:99)
at org.jvnet.winp.Native.(Native.java:70)
at org.jvnet.winp.WinProcess.enableDebugPrivilege(WinProcess.java:226)
at hudson.util.ProcessTree$Windows.(ProcessTree.java:555)
at hudson.util.ProcessTree.get(ProcessTree.java:350)
at hudson.Launcher$LocalLauncher.kill(Launcher.java:949)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:502)
at hudson.model.Run.execute(Run.java:1737)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)

@oleg-nenashev
Copy link
Member

Hmm... There is no problem to support zip::, but I wonder how it happens. It would be nice to know which OS and Java version you use.

Please also create a bug in https://issues.jenkins-ci.org/

@oleg-nenashev oleg-nenashev self-assigned this Dec 1, 2017
@bcastellucci
Copy link
Contributor Author

Sorry - the OS is Windows Server 2008 R2.
Java version is 1.8.0_121
Additional info - Jenkins is deployed to WebLogic 12.1.3 (which was an adventure all by itself).
This problem came up while email-ext was attempting to connect to the SMTP server however I believe winp is in Jenkins core.
I will create a bug in Jenkins JIRA for this - is there any other info you would need in that issue?
Thanks!

@bcastellucci
Copy link
Contributor Author

Jenkins bug filed -
https://issues.jenkins-ci.org/browse/JENKINS-48347

@bcastellucci
Copy link
Contributor Author

ok, I believe it is the WebLogic classloader - I found a few threads discussing how it is very different from just about every other vendor and this zip: protocol for a jar file URL is one of the differences. There is also no file: in the file portion of the URL.

I cloned the master branch and made a couple of changes to Native.java then re-built the library and included it in my Jenkins war file and it seems to work OK.

I could do a pull request with the changes so you can see them if you'd like but I am new to GIT and am unsure if I have done things correctly.

I committed to my local clone of master, is that appropriate or should I have created a local branch first?

I could also just paste the changes I made here in a comment if you feel better about that.

Let me know.

Thanks!
Ben

@oleg-nenashev
Copy link
Member

I think I have enough info to fix the issue though I doubt I will be able to reproduce it in Jenkins.

@bcastellucci
Copy link
Contributor Author

ok, for reference, here is the getJarFile() method as I have changed it:

private static File getJarFile(URL res) {

    String url = res.toExternalForm();
    if (!(url.startsWith("jar:") || url.startsWith("wsjar:") || url.startsWith("zip:"))) {
        return null;
    }

    int idx = url.lastIndexOf('!');
    String filePortion = url.substring(url.indexOf(':') + 1, idx);
    while (filePortion.startsWith("/")) {
        filePortion = filePortion.substring(1);
    }

    if (filePortion.startsWith("file:")) {
    	filePortion = filePortion.substring(5);
    }
    
    if (filePortion.startsWith("///")) {
        // JDK on Unix uses file:/home/kohsuke/abc, whereas
        // I believe RFC says file:///home/kohsuke/abc/... is correct.
        filePortion = filePortion.substring(2);
    } /*else if (filePortion.startsWith("//")) {
        // this indicates file://host/path-in-host format
        // Windows maps UNC path to this. On Unix, there's no well defined
        // semantics for  this.
    }*/

    filePortion = URLDecoder.decode(filePortion);
    return new File(filePortion.replace('/', File.separatorChar));

}

@oleg-nenashev
Copy link
Member

@bcastellucci yah, feel free to just create a pull request (bonus points for autotests, but it is likely not required in this case)

@bcastellucci
Copy link
Contributor Author

ok, I submitted a pull request.

As I said, I am new to GitHub so I am not sure if I did things right, especially when it comes to associating the commit/pull request to this issue.

I forked the repository, created my own branch (zip-jar-url), committed to it, pushed it then created a pull request for that back to the master.

I hope it's right...

@oleg-nenashev oleg-nenashev added this to the winp-1.26 milestone Jan 3, 2018
@oleg-nenashev oleg-nenashev changed the title Failed to locate JAR file by URL zip: [JENKINS-48347] - Failed to locate JAR file by URL zip: Mar 4, 2018
oleg-nenashev added a commit that referenced this issue Mar 4, 2018
[Issue #46] - Modified to accommodate Weblogic classloader JAR file URL style
@oleg-nenashev
Copy link
Member

I released it in 1.26. My apologies for the delay. It took a while for me to spin the release due to the Windows environment issues. I hope to automate releases at some point like I did for WinSW

Jenkins PR: jenkinsci/jenkins#3399

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants