15

enter image description hereI had created a dynamic web project. AS of now it has a jsp file which am trying to run. When I tried to associate the project with a specific runtime(tomcat 6.0), it is not happening.

I right clicked on the project/properties/Targeted Runtimes. It doesn't show any runtimes(I have added tomcat 6.0 in servers). When I click the checkbox 'Show all runtimes', everything comes in disabled mode.

What could be the problem ?

Attached screenshot of the problem.

Update: I even tried to create a new runtime and associate it with the project( project/properties/Targeted Runtimes/new). Even the newly created runtime is getting disabled and am unable to associate it with the project.

Anuj Balan
  • 7,629
  • 23
  • 58
  • 92
  • When you create dynamic webproject, didn't you select runtime? that is first dropdown, isn't it? – kosa Feb 11 '12 at 04:22
  • Why did you create a new question for this ? http://stackoverflow.com/questions/9237751/unable-to-associate-project-with-a-runtime-server And maybe read some documentation? You need to click new there and create a new server runtime in eclipse that's linked to the tomcat you installed. – cotton.m Feb 11 '12 at 04:35
  • Will delete that dont worry cotton.m I had created server runtime. I do know that. Even then its not coming. Any answers to that ? – Anuj Balan Feb 11 '12 at 09:01

4 Answers4

22

To add a project to a runtime you must have a match between your project and your runtime; you have to check:

  • project facet: to run on tomcat it must be a Dynamic Web Project
  • java version: you can't run for example a java 7 project on a java 6 runtime
  • web project version: you can't run a project that doesn't match the Java EE version deployable in the runtime

Once you've validated the match between your project and the runtime, you need the project to target the runtime, as follows:

  1. Open the project in Package Explorer, Project Explorer, or Navigator.
  2. Right-click on the project, and select "Properties".
  3. Click on "Targeted Runtimes" in the properties window.
  4. Select the checkbox of the validated runtime that is to be targeted.
  5. Confirm by clicking "OK".

The new runtime will be associated with that project. If a runtime that you want to select is not displayed or is disabled, you may need to uninstall one or more of the currently installed project facets. This can be done within the same Properties dialogue.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Andrea Colleoni
  • 5,919
  • 3
  • 30
  • 49
  • It worked when I installed new eclipse. Before, I did face problem with runtime set up(JRE7), which I changed n then tried. – Anuj Balan Feb 11 '12 at 09:26
  • LOL i've been trying for hour and hours and I haven't noticed that i was trying to make a static project instead of dynamic web project. so for those who has no got the solution. You should check what kind of proyect you are building. props to @Andrea Colleoni – AXSM Feb 15 '13 at 01:39
9

This is what worked for me. I'm just posting my method because it might help somebody else.

  1. Right-click on project
  2. Click on Properties
  3. Go to Project Facets
  4. Uncheck Dynamic Web Module checkbox
  5. Click on Runtimes in the tabs on the right. Apache Tomcat vX.x should be available now
  6. Check Apache Tomcat vX.x
  7. Click Apply and Close
  8. Repeat the previous steps 1-3
  9. Check Dynamic Web Module checkbox
  10. Apache Tomcat vX.x under Runtimes should still be enabled
  11. Click Apply and Close
1housand
  • 508
  • 7
  • 16
  • Yes. uncheck Dynamic Web Module -> check Tomcat on Runtimes Tab -> check Dynamic Web Module again -> Apply. Problem fixed. – etlds Mar 23 '18 at 15:25
  • 1
    Baniya ka dimag. You are seriously a programmer of the highest level. This is what the world needs – Ajay Oct 04 '18 at 19:26
0

I know it's already answered question, but I like to share my solution with new users if I can help..

For me the problem was because of the Dynamic wen Project version, 3.0 work with java 1.7 ( I was using 3.1) . If it didn't work you can access .settings folder in your project, org.eclipse.wst.common.project.facet.core.xml file and set the version that you need.

<installed facet="jst.web" version="3.0"/>

Hope I can help new users

Chris Sim
  • 4,054
  • 4
  • 29
  • 36
0

I have Found a fix for this problem. Go to Preferences and Check your Targeted runtime, If No Runtime is displayed you can Configure it through Feacts. Select Dinamic Web module to 3.0 or 3.1

You can Also refer to this Video for Detailed Explanation. : https://youtu.be/0W6s0hXbmNE