Tomcat 6.0 and Eclipse. Multiple instances of the server behave differently - java

I have Tomcat 6.0 installation on my Win7 PC. I used 64/32bit windows installation.
In Eclipse I was able to set paths and set server to use my Tomcat installation. Everything seems working fine until I run server from inside Eclipse.
I noticed that http://localhost:8080/index.html page is not available (Tomcat default home page). I also can't access http://localhost:8080/axis2. I have Axis2 installed too.
Since I am struggling to make simple axix2 web service for long time, I am thinking maybe this Eclipse instance of Tomcat is adding to my issues?
When I start Tomcat from windows GUI everything works as I expect.
Any ideas?
Thanks.

Eclipse does by default not take control over the Tomcat installation and all of its pre-deployed webapps, instead it just uses its sole server engine and uses the workspace metadata as deploy space. When you start such a server configuration from inside Eclipse, all of the pre-deployed webapps will just be plain ignored, including Tomcat's default homepage.
To let Eclipse take control over the Tomcat installation, you need to doubleclick the Tomcat server entry in Servers view to get its configuration, then at the left column, under Server Locations, you need to select Use Tomcat installation (note, when it is grayed out, read the section leading text! It needs to be published without any projects).

Yes, this is normal. In the Package Explorer, you can click the Servers folder and view the configuration files that the Eclipse instance is using, specifically server.xml and context.xml. You can edit this configuration to match your specific requirements.
You may also want to check out the section titled Tomcat Publishing Options in this link here: http://www.eclipse.org/webtools/releases/2.0/newandnoteworthy/server.php
I favor this approach because when WTP inevitably corrupts my configuration once every two weeks, I don't have to reinstall Tomcat, I can just delete the server and reconfigure it.

Related

How to startup a Tomcat server from command line that's configured for an Eclipse project?

At my current company we use the Eclipse IDE to run a Java Web-app. I've learned how to use it pretty well, but the feel and navigation of using VSCode is just suits me better.
If anyone has found a way to start up the server configured as the Eclipse project through command line and is able to use it it with VSCode that'd be awesome!
NOTE: I know there's the bat file for start/stop in the installation, but I can't seem to use those with a configured project. Thanks!
I am not aware about VSCode, but definitely, I can guide you, how to run Apache Tomcat Server in command prompt, configured for any specific project in Eclipse.
Please follow or check below procedure to do same:
1. Environment Variables and Set Bin Path
Please set new environment variables for JAVA_HOME and CATALINA_HOME
Please add entry in PATH variable for JAVA_HOME/bin
2. Eclipse-Preferences-Server-Runtime Environment
Please add server by selecting same Apache Tomcat Server CATALINA Home Path in preferences of Eclipse (Eclipse-Preferences-Server-Runtime Environment), which you have configured in Step 1. Both configured server must be same for step 1 and step 2.
Please refer below attached screenshot.
3. Eclipse-Java EE Perspective-Servers (View)- Create New Server
If you import your Java EE project then it should be opened in recommended Java EE perspective of Eclipse. Go to Servers View and create new server from configured Apache Tomcat Server
4. Configure or check options of Tomcat Server by double clicking in Server View
Please double click on newly created Apache Tomcat Server link before deploying any Java EE (web) application.
New tab will be opened to configure or set options for Apache Tomcat Server in below sections:
1) General Information
2) Server Locations
3) Server Options
4) Publishing
5) Timeouts
6) Ports
7) MIME Mappings
Please refer below screenshot
5. Server Locations
Here, in this section, you will notice three ways to specify server location:
1) Use workspace metadata (by default selected and does not modify tomcat installation)
.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
2) Use tomcat installation (takes control of tomcat installation)
It will display configured path of Apache Tomcat Server.
You should select this option, if you want to run your project from command prompt.
Eclipse will take full control of your configured tomcat installation.
If you want to run your project from command prompt then go to command prompt and start Apache Tomcat server, configured in Step 1 and Step 2.
The startup.bat (for windows) or startup.sh (for linux) files will be in bin folder.
You may set deploy path to the default value as wtpwebapps or browse and select.
3) Use custom location (does not modify tomcat installation)
6. Deploy Project or Add Resource to Server
If you have configured any one of above server locations, as per your requirement then after you should deploy or add project to server.
Thanks and Regards.

Can glassfish on 8089 port somehow block tomcat on 8088 port?

i worked with Tomcat 8.0 without any problem. Then i installed glassfish 4 and set its port on 8089 (works fine), but now i am unable to work with my tomcat server (8088 port).
Weird is that i can start Tomcat without any problem in eclipse (Started state) but in spite of it, i cannot display tomcat site in browser either some projects on tomcat. It throws 404 error.
Where could be a mistake, does anybody please have some idea?
I attached screen of some tomcat settings and how issues looks like.
You are using eclipse WTP to manage Tomcat which allows you to choose the following options for server locations:
Use workspace metadata (does not modify Tomcat installation)
Use tomcat installation (take control of Tomcat installation)
(1) means to create a new tomcat instance to deploy the web app by setting the $CATALINE_BASE. This new tomcat instance will not have any default applications. So nothing will be shown if you access the root URL.
(2) means to use the tomcat original instance which is shipped with a number of default web application (root web , example app , manager app etc.). So if you choose this option , you will see the tomcat welcome page (root web).
Reference :
WTP Tomcat FAQ this
CATALINA_HOME vs CATALINE_BASE
Yes because the tomcat use others ports. Try open glassfish with out tomcat . If work, change default ports of the server into server.XML file and try again with both servers

How to debug web service with Eclipse Websphere liberty

First thing's first: I'm trying to develop an web service that is integrated with third party JCE(using Security.addProvider to use that jar which is packed into my WAR), but somehow when I deploy the WAR on my Websphere 8(with Java 1.8), it keep telling me that it cannot find the specified algorithm(AES) that I need unless I drag the JCE into Websphere's JRE and change its java security configurations.
Since I have no idea about the root cause, so I installed light-weighted websphere using the Eclipse's plugin install manager. Then I start the light-weighted server, select my web project and set it to debug on this server. But the Next screen I saw is "Context Root Not Found", even I changed the URL to the servlet.
I'm not familiar with WAS and it's liberty plugin, but isn't it suppose to run my project on it? like the Tomcat? Can anyone tell me how to run my WAR in it, so I can debug it? please?
First off, it looks like there is a misunderstanding on what Liberty is. When you say "light-weighted server" I'm assuming you mean Liberty, which is accurate -- Liberty is indeed a light-weight server.
However, WebSphere traditional and Liberty are two different products/servers. Liberty is not a plugin for WebSphere traditional.
A Java EE application running on WAS should behave very similarly to an application running on Liberty, because they are both Java EE compliant application servers. Since debugging and developing an application on Liberty will be easier/faster than on WAS, I would recommend using Liberty.
To debug your application on Liberty using the Eclipse WDT plugin:
Open eclipse with the WebSphere Developer Tools (WDT) plugin installed (you can get WDT here).
Follow this article to create a server using WDT. You can skip the parts about creating a sample application since you already have one.
Open the "Servers" view (using Window->Show View->Other...->Servers) and find your server:
Right click the server and do Add and remove... then add your application to the server
Set a breakpoint in your application code in Eclipse
Start the server in debug mode (by pressing the bug icon shown in step 3)
In the Eclipse menu, select Debug->Debug As->Debug on Server:

Liferay IDE portlet changes not synchronized on the server

Platform
Liferay 6.2 EE Tomcat bundle deployed locally
Liferay 1DE - various version in the past 1 year
Liferay 6.2 EE plugins SDK
JDK 6 or 7
Mac OSX or Windows
Problem
We run into an issue intermittently with the Liferay IDE where a portlet java class changes are do show up the Tomcat server.
The setup is as follows:
A portlet is deployed on the server and is also configured to publish and synchronize on the local server (by drag and drop).
Any changes saved to any of the java class result in a expected publish to the server automatically without a need to do a ant deploy/ Liferay -> SDK -> deploy.
These changes can be seen in the browser after the publish
Intermittently, this automatic publish sync of the java classes does not work and the changes can't be seen in the browser.
Stopping and starting the server seem to have no effect.
Has anyone see this behavior?
I am working with a similar platform
Liferay 6.2 EE Tomcat bundle
Liferay Developer Studio 2.2.2
Liferay 6.2 SDK
JDK 7
Windows 10
To "synchronize" the changes in your IDE with your local server is about the way in which you deploy your portlet.
Although these initially steps are not explicitly necessary - I strongly recommend them for consistency
The first steps to clean your local environment
Stop the local server
Right click the server and clean
Empty your webapps folder leaving only root
Empty your temp folder
Remove all files and directories from tomcat-X.x.x/work/Catalina/localhost except _
Next open your local server settings by double clicking on your local server instance. In the top right corner you should see a publishing fold. Click to expand and select the following options
Automatically publish when resources change
Update context path
Under the Liferay Settings fold (bottom left) you should have the following setting selected
Development (portal-developer.properties)
Enabling Developer Mode turns off certain caching options that default to true when operating in standard mode. Despite the official documentation it does not eliminate the need "to redeploy to see your portal modifications".
Instead of direct deploying from ANT, right click on your server -> add -> then select your desired portlet
This creates a directory in webapps with your portlet similar to ANT direct deploy - this is the only way automatic publishing will work.
The problem above happened to a few of my team members local Liferay environments.
I have been able to work around this by following the steps below:
Undeploy the portlet by removing the portlet from the Tomcat home/webapps/ folder
Stop the Tomcat server Liferay IDE
Cleanup the temp folder under Tomcat home/tmp/ folder related the portlet in question
Start the tomcat server via the Liferay IDE
Deploy the portlet to the Tomcat server
The publish sync process seems to start to work after these steps.
I am not sure if there is a better solution.
Hope this helps someone.

Auto deploy changed java code in Maven, Eclipse, Glassfish

I am new very much new to maven and spring technologies. I want to know how can we auto deploy the java server code without rebuilding the maven or without restarting the glass fish server? Currently I have to restart the server if any change I do in java code. I have also use one option in Eclipse to "Automatically publish when resources change" but no use.
You may want to take a look at JRebel, it reloads changes made to your code instantly without having to restart your application server.
The recent version of HotSwap Agent works very well for me with Eclipse and Payara Server (server derived from and compatible with GlasFish).
It's free and opensource and supports Java 8, including lambdas. It supports reloading of resources in a webapp running on GlassFish/Payara, including JAX-RS annotations, CDI bean definitions etc., without restarting whole application.
The only drawback is that you need to install the DCEVM plugin into the JDK, which has to be activated by a command line argument -XXaltjvm=dcevm. But this isn't intrusive and doesn't affect your JDK if you avoid the argument - you can activate it just for GlassFish/Payara Server when you add it to the JVM options in the domain configuration. When adding the -XXaltjvm=dcevm option, you also have to remove -client and -server option, because they take precedence.
So, essentially these steps are needed with the recent version of HotSwap agent and practically with any version of GlassFish and Payara Server:
install DCEVM as altvm into the JDK (run the installer with admin rights)
copy the hotswap-agent.jar into lib/ext in your domain directory
add the following arguments as JVM options in your domain configuration: -XXaltjvm=dcevm -javaagent:/path/to/hotswap-agent.jar
run the server in debug mode from your IDE
in Eclipse, all works out of the box, just avoid using the Publish button for the server. Check that "Never Publish automatically" is checked in the server Overview, when you double click on the server in the Servers view
in Netbeans, you need to disable "Deploy on save" in project configuration and enable "Apply code changes after save" in global Java Debugger options
There is some information in this Payara issue, although it isn't an easy to follow guide. Some more info in this HotSwap issue.

Categories

Resources