Bug 103046 - Can't Profile Tomcat-targeted applications
Can't Profile Tomcat-targeted applications
Status: VERIFIED FIXED
Product: profiler
Classification: Unclassified
Component: Base
6.x
All Mac OS X
: P2 (vote)
: 6.x
Assigned To: issues@profiler
issues@profiler
it071030
: SPACE_IN_PATH
: 110882 114124 117150 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-05-01 14:05 UTC by Alexander Kouznetsov
Modified: 2007-11-12 13:29 UTC (History)
9 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kouznetsov 2007-05-01 14:05:46 UTC
Profiler 070427
NetBeans IDE 6.0 Preview (M9, build 070430)
1.5.0_06; Java HotSpot(TM) Client VM 1.5.0_06-68
Mac OS X version 10.4.7 running on i386
ru_RU (nb); MacCyrillic

Steps to reproduce:
- install NB using default installation directories
- unzip Apache Tomcat 5.5.23 and make it executable
- register it in IDE
- verify that NB is able to run projects targeted Tomcat
- try to Profile Application targeted Tomcat
- RESULT: Server is failed to start:
Error occurred during initialization of VM
Could not find agent library in absolute path: /Applications/NetBeans
Comment 1 Tomas Hurka 2007-06-11 15:32:42 UTC
The situation is on any Unix platform, when netbeans is installed in directory with space. 
Comment 2 Tomas Hurka 2007-06-11 15:52:21 UTC
According to my investigation, profiler correctly pass the jvm arguments to nbstartprofiledserver task.
Unfortunately org.netbeans.modules.tomcat5.ide.StartTomcat.StartRunnable adds all jvm args together 
without doing any quoting. Reassigning to tomcatint for evaluation.  
Comment 3 Sherold Dev 2007-08-01 18:06:10 UTC
It does not seem to me that the bug is in the Tomcat plugin. The right place to do the quoting is most likely the
profiler. Tomcat plugin does not know anything about the -agentpath:.. argument and how it is supposed to be quoted. See
also the following issue: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6276819.
Comment 4 Tomas Hurka 2007-08-02 09:11:49 UTC
As I said, it looks to me like bug in tomcat plug-in. Look at the following code:

        String[] profJvmArgs = profilerSettings.getJvmArgs();
        // TODO solve conflicts between profiler and tomcat vm args
        StringBuffer catalinaOpts = new StringBuffer();
        for (int i = 0; i < profJvmArgs.length; i++) {
           catalinaOpts.append(profJvmArgs[i]).append(" "); // NOI18N
        }

Profiler provides _array_ of jvm arguments, which should be added to other jvm options. It is wrong to concat them with space without any test that the 
profJvmArgs[i] does not contain space. This is very similar situation how ant handle command-line arguments (http://ant.apache.org/manual/
using.html#arg) or unix execv(2) handles it. User of the API provides _list_ of arguments (which can contain spaces) and the implementation of the API is 
responsible to correctly pass arguments to newly started process. BTW: It has nothing to do with  -agentpath:.. argument and http://bugs.sun.com/
bugdatabase/view_bug.do?bug_id=6276819
Comment 5 Sherold Dev 2007-08-07 12:39:11 UTC
At this point I do not really know how to fix this issue. Escaping the spaces does not seem to be easy, especially since
we cannot modify the catalina.sh startup script. I talked to Tomas and the profiler team will try to fix the issue some
other way.

Closing the issue as WONTFIX.
Comment 6 Tomas Hurka 2007-08-29 15:27:05 UTC
*** Issue 114124 has been marked as a duplicate of this issue. ***
Comment 7 Alexander Kouznetsov 2007-10-18 13:28:09 UTC
Reassigning back to profiler to let "profiler team try to fix the issue some
other way" according to last comments.
Comment 8 Alexander Kouznetsov 2007-10-18 13:28:47 UTC
*** Issue 117150 has been marked as a duplicate of this issue. ***
Comment 9 Alexander Kouznetsov 2007-10-18 13:59:53 UTC
There is a problem also that NetBeans installer on Mac doesn't allow to specify the installation directory.
Comment 10 J Bachorik 2007-10-19 08:25:29 UTC
The last comment is directed more towards the installer component than the profiler, i dare say  - see issue #115779
The problem is that we can't pass to tomcat any argument containing space - such an argument would be split by spaces,
effectively destroying any information in the original argument.
A solution could be to notify the user about this problem and let her change the location of the profiler files to the
one without spaces. However, this would involve more changes in the profiler UI and at this stage of release cycle it
doesn't seem to be feasible. Should be targeted in the next release.
The easiest workaround would be not to a path with spaces as a default NB IDE installation location. Passing to
installer for evaluation
Comment 11 dlipin 2007-10-19 10:47:39 UTC
Why just not quote the argument on windows and escape spaces ( " "->"\ " or " "->"\\ ") on unix when creating 
catalinaOpts?

If Tomcat itself does work bad with spaces (not the NetBeans plugin) then the issue should be filed against tomcat 
server. 

Imagine that the user uses the netbeans zip and extract it somewhere in the path with spaces - it will get the same 
issue without useg the installer. Not the installer problem, really.


Comment 12 Petr Hejl 2007-10-22 16:04:55 UTC
We are not passing any arguments. Most of the servers (including tomcat) accepts the environment variables. Such
variables are hard to escape in any way because there is no shell expansion performed.

I think this is impossible to escape, partly due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6276819.
Comment 13 Alexander Kouznetsov 2007-10-26 13:13:43 UTC
One more idea. We can create symbolic link to NetBeans directory and use it instead of full path. It could be placed in
.nbprofiler or .netbeans folder. I checked that this approach works very well with profiling.
Comment 14 Petr Hejl 2007-10-27 20:46:49 UTC
Little summary.

Other possibilities follows (aside the previous one - I'm not sure about java support for symbolic link) - as sent to
Jaroslav Bachorik. I prefer the first and the second option.

1) silently copy profiler required stuff to some directory without
spaces (temp for example) and use it from this temporary directory
2) display warning about the space in the path - done in profiler code
(and probably dialog warning when starting the server in profile mode by
hand)
3) display warning in nbstartprofiledserver (console, unfortunately) and
dialog warning when starting the server in profile mode by hand
4) waive, won'tfix
Comment 15 Tomas Hurka 2007-10-31 13:32:28 UTC
*** Issue 110882 has been marked as a duplicate of this issue. ***
Comment 16 Tomas Hurka 2007-11-02 16:14:07 UTC
Workaround on profler side committed to trunk.   
Checking in IntegrationUtils.java;
/cvs/profiler/libs/common/src/org/netbeans/lib/profiler/common/integration/IntegrationUtils.java,v  <-- 
IntegrationUtils.java
new revision: 1.2; previous revision: 1.1
done

It is really ugly workaround. It uses Runtime.exec, it uses ugly name created by File.createTempFile(). Hopefully only
one such link is created for every profiler session. If NetBeans is terminated abruptly, those links will not be
deleted. I am not sure if there will be any problems caused by the fact that the path for profiler agent is not under
netbeans installation directory. I think that this workaround should be used as backup solution if the user explicitly
installs NetBeans in the directory with the space(s). Default installation should have no spaces, since this
configuration is very well tested. Reassigning to installer. If possible please change default name on Mac OS X to be
one without spaces.
Comment 17 William Leonard 2007-11-02 17:09:16 UTC
+1. Having spaces in the install path causes headaches for more then just the profiler.
Comment 18 Alexei Mokeev 2007-11-03 19:29:59 UTC
So you are requesting a change of default installtion directory. I have filed a separate issue for that 
http://www.netbeans.org/issues/show_bug.cgi?id=121067. We have to evaluate. 
Comment 19 arseniy 2007-11-04 09:33:53 UTC
closing this one as fixed, as there is a workaround in the profiler and a separate issue filed for the installer
Comment 20 Alexander Kouznetsov 2007-11-07 12:01:09 UTC
Verified with
Product Version: NetBeans IDE Dev (Build 200711060000)
Java: 1.5.0_07; Java HotSpot(TM) Client VM 1.5.0_07-87
System: Mac OS X version 10.4.10 running on i386; MacCyrillic; ru_RU (nb)
Comment 21 Jiri Sedlacek 2007-11-12 13:29:02 UTC
Removing RELNOTE keyword, fixed.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo