Map external directory outside tomcat installation in eclipse Dynamic Web Project - eclipse

I want to map an external directory outside tomcat installation which stores images in eclipse Dynamic Web Project's tomcat server. I have done that in tomcat directly by adding context tag in server.xml file. But when I done that in eclipse Dynamic Web Project's tomcat server.xml file. It is not working. I am using Tomcat 6.
My question is:
How to map an external directory outside tomcat installation in eclipse Dynamic Web Project?
Is it the good way to map external directory outside tomcat installation?
Thanks
Brajesh

Try a linked resource. Go to the folder in which you want your external directory to apprear. Now open the File menu -> New -> Folder.
Type in the name.
Click on "Advanced >>". Select "Link to alternate location (Linked Folder)". Browse to the external directory.
Click Finish.
That creates a link from your workspace to the external directory. It's possible that the plugin supports that.

Related

Eclipse with Tomcat does not automatically republish my WAR file

I've got Windows 8.1 with a 1.6 JDK manually installed.
I'm using Eclipse (Kepler, Java EE IDE for Web Developers).
I imported a project that builds a WAR file using an Ant build script; that shows up as a Project.
I created a Tomcat6 Server (downloading the available Eclipse package); that shows up as a second Project.
On the Modules tab for the Server, I clicked "Add External Web Module...", browsed to the folder holding my WAR file and clicked OK. I then added the name of my WAR file (directory name "...\SpiffyApp" to file name "...\SpiffyApp\spiffyapp.war"). I confirmed that the name of the path is "/"; I clicked to have "Auto reloading enabled" checked, and clicked OK.
I admit - I peeked inside the Server configuration. I clicked on "Open launch configuration"; in dialog "Edit launch configuration properties", on the Arguments tab, I discovered the following property setting:
-Dcatalina.base= "....metadata.plugins\org.eclipse.wst.server.core\tmp0"
Then in my mischief I observed that the "tmp0" directory had a "webapps" subdirectory. Aha!
I notice that, under some circumstances, the "SpiffyApp" is republished under "webapps" - problem is, I can't figure out when!
Specifically, I'm disappointed that Eclipse doesn't republish my app to "webapps" when I tell the server to "Clean"/"Publish". What I'd really like is for it to republish automatically when I rebuild the WAR.
I can get the WAR redeployed when I do all of this:
stopped my Tomcat Server
delete all folders under "tmp0/webapps"
delete all folders under "tmp0/work" (tip I got from Chris Lercher, here)
rebuilt my WAR file
Started my Server
Surely I'm doing something wrong.
What are the rules here? Am I really left to remove the Web Module, delete the folder in "tmp0" and re-add the Web Module?
What you're doing wrong is expecting it to watch for changes on an archive file, which generally isn't expected to change. Import the WAR as a project and then Eclipse can deploy it properly when something actually changes within the app.
Otherwise you might try forcibly Cleaning the server area from the context menu of the Tomcat server instance in the Servers View.

Eclipse - Make dynamic web application include other projects in workspace

I'd like the exported .war file to include the other (referenced) projects in the workspace.
When I reference them in the Build Path only, it shows no "Problems", but ClassNotFoundException is thrown later, when I try to "Run on Server" or export.
Using eclipse Kepler, tomcat 7.0.42.
I've seen the solution here: Not able to configure run path for web application project in Eclipse workspace; that's how it works now. Is there a more convenient way?
Are you running Tomcat within Eclipse? Try this:
Run -> Run Configurations... (or Debug Configurations...).
Find Tomcat v7.0 Server at localhost (or whatever it's named for you) under Apache Tomcat on the left-hand side.
Go to the Classpath tab on the right.
Select User Entries and click Add Projects....
Select the projects you wish to include.
That should place that project on Tomcat's classpath.

How to change Liferay Portlet Plugin API library in Eclipse?

I have switched my web-application to run on another installtion of Liferay. Consequently, I was able to changle classpath libraries in my project to new server location. This includes JRE System Library and Liferay v6.0 CE. I.e, both these libraries can be added for new server location from Java Build Path dialog.
But the library "Liferay Portlet Plugin API" still refers old Liferay installation path and I see no way to change it.
How is it possible?
UPDATE 1
Here: http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+IDE+Getting+Started+Tutorial
On the very most low picture you can see all three libraries listed in Package Explorer. Two of them I was able to change and the question is about third one.
You can manually change file .metadata\.plugins\org.eclipse.jdt.core\variablesAndContainers.dat.
So open your filesystem browswer (My computer) navigate to your liferay IDE workspace location and go to .metadata\.plugins\org.eclipse.jdt.core. Open file variablesAndContainers.dat and find and edit your jars locations.
After that restart Liferay IDE or simply close and open your project.
UPDATE:
1) Take note of jars that are needed
2) Go to configure build path dialogue than go to libraries and select "Liferay Portlet Plugin API" then click Remove
3) Create folder "lib" directly in your project (not WEB-INF/lib)
4) Add jars to lib folder (from 1.)
5) Select jars and add them to build path (right click - Build path - add to build path)
Or you can crete you User libarary with those jars and than add it to build path
Additionally to chosing correct libraries in classpath dialog, one should also change "target runtime" appropriatedly by right click project and going to properties > Targeted Runtimes.
P.S. And plus one should close project and then open it again.
in my case, following instructions in this question about clearing eclipse cache (-clear option) helped, as changing liferay plugins SDK path wouldn't change the libraries' locations when adding this library to project build path...

Change eclipse's built in tomcat context.xml file using WTP?

Is it possible somehow to modify the contents of the context.xml that eclipse uses when you are doing "Run as" -> "On server"... and "Debug as" -> "on server"
We have some settings that are in our production environments context.xml file and we need them to be available to eclipse built in tomcat as well.
I know we could use eclipse to run run on an external server, but thats not as convenient.
Have a look at the automatically created project "Servers". There should be a folder for each configured Server. There, open the context.xml and add anything you like to be in the "default" context (Parameter-Tags for example).
Anything that's inside there will be used to populate the context.xml WTP automatically creates on publishing for each project on that Server.
Or use the project specific way: put a context.xml with your contents inside META-INF in your project (have a look here: http://wiki.eclipse.org/WTP_Tomcat_FAQ#How_do_I_specify_the_Tomcat_context_configuration_for_my_Web_Application.3F)

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.