[ 
https://issues.apache.org/jira/browse/DAEMON-453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17684023#comment-17684023
 ] 

Thomas De Waelheyns edited comment on DAEMON-453 at 2/3/23 9:50 PM:
--------------------------------------------------------------------

Hey all,

 

I have been attempting to make an implementation for this issue. At least for 
windows at the moment. The branch can be found 
[here|https://github.com/thomasdewaelheyns/commons-daemon/tree/DAEMON-453-wilcard-param-java-mode].
 I'm a bit stuck at the moment. Based on the implementation for the jvm mode I 
made one for java. I tried adding supports for quote rapping but haven't 
managed to test it thus far because of a different issue. Namely that the 
method FindFirstFileW always returns the INVALID_HANDLE_VALUE for relative 
paths. Absolute paths with a * wild card at the end seem to work fine. 

 
{noformat}
lstrcatW(szJars, L'.jar');
if ((hFind = FindFirstFileW(szJars, &stGlob)) == INVALID_HANDLE_VALUE) {
        /* Find failed
         */
         apxLogWrite(APXLOG_MARK_ERROR "Find file failed");
        return pStr;
    }{noformat}
In my test setup I have the following:

!image-2023-02-03-21-30-22-322.png!

With some logging libraries inside the lib directory.

For the following classpath

 
{noformat}
--Classpath="ServiceTest.jar;logback.xml;lib\*" ^{noformat}
szJars will be equal to a wide char string 'lib*.jar'. With this input the 
FindFirstFileW does not find anything.

Either I am providing a wrong format or the relative path does not go from the 
location of where prunsrv.exe is but somewhere else.

My knowledge of c++ is very limited and I'm at my wits end on how to further 
debug this issue since for jvm mode, relative paths work as expected.

 
{noformat}
if (GetModuleFileNameW(GetModuleHandle(NULL), mh, SIZ_HUGLEN)) {
        GetLongPathNameW(mh, mh, SIZ_HUGLEN);
        apxLogWrite(APXLOG_MARK_DEBUG "Location: '%S'", apxPoolStrdupW(hPool, 
mh));
    }{noformat}
prints 'C:\...\servicetest\prunsrv.exe' with ... a redacted path which is the 
correct location.

Thanks for any input.

EDIT:

It looks like the relative path starts from C:\Windows\System32 and not from 
where the prunsrv.exe is.

 

EDIT 2:

>From further investigation it looks like the working directory for the prunsrv 
>process is only set in jvm mode. In all other cases, the working directory is 
>only set for the child process that gets created for the application start.

The question is now, do we want to change the working directory of the prunsrv 
process in jvm and exe mode. Or do I adjust my file resolve method to take into 
account this fact. How is it done for the log files? Are relative paths 
supported there?

 


was (Author: JIRAUSER298820):
Hey all,

 

I have been attempting to make an implementation for this issue. At least for 
windows at the moment. The branch can be found 
[here|https://github.com/thomasdewaelheyns/commons-daemon/tree/DAEMON-453-wilcard-param-java-mode].
 I'm a bit stuck at the moment. Based on the implementation for the jvm mode I 
made one for java. I tried adding supports for quote rapping but haven't 
managed to test it thus far because of a different issue. Namely that the 
method FindFirstFileW always returns the INVALID_HANDLE_VALUE for relative 
paths. Absolute paths with a * wild card at the end seem to work fine. 

 
{noformat}
lstrcatW(szJars, L'.jar');
if ((hFind = FindFirstFileW(szJars, &stGlob)) == INVALID_HANDLE_VALUE) {
        /* Find failed
         */
         apxLogWrite(APXLOG_MARK_ERROR "Find file failed");
        return pStr;
    }{noformat}
In my test setup I have the following:

!image-2023-02-03-21-30-22-322.png!

With some logging libraries inside the lib directory.

For the following classpath

 
{noformat}
--Classpath="ServiceTest.jar;logback.xml;lib\*" ^{noformat}
szJars will be equal to a wide char string 'lib*.jar'. With this input the 
FindFirstFileW does not find anything.

Either I am providing a wrong format or the relative path does not go from the 
location of where prunsrv.exe is but somewhere else.

My knowledge of c++ is very limited and I'm at my wits end on how to further 
debug this issue since for jvm mode, relative paths work as expected.

 
{noformat}
if (GetModuleFileNameW(GetModuleHandle(NULL), mh, SIZ_HUGLEN)) {
        GetLongPathNameW(mh, mh, SIZ_HUGLEN);
        apxLogWrite(APXLOG_MARK_DEBUG "Location: '%S'", apxPoolStrdupW(hPool, 
mh));
    }{noformat}
prints 'C:\...\servicetest\prunsrv.exe' with ... a redacted path which is the 
correct location.

Thanks for any input.

EDIT:

It looks like the relative path starts from C:\Windows\System32 and not from 
where the prunsrv.exe is.

 

 

> Add support for wildcard classpath in java mode
> -----------------------------------------------
>
>                 Key: DAEMON-453
>                 URL: https://issues.apache.org/jira/browse/DAEMON-453
>             Project: Commons Daemon
>          Issue Type: Improvement
>          Components: Procrun
>    Affects Versions: 1.3.3
>            Reporter: Thomas De Waelheyns
>            Priority: Minor
>         Attachments: image-2023-02-03-21-30-22-322.png
>
>
> Classpaths with wildcards are currently supported only in jvm mode of the 
> launcher according to this [mail 
> list|https://lists.apache.org/thread/xz3v6p6xcw8hcp0rm1yt9gd7xg9oryvf]. The 
> jvm mode support was implemented in DAEMON-166.
> Since the code to expand the wildcard to actual references to jar files was 
> already written, wouldn't it make sense to expand this to also include java 
> mode?
>  
> Relevant commits:
> Windows: 
> [https://github.com/apache/commons-daemon/commit/6c0758fc052188dead563e4ce776a5da6e34acb9]
> Unix: 
> [https://github.com/apache/commons-daemon/commit/5997b1355ecc2fe0bcf3608e33195e5c2968931e]
>  
> For windows, in javajni.c, line 915-920 looks like a good place to call the 
> __apxEvalClasspath which expands any wildcard paths into a complete list.
> {noformat}
> if (szClassPath) {
>     p = (LPWSTR)apxPoolAlloc(hPool, (lstrlenW(JAVA_CLASSPATH_W) + 
> lstrlenW(szClassPath)) * sizeof(WCHAR));
>     lstrcpyW(p, JAVA_CLASSPATH_W);
>     lstrcatW(p, szClassPath);
>     (*lppArray)[i++] = p;
> }{noformat}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to