Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337703

Summary: Run->Run asks for "Run on server" for simple java projects
Product: [WebTools] WTP ServerTools Reporter: arne anka <eclipse-bugs>
Component: wst.serverAssignee: wst.server <wst.server-inbox>
Status: CLOSED WONTFIX QA Contact: Angel Vera <arvera>
Severity: normal    
Priority: P3 CC: eclipse.dserodio, markus.kell.r, Michael_Rennie, tor.norbye
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description arne anka CLA 2011-02-21 05:32:21 EST
Build Identifier: 20100917-0705

i got a little plain java project with a main method.
hitting Run->Run does not simply run my project, but pops open a dialog asking to
"Run on Server" or "Java Application".
the project has no connections to a server whatsoever, hence i completely fail to understand why such an entry appears.
after hitting "ok" for "Run on Server" quite rightly a message pops up, saying
"The selection did not contain any resources that can run on a server"
or something to that effect (as usual it is impossible to simply copy the message, after many years of using eclipse i still do not understand what harebrained rationale is behind that).
it should be easy for eclipse to recognizes that beforehand.

i have WST installed, not sure if WST simply grabs everithing it can get or if JDT/Platform simply puts everything into the list that is capable to do something ...


Reproducible: Always

Steps to Reproduce:
1. create a plain java project with a main method
2. hit Run->Run (or the matching shortcut)
3. watch a meaningless question dialog pop up
Comment 1 Markus Keller CLA 2011-02-21 07:02:19 EST
WST team, please have a look at your contribution to the org.eclipse.debug.ui.launchShortcuts extension point.

org.eclipse.jdt.junit is in a similar situation, and we solved it using the following enablement expression:

         <contextualLaunch>
            <enablement>
               <with variable="selection">
                  <count value="1"/>
               	  <iterate>
                     <adapt type="org.eclipse.jdt.core.IJavaElement">
		                <test property="org.eclipse.jdt.core.isInJavaProject"/>
		                <test property="org.eclipse.jdt.core.hasTypeOnClasspath" value="junit.framework.Test"/>
		                <test property="org.eclipse.jdt.junit.canLaunchAsJUnit" forcePluginActivation="true"/>
		             </adapt>
		          </iterate>
               </with>
            </enablement>
         </contextualLaunch>

The custom property "canLaunchAsJUnit" forces plug-in activation, that's why we only test it at the end.
Comment 2 Michael Rennie CLA 2011-04-25 14:18:27 EDT
I opened bug 34351 with an alternate approach to preventing the launch shortcut appearing everywhere. You could use the newly available variable from platform debug from bug 338576:

<enablement>
  <with variable="selection">
    <count value="1"/>
      <iterate>
        <and>
          <test property="org.eclipse.wst.server.ui.isRunnable" value="true"/>
          <with variable="org.eclipse.core.runtime.Platform">
             <test
                args="org.eclipse.wst.server.ui"
                property="org.eclipse.core.runtime.bundleState"
                value="ACTIVE">
              </test>
           </with>
        </and>
      </iterate>
  </with>
</enablement>
Comment 3 Michael Rennie CLA 2011-04-25 14:19:30 EDT
I meant bug 343751
Comment 4 Daniel Serodio CLA 2012-09-21 10:41:21 EDT
Bug 343751 talks about pretty much the same problem