Unable to associate project with a runtime server in eclipse IDE - java

I 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.

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:
Open the project in Package Explorer, Project Explorer, or Navigator.
Right-click on the project, and select "Properties".
Click on "Targeted Runtimes" in the properties window.
Select the checkbox of the validated runtime that is to be targeted.
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.

This is what worked for me. I'm just posting my method because it might help somebody else.
Right-click on project
Click on Properties
Go to Project Facets
Uncheck Dynamic Web Module checkbox
Click on Runtimes in the tabs on the right. Apache Tomcat vX.x should be available now
Check Apache Tomcat vX.x
Click Apply and Close
Repeat the previous steps 1-3
Check Dynamic Web Module checkbox
Apache Tomcat vX.x under Runtimes should still be enabled
Click Apply and Close

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

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

Related

Eclipse: Imports not being recognized

I'm using in my Eclipse (Java EE edition) project some classes, like the ServletConfig, for example. If I just add some code with an object of this class without importing it, and click on the error sign (where should appear the import option), it only shows the option to create a class with that name. And if I import it anyway:
import javax.servlet.ServletConfig;
It points an error and shows me the option to create the class 'ServletConfig' in packgae 'javax.servler'. It was working on another computer with Windows 7. The one I'm using is Windows 8.1.
Help!
It sounds as if your project isn't configure as a web project but rather as a plain Java project. Usually, you would do it when you create a project. You'd select File / New / Dynamic Web Project.
If you haven't done so, you should be able the fix the configuration. In the project settings, go to Project Facets and check Dynamic Web Module.
If I'm not mistaken, you'll need to set up a web server runtime environment as well. First go to Eclipse's preferences and select Server / Runtime Environments. If the list is empty, add one.
Then go to the project settings again and make sure there is a targeted runtime selected:
If everything goes ok, the project explorer will show all the web server jars in Java Resources / Libraries / Apache Tomcat v7.0 (or whatever your environment is called). One of the jars is servlet-api.jar and contains the classes you're looking for.

Issue Glassfish 4 doesn't appear glassfish-web

I'm trying to create a descriptor file for my Java web application project.
For this project i am using:
Netbeans 8.0 &
GlassFish 4
When I try to create the glassfish descriptor file. Netbeans shows into the dialog window that is going to create a file called sun-web.xml instead of glassfish-web.xml.
I was looking for this on the internet and found that the first one sun-web.xml is created for version older than 3, and the version 4 should create a file with the name glassfish-web.xml.
I'm following a tutorial where a person is using the same tools that I have. But in the tutorial he can create a glassfish-web.xml file.
Another error raise when I click the finish button with the intention of create the sun-web.xml file and an error popup raise a show me this message:
"Deployment Configuration for this project not found. Deployment descriptor version could not be set properly"
Can't anyone help me please ???
Thank you a lot!!
You should be able to use that sun-web.xml file fine, it might change in a couple of ways like for example when you want to add a security role mapping, NetBeans won't be able to automatically fill in the security role names from your web.xml, but if you fill them in manually and correctly you should be fine.
Actually, I had the same problem, so what I did was erase all versions of Glassfish (I use OSX so I erased the folders from Applications > Netbeans > GlassFish and from Users/MyUser/GlassFish_Server), added a new server in NetBeans Services > Servers > right click add server and follow the wizard, when you get to step 2 (Server location) click download now and that will reinstall glassfish, restart NetBeans and now when you try to create a Glassfish descriptor it should be properly named as glass fish-web.xml
Hope this helps :)
I simply changed version Java EE 7 to Java EE 5 when creating new project at 3rd step Server and Settings and it could create glassfish-web.xml. I'm using same versions of Netbeans and Glasssfish. Hope may this will help you.

Why won't basic spring 4 sample run with Eclipse kepler?

I am using the sample project code here that i've downloaded from the following:
http://javahash.com/spring-4-mvc-hello-world-tutorial-full-example/
Direct link here:
http://javahash.com/wp-content/uploads/2014/02/Spring4MVCHelloWorld.zip
I have Eclipse Kepler SR2 (J2EE), Tomcat 7 64-bit, Java 7.
The project does not appear to be a web project, so I add "Dynamic Web Module" version 3.0 and "Java" (version 1.7) to it. I right click, maven install, which appears to run fine. When I try to actually deploy it on tomcat, it does not give any errors in the console, but when the browser window pops up it shows a 404
http://localhost:8080/Spring4MVCHelloWorld/
HTTP Status 404 - /Spring4MVCHelloWorld/
--------------------------------------------------------------------------------
type Status report
message /Spring4MVCHelloWorld/
description The requested resource is not available.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.39
That said, how do I get this "basic" example running in eclipse? Anyone able to get this working successfully? It feels like it should be more trivial than the 5 hours I've spent on trying to get this sample code working to no avail.
UPDATE:
Still continues to fail despite using Tomcat 7.0 server.
Download the sample, extract contents to workspace directory.
"Import Existing Project" in Eclipse
Since there is no "Run On Server" option, I right click on the imported project directory and hit "Properties".
I go to "Project Facets" and check 2 things: "Dynamic Web Module" (3.0) and "Java" (1.7) and hit apply then "Ok".
I right click on the project Spring4MVCHelloWorld and click "Maven"->"Update Project". Then I click "Run On Server".
There are no errors in the console, but the web browser that pops up in eclipse shows a HTTP STATUS 404.
I tried going to:
http://localhost:8080/Spring4MVCHelloWord/hello
and the same:
HTTP Status 404 - /Spring4MVCHelloWorld/hello
shows up, but the tomcat shows up as:
Apache Tomcat/7.0.53
Note that this is the 64-bit version. What steps am I missing? How do I get around this silent failing?
Apart from what Dimitri stated, your log seems to indicate that you are using
Apache Tomcat/6.0.39
That version of Tomcat does not support ServletContainerInitializer which your Spring web application depends on for configuration. Upgrade to a Tomcat version 7+.
It seems like the Maven update doesn't work for you (or for me).
First, go into Properties -> Deployment Assembly. You need to get rid of Web Content if it's there and add src/main/webapp (which is a maven convention). You also need to add the Maven Dependencies as shown below.
Finally, and this might not be necessary, delete the web.xml provided to you and re-create it by selecting and right clicking Deployment Descriptor in the Project Explorer and clicking Generate Deployment Descriptor Stub.
Also, make sure your Java Build Path in the Properties has a Java 7+ version of the JRE.
As far as I can see your controller only maps to /hello, which means your URL should be:
http://localhost:8080/Spring4MVCHelloWorld/hello
Another thing that might be interesting to you is that if your having problems with certain project facets (like Dynamic Web Module) not being recognized, you can usually fix them by righ clicking your project, opening the Maven menu and choosing Update Project.

Eclipse Debug: Source Not Found while remote debugging

In my Java eclipse project, while I am remote debugging, eclipse does not step into the class files of imported library files even though the source file jars are properly mapped to the library files.
Instead it gives me a "Source Not Found" error. But when I am editing the same class in eclipse, I can control-click a class or method name and it takes me to the correct library class file.
Can anyone please tell me what I am doing wrong?
I am using Tomcat 6 and latest Eclipse Java EE.
In this scenario just follow the following steps:
Go to Run → Debug Configurations
Select the remote application configuration being debugged.
Select the second tab named 'Source'
Now add the folder/projects containing the source code explicitly here.
In the Java build path for the project, under the sources tab, check if your class path is under the included list. If its under the excluded list, remove it from there.
As Saury said, get your debug configuration right. When remote debugging, often developers have selected the wrong project while creating a new configuration. Verify you select the project you wish to debug and it corresponds to the version of the deployed WAR/EAR/JAR in the appliation container.
I faced same issue and got solved by below steps in eclipse.
Go to Severs tab in your Eclipse tab
Right click on the server and click on Add and Remove Projects
Select/add the project EAR which you want to debug
After finish - Start your server in debug mode
Should solve with above steps as it resolved for me:)
I ran into a similar problem. It turns out I was missing the devel package on CentOS.
In my particular case, the following yum statement solved the problem.
yum install java-1.7.0-openjdk-devel
Follow the next steps in case you use a parent project connected to sub-project/s:
Use the 'Debug Cofigurations' source tab or the 'Edit Source LookUp path' option to attach the sources of the running code.
Note: you'll need to attach the src folder of your inner project rather than the target in order to make it work (check the screenshot below).
E.g.
An update for eclipse Oxygen (Feb 2018):
Attaching the Java projects (sub projects) also worked well; e.g:
Check under "Debug Configurations" -> "Remote Java Application" -> Tab "Connect" -> "Project" that you chose the correct project.
Here is how it worked for me. Did this on Eclipse oxygen
Go to debug configurations and then the source tab
Click on Add
Select Java Library. Hit ok
The select Web app libraries and click next
In the next screen select the project/application that you are
debugging.
Click Finish
This worked for me like a charm
Using Eclipse version Oxygen.2 (2017), the accepted answer did not work for me. The following procedure was successful.
Launch the application to debug with the Xdebug and Xrunjdwp switches.
cd "C:\Program Files\Test_742\Test 7.4"
test_app.exe -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8500
Create a new workspace in Eclipse.
Create a new Java project using File -> New -> Java Project.
Copy the source code of the Jar to debug to the src folder of the new project. I found it necessary to ensure that I copied the complete folder hierarchy of the source code to my source folder.
For me that meant copying \com\test... to my src folder.
This puts all the source code in the build path.
Copy any dependency JARs to the project. I created a new folder named myJARs.
Refresh Package Explorer to see the new myJARs folder.
Add the dependency JARs to the build path by opening File -> Properties -> Java Build Path -> Libraries (tab), and click Add JARs...
Add each dependency JAR to the list, then click Apply and Close. This adds the JARs to Referenced Libraries.
Configure a debug session. Click Run -> Debug Configurations -> Remote Java Application. I set Connection Type = Standard.
Configure Host to point to the machine running the JAR and Port to the port specified in the address portion of the command line switches (8500 in my example).
Notice that on the Source tab, both the source files and the dependency JARs are present.
Click Apply, then Debug.
View the debugging perspective by clicking Window -> Perspective -> Open Perspective -> Debug.
Place breakpoints in the source code.

Add Jars to User LIbraries in Eclipse Helios, Mac OSX

I've created a new Java project (testProject) and begin to add jars to a user library, but I'm getting project errors after adding jars to a "User Library"
Here's what I'm doing:Create the User Library
Right mouse click the project and click Properties
Click Add Library..., select User Library, and click Next
Click button, User Libraries...
Click New... and give it a name: mule; click OK.
Select mule and click Add JARs...
Add a jar (e.g. I've added two, one from the root project, log4j.jar, and another from /opt/mule/lib)
Click OK
Click Finish
Now I'm seeing a red x show on the mule library.
1. Click Edit, and click User Libraries
2. The message on each jar says the library is missing, and it seems to be losing the actual path.
See attached image:
I'm running On a Mac OSX 10.5.8, running Java
openjdk version "1.6.0-internal"
OpenJDK Runtime Environment (build 1.6.0-internal-landonf_17_may_2009_13_58-b00)
OpenJDK Client VM (build 11.0-b17, mixed mode)
This doesn't seem to be a problem on a Vista PC, running Eclipse on Java 1.6.0_16. (Or under Ubuntu).
Is anyone else seeing this?
I have had a similar problem in Eclipse Indigo SR2 on a Windows XP workstation. It ran perfectly for a long time until it broke and displayed the behavior that the OP has observed.
I have found out more what causes the problem and have found a workaround.
The problem is caused when I choose Preferences -> Java -> Build Path -> User Libraries | Add JARS... and add a new jar file. What happens is that although the user library is given an absolute path (C:\Documents and Settings\a23456\box_corefx\1box-corefx\box-build\target\deployment\weblogic\APP-INF\lib\antlr-2.7.6.jar) it only stores a relative path (\1box-corefx\box-build\target\deployment\weblogic\APP-INF\lib\antlr-2.7.6.jar). This relative path is what makes it say "missing."
The workaround is to export a good user library and massage the jars so that it has entries like:
<archive path="C:/Documents and Settings/a23456/box_corefx/1box-corefx/box-build/target/deployment/weblogic/APP-INF/lib/antlr-2.7.6.jar"/>
Then import the new user library.
There have been a number of problems reported by people trying to run Eclipse on Open JDK. Plus it looks like you are using some sort of pre-production build of it. The first thing I'd do is to try running Eclipse with JDK that comes with Mac OSX.

Categories

Resources