Yasser Zamani,

Run your test codes below:
private void testStruts2()
{
  try {
    Iterator<URL> strutsDefaultXmls = 
ClassLoaderUtil.getResources("struts-default.xml", this.getClass(), true);
    while (strutsDefaultXmls.hasNext())
    {
      URLConnection conn = strutsDefaultXmls.next().openConnection();
      System.out.println("COPY ME: " + conn.toString()); 
conn.getInputStream().close();
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}

Here is the output:
COPY ME: 
weblogic.utils.zip.ZipURLConnection:zip:C:/Oracle/Middleware/Oracle_Home12.2.1.0.0/user_projects/domains/iwa_local_domain/servers/AdminServer/tmp/_WL_user/IWA/zfd81u/war/WEB-INF/lib/struts2-core.jar!/struts-default.xml


--------
Also, below is URL connection object that is passed to 
StrutsJarURLConnection.openConnection(URL url):
url-type=java.net.URL
url.toString=zip:C:/Oracle/Middleware/Oracle_Home12.2.1.0.0/user_projects/domains/iwa_local_domain/servers/AdminServer/tmp/_WL_user/IWA/zfd81u/war/WEB-INF/lib/struts2-core.jar!/struts-default.xml
url.getProtocol=zip
url.getPath=C:/Oracle/Middleware/Oracle_Home12.2.1.0.0/user_projects/domains/iwa_local_domain/servers/AdminServer/tmp/_WL_user/IWA/zfd81u/war/WEB-INF/lib/struts2-core.jar!/struts-default.xml
url.getPort=-1
url.getQuery=null
url.getFile=C:/Oracle/Middleware/Oracle_Home12.2.1.0.0/user_projects/domains/iwa_local_domain/servers/AdminServer/tmp/_WL_user/IWA/zfd81u/war/WEB-INF/lib/struts2-core.jar!/struts-default.xml
url.getHost=
url.getRef=null
url.getAuthority=
url.getDefaultPort=-1

Thanks,
Liem.



  *   From: Yasser Zamani <y...@apache.org>
Subject: Re: BUG in struts-2.5.15
Date: 2018/02/15 15:12:39
List: 
user@struts.apache.org<https://lists.apache.org/list.html?user@struts.apache.org>


*

[https://lists.apache.org/images/quote.png]



On 2/14/2018 7:13 PM, liemngu...@ups.com.INVALID wrote:

> Hi all,

>

> Testing your upcoming struts-2.5.15, when starting Weblogic server (Weblogic 
> server version 12.2.1.2.0, JDK v 1.8.0_101), we see exception below.

>

> Thanks,

> Liem.

> --------------------------------------------

>

> 2018-02-14 10:28:37.194 WARN  - Could not create JarEntryRevision for 
> [zip:C:/Oracle/Middleware/Oracle_Home12.2.1.0.0/user_projects/domains/iwa_local_domain/servers/AdminServer/tmp/_WL_user/IWA/zfd81u/war/WEB-INF/lib/struts2-core.jar!/struts-default.xml]!

> java.net.MalformedURLException: unknown protocol: c

>                 at java.net.URL.<init>(URL.java:600) ~[?:1.8.0_101]

>                 at java.net.URL.<init>(URL.java:490) ~[?:1.8.0_101]

>                 at java.net.URL.<init>(URL.java:439) ~[?:1.8.0_101]

>                 at 
> java.net.JarURLConnection.parseSpecs(JarURLConnection.java:175) ~[?:1.8.0_101]

>                 at 
> java.net.JarURLConnection.<init>(JarURLConnection.java:158) ~[?:1.8.0_101]

>                 at 
> com.opensymphony.xwork2.util.fs.StrutsJarURLConnection.<init>(StrutsJarURLConnection.java:44)
>  ~[struts2-core.jar:2.5.15]

>                 at 
> com.opensymphony.xwork2.util.fs.StrutsJarURLConnection.openConnection(StrutsJarURLConnection.java:99)
>  ~[struts2-core.jar:2.5.15]

>                 at 
> com.opensymphony.xwork2.util.fs.JarEntryRevision.build(JarEntryRevision.java:42)
>  [struts2-core.jar:2.5.15]

>                 at 
> com.opensymphony.xwork2.util.fs.DefaultFileManager.monitorFile(DefaultFileManager.java:94)
>  [struts2-core.jar:2.5.15]





Hi Liem,



Thank you so much for your report and nice catch!



It seems weblogic is commerical and so I cannot try this myself then may

I ask you to run following code in your action then examine output and

reply me every line starting with "COPY ME:"?



import com.opensymphony.xwork2.util.ClassLoaderUtil;



    public String execute() throws Exception {

        Iterator<URL> strutsDefaultXmls =

ClassLoaderUtil.getResources("struts-default.xml", this.getClass(), true);

        while (strutsDefaultXmls.hasNext()) {

            URLConnection conn = strutsDefaultXmls.next().openConnection();

            System.out.println("COPY ME: " + conn.toString());

            conn.getInputStream().close();

        }



These two days I tried to make StrutsJarURLConnection even more

decoupled from container (e.g. weblogic) but could not pass tests so far :(



The issue is, JDK's JarURLConnection expects url of jars in

jar:<url>!/{entry} format but weblogic reports them as zip:C:/... then

JDK is going to convert C:/... to url then sees it does not know any

protocol named c.



So I'm interested to know if "conn.toString" above contains "jar" or not

i.e. does weblogic report them as jars or not.



I also would like to say it seems it's just a warning and does not block

your app functionality; Only "reloading configs runtime when jar

changes" won't work as expected.



Thanks in advance!




Reply via email to