How to setup tomcat with intelliJ? - eclipse

I used to use eclipse for my java project till now. In that I used to give a server.xml corresponding to a tomcat server. But in IntelliJ I can't find where should I give that server.xml. Can anyone help me out?

You can find this file in Directories Used by IntelliJ IDEA to Store Settings, Caches, Plugins and Logs.
For my computer, I am using window 10, I found that in following path:
C:\Users\<USER ACCOUNT NAME>\.IntelliJIdea15\system\tomcat\<project name>\conf\server.xml

In intellij, you should click on Run > Edit configurations... > Add new configuration (clicking on "+" icon) > Tomcat (select local or remote) and complete the configuration using your settings.
I hope this can help you.
Thanks

Goto File, then New Project.
Create from Scratch.
Click Next, give the Project a Name, and keep Clicking Next until the Desired Technologies window comes.
Click Web-Application, then Finish.
Click File, then Settings.
Click on Application Servers and Hit the + to add a new Tomcat Server.
Set the Home Directory of the application server you have just installed(ex: c:/Program Files/Apache Software Foundation// and then Click ok.
Click on the run button, and then then Edit Defaults.
Click on the + in the top left hand corner and add a Tomcat Server, then Local configuration.
Select the Tomcat in the pulldown menu next to Application Server.
I hope this will help you.

Related

Running JBoss Server from eclipse [Adempiere project]

For testing the webui of adempiere, I need to build the code and deploy it every time with all change. Its much time consuming. The remote debugging is quite useful. But the build, setup and server running time remains the same.
Can we run the JBoss server through eclipse ? Hence can we write the code and test it on debug mode?
You Can run the jboss server in eclipse and deploy adempiere projects in jboss also
Download the jboss4.2.3 and place into your desire location in your drive.
Extract the jboss zip file (let say /home/Giri/Server/jboss4.2.3GA/....)
Open your eclipse IDE, and open the server pane
Click on the Window And choose Show View
It will open a popup and select the server (By writing the help text you will get)
Right click on the server editor, New---->Server
It will open the a new server pop-up
Select the jboss and select the jboss version as the 4.2
Click on the Next button
Here you need to select the your jboss server path (as previously i mentioned /home/Giri/Server/jboss4.2.3GA/ )
Click on the Next (no need to change the ports)---> Finish
Don't bother about the project Add And Remove Project
Now in server editor you will get a jboss server details in single line
Now double click on the server, or Right click on the jboss server And select the Open
It will open server details page
Now update the following settings
In Publishing :- Select Never select auotmatically
In Time Out :- Set start time as 5000
Save(CTRL+S) the settings and close the settings
Click on the Open launch configuration
It will open the a pop-up
Now Navigate into classpath tab, And select the User Entries and add the following mentioned jars by clicking on the Add Jars button at right side
trunk\tools\lib*.jars (Except cglib.jar, log4j.jar, jnlp.jar, javaee.jar)
trunk\japserreportstool\lib*.jars (Except jfreechart***.jar)
and add the javaw.jar from the jre library (by using Add external jars)
If you want to configure the properties files then add the properties files details into Arguments tab
Save it and close it
Right click on the server and Click on the Add And Remove Select available installers and add to right side tab, and click on Finish.
Run click on jboss and publish after that start it....
Hope your server will start properly .....

how to setup JDBC in Eclipse?

I have eclipse and j developer,I am more comfortable with eclipse.I want to know how to setup the JDBC driver in eclipse,I downloaded a driver from oracle.com but it does not appear anywhere when I browse after clicking 'external jars' in 'java build path' in "libraries" tab. My database is Oracle express edition.
Are there any good pdf's or tutorials for java application development?I want to make a front end application where I enter data into fields and it inserts into DB,and make it such that we can also retrieve information when we enter for example an ID.
What are the materials required for this?I don't want to learn too deep but I want to learn in the process(this is not a project just something I wanna achieve this month) so I am guessing i need
1. a book on awt,swing classes
2. I need to set this JDBC thing I don't understand how to get it up and running in eclipse,i type code it gives me error.
3.a book on how to connect java to oracle express edition DB.
I have JDK 1.7.0.0.3
Thanks in advance(i'm a beginner ;))
If you're wanting to include a JAR file to your Eclipse project, you would generally create a 'lib' folder inside the project folder, and put the file in there. You then need to tell eclipse to include it in your class path so your code will compile and run inside eclipse.
To do that:
- Go into the properties of your project
- Select 'Java Build Path' in the left hand column
- Select the 'Libraries' tab in the centre part of the window
- Click the Add JARs button - this will give you a list of your projects in eclipse - expand your project and into the lib folder - your jar will be there.
- Select the JAR, click OK, and OK again out of the properties window.
Or, you can just right-click the jar and click BuildPath->Add to Build Path.
Select the option of Add External Jar from the Build path and then browse to the location where the Jar is downloaded, select it and add it.
If you are not able to find the Jar while browsing through build path, check the location in windows explorer and confirm that it is where you are searching for it.
You asked how to "set up jdbc in eclipse". Here is my take on your question. If this isn't the answer to your question maybe it will help someone else.
Also - I'm using kepler eclipse. (really jboss dev studio version based on kepler)
First set up the driver.
Preferences -> Connectivity -> Driver Definitions
Click Add... and follow the prompts. You will be able to test the connection at this point. Eclipse makes it obvious how! (Click the Test connection button)
Close the Preferences window. In the main window
Window -> Show View... -> Data Source Explorer
Right click on Database Connections. Select New... and follow the prompts.
You'll be able to open the connection and browse your database.
As far as JPA-enabling your application, there may be a way to have eclipse set that up (ie right click on your project and maybe there is something in the context menu). It would set up a persistence.xml file in the right place and maybe other things. I don't know off the top of my head.
Hope this helps.
add a classnotfound exception. like this:
try {
Class.forName("com.mysql.jdbc.Driver");//the class driver
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

HTTP Status 404 - The requested resource (/) is not available

I integrated Tomcat 7 in Eclipse. When I start it using Eclipse, it shows that Tomcat is up and running, but when I go to http://localhost:8080 in my browser, it gives me following error:
HTTP Status 404 - /
type Status report
message /
description The requested resource (/) is not available.
Apache Tomcat/7.0.23
I tried changing the port in server.xml just in case if 8080 is used by another service, but it didn't work either. How can I solve it?
What are you expecting? The default Tomcat homepage? If so, you'll need to configure Eclipse to take control over from Tomcat.
Doubleclick the Tomcat server entry in the Servers tab, you'll get the server configuration. At the left column, under Server Locations, select Use Tomcat installation (note, when it is grayed out, read the section leading text! ;) ). This way Eclipse will take full control over Tomcat, this way you'll also be able to access the default Tomcat homepage with the Tomcat Manager when running from inside Eclipse. I only don't see how that's useful while developing using Eclipse.
The port number is not the problem. You would otherwise have gotten an exception in Tomcat's startup log and the browser would show a browser-specific "Connection timed out" error page (and thus not a Tomcat-specific error page which would impossibly be served when Tomcat was not up and running!)
Following steps helped me solve the issue.
In the eclipse right click on server and click on properties.
If Location is set workspace/metadata click on switch location and
so that it refers to /servers/tomcatv7server at localhost.server
Save and close
Next double click on server
Under server locations mostly it would be selected as
use workspace metadata Instead, select use tomcat installation
Save changes
Restart server and verify localhost:8080 works.
Copy the ROOT (Default) Web App into Eclipse.
Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace.
Go to C:\apache-tomcat-7.0.27\webapps, R-click on the ROOT folder and copy it.
Then go to your Eclipse workspace, go to the .metadata folder, and search for "wtpwebapps". You should find something like your-eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps (or .../tmp1/wtpwebapps if you already had another server registered in Eclipse).
Go to the wtpwebapps folder, right-click, and paste ROOT (say "yes" if asked if you want to merge/replace folders/files).
Then reload localhost:8080 to see the Tomcat welcome page.
I did what BalusC said but it was not enough for me, I had to clean the Tomcat workdirectory : ( Click right on right on Tomcat in the Servers Tab -> Clean Tomcat Work Directory )
Please check in your server specification again, if you have changed your port number to something else.
And change the port number in your link whatever new port number it is.
Also check whether your server is running properly before you try accessing your localhost.
If you are new in JSP/Tomcat don't modify tomcat's xml files.
I assume you have already deployed web application. But to be sure, try these steps:
- right click on your web application
- select Run As / Run on Server, choose your Tomcat 7
These steps will deploy and run in the browser your application. Another idea to check if your Tomcat works correctly is to find path where tomcat exists (in eclipse plugin), and copy some working WAR file to webapps (not to wtpwebapps), and then try to run the app.
If options under Server Locations are grayed out, note the message in the section title: "Server must be published with no modules present". To publish the server, right click the name of the server in the Server window and select "Publish".
Sometimes cleaning the server works. It worked for me many times.This is only applicable if the program worked earlier but suddenly it stops working.
Steps:
" Right click on Tomcat Server -> Clean. Then restart the server."
I had the same problem with my localhost project using Eclipse Luna, Maven and Tomcat - the Tomcat homepage would appear fine, however my project would get the 404 error.
After trying many suggested solutions (updating spring .jar file, changing properties of the Tomcat server, add/remove project, change JRE from 1.6 to 7 etc) which did not fix the issue, what worked for me was to just Refresh my project. It seems Eclipse does not automatically refresh the project after a (Maven) build. In Eclipse 3.3.1 there was a 'Refresh Automatically' option under Preferences > General > Workspace however that option doesn't look to be in Luna.
Maven clean-install on the project.
** Right-click the project and select 'Refresh'. **
Right-click the Eclipse Tomcat server and select 'Clean'.
Right-click > Publish and then start the Tomcat server.
In my case, I've had to click on my project, then go to File > Properties > *servlet name* and click Restart servlet.
For me, my Eclipse installation was hosed - I think because I'd installed struts. After trying a dozen remedies for this error, I re-installed Eclipse, made a new workspace and it was OK. Using Kepler-64-Windows, Tomcat 7, Windows 7.
This worked for me:
Project > Build Automatically (Make sure it's turned on)
Project > Clean ...
Right click Tomcat > Properties > General Tab > Switch Location (switch from workspace metadata to Server at localhost.server)
Restart Eclipse
Run Project As Server
Apache Tomcat/7.0.23 service is not loaded or enabled. Pls check the service status and other app which is using 8080 port currently. To check this use netstat command and observe whether another app is occupying the port 8080!

Connecting Tomcat server to Eclipse

I am trying to use Tomcat 6.0 as a web development server within SpringSource Tool Suite 2.7.1. I create a runtime, download tomcat, create a server, etc as per these instructions http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html#N10148
When I try to run a web app on the server though I get the following error:
The archive: /Servers/Tomcat/bin/bootstrap.jar which is referenced
by the classpath, does not exist.
I know this bootstrap.jar file does exist in the exact place it says it should be yet it still causes an error. Any ideas?
You might want to check/manually edit your path by going into server properities:
In Servers view,
1) double-click on Tomcat server.
2) Then click on Overview of Tomcat settings appears.
3) "Open launch configuration" then Classpath
4) Edit User Entries here
The trick here was that the location of the jar was inside the Eclipse/STS project directory. STS stores its server configurations inside the /Servers folder and I had decided to store the tomcat runtimes here as well for neatness. Placing the runtimes elsewhere and trying again solves this issue.
None of the above answers provide proper concrete solution.
I faced exactly same issue and i figured out a very simple solution.
Open Eclipse and remove all entries of Apache server
Delete Servers from explorer tab, delete Tomcat from server explorer window, delete server from Window > Preferences > Server > Apache tomcat, delete it, also delete servers folder inside EclipseProjects.
Place Apache tomcat folder outside the project folder anywhere you wish to, you can place in Eclipse_Projects folder but not inside EclipseProjects/projectxyz/.
Now add server in eclipse the usual way and give path of this new location.
This should work!
I had similar issue. This is what worked for me:
When the path begins with slash like: "/Servers/Tomcat/bin/bootstrap.jar" it means that the local project is refered. In the picture - I had 'pivotal-tc-server-developer-3.2.8.RELEASE' as the name of the project.
Open the project ('Servers' in your case or 'pivotal-tc-server-developer-3.2.8.RELEASE') so it is accessible to Eclipse.
The jar should be now visible.
Alternatively go into Run Configurations; delete jars, and add it as an external jar.
Or you may delete the servers configuration, and configure the server again. This works when you may have changed the directory of the server.
I googled my way here on the search terms, "the specified tomcat directory does not exist". (I had moved it from one directory to another.)
For others here for that reason, my solution was to go into Window -> Preferences -> Server -> Runtime Environments and update it there. Then to update the JARs, as in Marcin Wasiluk's answer.
I was also facing same issue and solved it as follows :
My conclusions :
1) In my case issue was coming as I shifted the location of the Tomcat.
Solution :
2) double clicked on the server configured in the eclipse.
3) Click on Open Launch configuration.
4) Change the classpath under classpath tab to the new location.
Hope this would help.
I have faced the same problem.
Solution: In Project Explorer--> Servers(right click) --> Run As --> Run Configurations(click) --> (Select "Tomcat v7.0 Server at localhost") --> Arguments(tab) --> Working directory(bottom of window) --> others : (click workspace) --> select the "boostraps.jar" from -->Server.
Eg., My workspace.MY path is:
Project Explorer --> Servers(right click) --> Run As --> Run Configurations(click) --> (Select "Tomcat v7.0 Server at localhost") --> Arguments(tab) --> Working directory(bottom of window) --> others : (click workspace) --> /home/ciprus//Servers --> click apply.
this could happen if you probably used previous tomcat server in eclipse, so deleting server and its configuration and creating another one will make it work .
You can try as below steps:
Open Window -> Preferences -> Server -> Runtime Environments
Click add button, choose the what's kind of server you use.
Click next button, give a name to your runtime server and the path of tomcat.
New a new server with the new created runtime server
same problem in my case also i solved::
just remove your older tomacat server and add tomcat 8.0 version only
If you have unzipped downloaded Tomcat archive into Eclipse Servers folder, User Entries in classpath have relative path (e.g. /Servers/....) of bootstrap.jar and tomcat-juli.jar which path I guess is not accessible as a relative path.
Once I removed Tomcat installation directory (with files) outside Eclipse's Servers folder, delete the old configuration and re-add Tomcat, everything worked as expected.
I hope this helps narrow down the cause.

Server configuration is missing in Eclipse

Im using Eclipse Galileo, and have configured it for Apache Tomcat . I have added Apache Tomcat 6.0 to Windows->Server->Runtime Environments, with the following settings:
Tomcat Installation Directory - C:\apache-tomcat-6.0.24\apache-tomcat-6.0.24
JRE - Workbench Default JRE (This points to C:\Program Files\Java\jre6)
Now, I create a Dynamic Web Project, and add a JSP file to it. But, when I run the project I get the following error:
The Tomcat server configuration at \Servers\Tomcat v6.0 Server at localhost-config is missing. Check the server for errors.
Any way to fix this?
Probably, you have some problems with your server's configuration.
Follow these steps to remove and create a new one, it might help you.
In Eclipse
1. Window -> Show view -> Servers (If you cannot see it, you might need to choose Others -> Server)
2. From Server view -> Delete the server which has problems.
3. Right click -> New -> Server : to create a new one
In my case, after new server was created, I get rid of this "localhost-config is missing"
I faced the same problem once. THe reason for this is that even though the server is available, the config files are missing. You can see the server at Windows -> Show view -> Servers. Their configuration files can be seen at Project Explorer -> Servers. For some reason this second mentioned config files were missing.
I simply deleted the existing server and created a new one with this the config files were also created and the problem was solved!
Similar solution is given at here by Emertana EM
java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
In Eclipse Neo
1. Window -> Show view -> Servers
2. Right click on server -> choose Properties
3. From General Tab -> Switch Location
As Yoni already mentioned, you probably deleted the project named "Servers" from your Project Explorer. If config files for the server still present on a file system, the quickest way to restore it will be Right Click in Project Explorer->Import->General->Existing Projects into Workspace, then select the root dir where Servers dir located, set checkbox near "Servers" and finally click Finish. If everything works as expected, you should see the 'Servers' project added to the Project Explorer view and your old config files will be there. Finally, save the tomcat configuration which you had open. You can startup your Tomcat server without errors now.
From project explorer ,just make sure that Servers is not closed
You need to define the server instance in the Servers view.
In the box at the right bottom, press the Servers tab and add the server there. You by the way don't necessarily need to add it through global IDE preferences. It will be automagically added when you define it in Servers view. The preference you've modified just defines default locations, not the whole server instance itself. If you for instance upgrade/move the server, you can change the physical location there.
Once defining the server in the Servers view, you need to add the newly created server instance to the project through its Server and Targeted runtime preference.
If you're not too attached to your current workspace you can create a new workspace, follow BalusC's steps for server creation, and recreate your project in the new workspace.
I got the same error after installing Eclipse Java EE IDE for Web Developers(Juno) but using the workspace of a much older Eclipse installation. When I created a new workspace I was able to get my Tomcat server running without this error.
Did you, by any chance, deleted stuff from your workspace, or moved it around?
When you create a server for the first time, either globally or through the project's "run on server" settings, Eclipse creates a project in the Servers view, as BalusC pointed out. Eclipse stores this server inside your workspace, in a project called Servers. The project needs to be open for tomcat to run.
(If you want, you can store the server settings elsewher. You can right click and open the server instance from the Servers view and configure various parameters and locations)
This happens when Eclipse shuts down incorrectly - delete the server and then re-create it again.
Remove the server from IDE and install again to it.
In my case, the server list was empty for Apache in "Run Configurations" when I opened
Run > Run Configurations
I fixed this by creating a server in the Servers Panel as in other answers:
Window -> Show view -> Servers
Right click -> New -> Server : to create a new one
this worked for me
In the Server's tab in Eclipse, Stop the Tomcat server
Right-click the server and select "Clean..."
Right-click the server again and select "Clean Tomcat Work Directory..."
In the Eclipse, select the top-level menu option, Project > Clean ...
Be sure your project is selected and click Ok
Restart Eclipse
4th Step is most important.
Go to Servers remove the existing server by clicking delete.
Click the blue link to launch the server.
Set a new runtime environment.
Close the Eclipse and launch it again.
Boom it works!