Hawtio simple plugin example - tab is not visible - plugins

I am trying to develop a custom hawtio plugin. I have custom WAR deployed in Tomcat based on hawtio-default 1.4.37. It works correctly
I built simple-plugin.war following https://github.com/hawtio/hawtio/tree/master/hawtio-plugin-examples/simple-plugin instruction (no changes are done) and deployed it in the same Tomcat.
There are no errors, all logs are clean, I can see simple-plugin as plugin of hawtio in JMX bean, however no new tab is visible (although as I guess from .js code "Simple" tab should appear)
Any idea? Is it something to do with perspectives?
Edit:
Just checked the browser console and seen 404 error
GET http://localhost:8080/myhawtio/plugin/ 404 (Not Found)
It seems that my custom WAR is not correctly reconfigured
Edit 2:
Downloaded and deployed clean hawtio-default-1.4.37.war - simple-plugin works, "Simple" tab is visible
Downloaded and deployed clean sample-1.4.37.war - simple-plugin does not work, tab is not visible and get 404 error
GET http://localhost:8080/sample-1.4.37/plugin 404 (Not Found)

You must make sure to install the simple plugin using the same name as its configured in the web.xml file.
In the web.xml the context path gets set when you build the example from:
https://github.com/hawtio/hawtio/blob/master/hawtio-plugin-examples/simple-plugin/src/main/resources/WEB-INF/web.xml#L14
By default that is generated as
<context-param>
<description>Plugin's path on the server</description>
<param-name>plugin-context</param-name>
<param-value>/simple-plugin</param-value>
</context-param>
So that means you should install the war as simple-plugin in Apache Tomcat, eg rename the .war file to simple-plugin.war

If you're getting a 404 for /hawtio/plugin then you're missing the PluginServlet from your war, or at least it isn't running -> https://github.com/hawtio/hawtio/blob/master/hawtio-system/src/main/java/io/hawt/web/PluginServlet.java
This servlet is how the frontend discovers any additional plugins to load. I'd suggest comparing your web.xml with the one from hawtio-web and make sure this class is getting loaded.

Related

JavaEE Servlet won't hot deploying

I started working with javaEE and currently doing some basic servlet stuff. So I'm using Eclipse neon and GlassFish server. Created a dynamic web project and everything works fine.
The problem are servlet file changes. If there is a change in the java file nothing happens - no hot deploying/ republish. I have to complete remove the application from server and re add it to see the changes.
Changing .html files works (doesn't effect servlets changes)
Rebuild does nothing
Server "clean" does nothing
Server restart does nothing
"Automatically publish when resources change" is of course on, hence the html changes
The problem might be, that it does not observe the correct files for triggering the redeployment.
I haven't tried it for GlassFish, but could see the same behavior for WildFly as you described with the default server settings.
Try to add \.class$ to section Application Reload Behavior in server settings. (This will be the case for exploded deployment.)
Credits to varantes answer in this question

basic authentication not working in eclipse but works when i put my app in web-app in apache-tomcat

i am facing a problem in using basic authentication..
initially i tried this in eclipse but i got 404 error, i tried everything, restarting, creating new projects but nothing worked.
then i exported the war file n deployed it in apache-tomcat web-app folder and started tomcat from command line and it worked,,
when i go this way i get the expected output when i refresh the page in eclipse , it works.
but then again of i run shutdown.bat and run server in eclipse and again refresh the page.. I GET NOTHING.. SAME 404 ERROR
please help
Check properly that may be you deployed your .jsp file inside WEB-INF folder so you will get this error because WEB-INF is secure.So create .jsp .html inside web-content.
Error 404 means your tomcat not able to get requested resource.
You can go here and check here
DeployentStructure

Apache Tomcat 7.0 not working properly with eclipse EE juno version

When I run apache tomcat 7.0 alone, it works without any flaw in my browser I can execute the examples also, but when I apache tomcat 7.0 in eclipse I'm getting a 404 error message saying that "requested resource is not available".
I just type the session example program and run it again, it shows this 404 error message only.
How do I resolve it?
I don't know whether it's the problem with tomcat or with eclipse..
Please help!!
I think your eclipse is configured to load a webapp folder that is not the one installed with tomcat, please follow the steps below:
Open the Run Configuration of the Tomcat 7 in the eclipse
Go to the Arguments tab
In the VM arguments, it should have a property listed: -Dwtp.deploy=...
The folder on this property define the webapp folder for the tomcat started from the eclipse
If you want it to load the tomcat examples, change the folder of that property to the one that have the examples
try doing the following steps:
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.34\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, R-click, and paste ROOT (say "yes" if asked if you want to merge/replace folders/files).
Then reload tomcat test pagea to see the Tomcat welcome page.
I feel your pain. I am also using Tomcat 7.0, and I've gotten servlets to work in Tomcat doing everything by hand. Then a couple of days ago I downloaded eclipse, and after a struggle I successfully got some servlets to work in eclipse.
I downloaded the Java EE version of eclipse here:
http://www.eclipse.org/downloads/
And then I followed this tutorial:
http://www.vogella.com/articles/EclipseWTP/article.html
The tutorial is a little out of date, but I managed to get eclipse setup correctly using that tutorial. In a couple of places, the tutorial says to click on Window->Preferences->..., which for me was equivalent to Eclipse->Preferences->.... The biggest problem I had was when the tutorial said:
Create a new package called ....
There were no instructions on how to create a new package. The way you create a new package is by looking in your project folder for:
--JavaResources
--src
Then right click on the src folder and select:
New-->Package
Send me a comment if you have any questions about any of the steps in the tutorial.
I got that 404 Error constantly until I figured out what was the correct path with which to call the servlet. If you are calling the servlet, say with a <form>'s action attribute, the url should look like this:
<form action="/<project name>/WelcomeServlet" method="get">
And that would correspond to a web.xml something like this:
<servlet>
<servlet-name>WelcomeServlet</servlet-name>
<servlet-class>com.exmaple.WelcomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>WelcomeServlet</servlet-name>
<url-pattern>/WelcomeServlet</url-pattern>
</servlet-mapping>
Are you using servlets 3.0 or 2.5? With 3.0 you use the syntax:
#WebServlet("/WelcomeServlet")
public class WelcomeServlet extends HttpServlet {
for the url mapping instead of a web.xml file.
I had a similar issue with my project.
Maybe Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace.
Go to webapps directory inside apache directory (for example C:\apache-tomcat-7.0.34\webapps), right click on the ROOT folder and copy it.
Then go to your Eclipse workspace, go to the .metadata folder, and search for "wtpwebapps".
Start the Tomcat server by eclipse.
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).
Pay attention that the folder tmp0 is present only if the server is started.
Go to the wtpwebapps folder, right click, and paste ROOT (say "yes" if asked to override folders/files).
Then try to see the Tomcat welcome page.
Bye
Monica
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 radio button ,browse Server Path of the Tomcat Root directory(Ex: D:\RaviTeja\installed\apache-tomcat-7.0.57) and browse Deploy path aslo webapps folderof tomcat
(Ex: D:\RaviTeja\installed\apache-tomcat-7.0.57\webapps).
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.
3. Please find below Tomcat configuration screen shot.

Apache tomcat 7 No error with localhost page, But when run project: show HTTP Status 404

I know there are many questions about Apache tomcat 404 error: but I think mine is different.
I am using windows 7 64 bit
unzipped eclipse-jee-juno-SR2-win32-x86_64 to C:\
unzipped apache-tomcat-7.0.37-windows-x64
changed port server.xml to 3030 instead of 8080
continue with this steps "Quick Start" from point (2)
I didn't forget:
copying ROOT folder
R-click tomcat node in eclipse Servers tab -> properties -> Switch location
Double click tomcat node in Project explorer and check use tomcat instillation (takes control of tomcat installation)
The page:http://localhost:3030/ works fine. It shows the message If you're seeing this, you've successfully installed Tomcat. Congratulations!
But when I tried simple project (I followed basic tutorial) and use Run as -> Run on Server the page of error 404 is shown. When back to http://localhost:3030/ it shows no error.
No error with http://localhost:3030/
Error when running a project!
HTTP Status 404 - /SimpleProject/
type Status report
message /SimpleProject/
description The requested resource is not available.
Apache Tomcat/7.0.37
I am The author of this question, and I solved it. I will provide the solution so that others can get help from it.
As I followed this installation steps carefully, then the installation is correct.
The only problem that caused the error is in the web.xml:
- When create a new "Dynamic Web Project" (As my case)
- Take care of this file: WebContent -> WEB-INF -> web.xml
- The <welcome-file> </welcome-file> tags must refer to exist files to display in the browser.
- If there are some default tags delete them.
- when you create for example a new HTML file named index.html, then make sure that the web.xml file refers to it. <welcome-file>index.html</welcome-file>
Digression (irrelevant to the solution above)
I am actually working on NetBeans extensively doing simple Java Standard Edition projects. I rarely encountered problems with NetBeans, and when they occur I can solve them easily either myself or by searching for information about the problem.
When I began learning the Java Entrprise Edition, and see tutorial on NetBeans, I started my first project from the first day.
But I found most of the tutorials use Eclipse and that was the reason why I installed it.
When I moved to Eclipse. I encountered many problems, and each problem take many hours to search and solve. that takes three days before starting one project.
I am wondering why people prefer Eclipse over NetBeans. I think there is some reason. (^_^)

error in running a web application on tomcat server

I am currently converting my Java project written under Eclipse to a web application and trying to run on tomcat server. I have converted the project into a maven module, changed its project facets and other requirements to make it a web app. I have put my project.cfg.xml file under WEB-INF and included deployment to web.xml file. When i run my browser and point to "http://localhost:8080/manager/html", i am able to see my deployed war file. But it says running = false and when i click on my project, it shows me
HTTP Status 404 - /myproject/
type Status report
message /myproject/
description The requested resource is not available.
Apache Tomcat/7.0.32
I faced the same problem in running sample programs from "quickstart" also.
You should read $TOMCAT_HOME/logs/catalina.out This log records the lifecycle of web applications. You should be able to find the part where it attempts to start your web application and it is most likely throwing some errors at that location.
Observe the tomcat console . Surely, there are some errors being thrown at the application start-up, due to which it's not starting.