How to get eclipse Dynamic Web Project working in elastic beanstalk - java

I have a spring boot java web server running in AWS elastic beanstalk that was created 3 years ago. I am trying to recreate it now using current versions of tomcat, eclipse and the AWS plugin and can't get it to work. I do not want to use spring boot again in this server but will if I have to.
No matter what I try I can't access a servlet in the web project, and all servlet requests result in 404 not found errors. Requests for static HTML pages work properly.
I have searched for answers and found some tips for old versions of tomcat (name your war ROOT.war) and a suggestion that using web.xml instead of modern servlet annotations will help. None of these suggestions solved the problem and I have tried many combinations of different versions of Tomcat and various servlet mapping techniques with no luck.
To ask for help, I have listed the following steps. I am suggesting Tomcat v7 because it uses web.xml as my old server did. I would be happy to use v8.5 if possible, or change any other step, to get this basic Hello World sample running in elastic beanstalk.
Here are the steps:
create new Dynamic Web Project (TestProject) in eclipse
target runtime = Tomcat v7 (which still uses web.xml)
web module version = 2.5 (which does not use annotations)
accept all other defaults
added index.html (to prove war is deployed in elastic beanstalk)
simple content, containing just a Hello World
add new servlet (org.example.TestServlet)
accept all defaults including generated eclipse code stubs
test static content in eclipse
select project, right click menu, Debug As / Debug on Server
can view index.html in browser
test servlet in eclipse
select TestServlet, right click menu, Debug As / Debug on Server
can view output: "Served at: /TestProject"
url is: http://localhost:8080/TestProject/TestServlet
export TestProject.war to disk
optimize for Tomcat v7
setup elastic beanstalk
create new web server environment
select Tomcat Preconfigured platform (this is v8.5)
upload TestProject.war
test static content in elastic beanstalk
request in browser: http://my-env.ejppddd6xm.us-east-1.elasticbeanstalk.com
can view index.html in browser
test servlet in elastic beanstalk
request in http://my-env.ejppddd6xm.us-east-1.elasticbeanstalk.com/TestProject/TestServlet
get HTTP 404 not found error
No matter what I change, the servlet test always results in a 404 error. I can do the same test on my old server built 3 years ago and it works.
I have also tried an AWS Java Web Project using the AWS plugin, but it results in a corrupt project with a low-level Maven error. I have reported this to AWS.
Can anyone suggest a change in the above steps that will result in successful servlet test within elastic beanstalk?

Related

How to get started on Google App Engine for current GlassFish solution

I'm currently running my Java application on a GlassFish server on AWS-EB.
Since our front-end is already running on the Google Cloud Platform, I would like to migrate my back-end to GCP as well.
I tried the Jelastic interface but I was not happy with the speed results.
Now I'm looking to deploy my application on the App Engine but when I deploy my current .war file, I get the following error:
Error 404 - Not Found.
No context on this server matched or handled this request.
Contexts known to this server are:
/ ---> o.e.j.w.WebAppContext#7e0b0338{/,file:///var/lib/jetty/webapps/root/,UNAVAILABLE}{/root.war} [failed]
I guess I'm missing something, since GCP is using Jetty as a server.
I'm a bit lost and I hope you guys can point me in the right direction to make this migration successful.
It's suggested here that Jetty requires two configuration files (web.xml and applicationContext.xml).
As well as this, the original poster in the issue above stated that they solved their issue in this GitHub post by rebuilding their project before deploying.

Apache and Tomcat Server Cross Domain

I have three distinct heavily coded web-projects; two of them (new) is newly developed with Java/Script, the other (old) one with PHP. All of these three project has some common resources like HTML containers, Element classes etc. Moreover, one of the Java project is Main Project that call the other two projects.
The issue is that Java projects run on a Tomcat Server, PHP needs to run on Apache Server. And PHP project has some location paths for resources like "../SomeResourceFolder/somePage.php". However, when I run Main Project (Java) on Tomcat Server which has "localhost:8080" I could not reach PHP project which is run on Apache Server with "localhost:80", even if I accomplish to reach PHP project, PHP one fails to reach common resources in Tomcat.
I solve the issue a little bit unconvincing way with JavaBridge and Quercus; they help to run PHP on Tomcat Server. However, again I have some path problems.
Actually these projects runs on production with load-balancer which direct request to related server. I try to simulate this or at least run PHP on Apache, Java on Tomcat and connect them somehow. How can I construct this kind of structure without cross domain problems?
I solve the issue by using "Tomcat Connector". It connect Apache and Tomcat by defining Tomcat as worker, and send HTTP request with given path configuration.
You can follow guide given by Nanyang University. In guide Tomcat 6 and Apache 2.2 are used but I used Tomcat 7 and Apache 2.4 with the same directions.

Tomcat setup issues

I'm trying to run a simple JAX-WS example I found on the web. So I wanted to setup Tomcat 7 under windows xp using Eclipse Helios 32 bit as the web server.
I remembered I had to have my app added as a resource to the Tomcat server, but nothing is coming up as a resource to add. I just have WS-Server and WS-Client projects for the app.
I've done this before, checked the server.xml and see http 1.1 port is 8080, but when I start up Tomcat under eclipse I'm getting a 404 error with this url: http://localhost:8080/, so Tomcat isn't really running properly.
What am I missing here?
Thanks!
If you're getting a 404 - that means the web server is running. This likely means you don't have anything mapped to the path specified (no servlets/default web page/etc).
Either make a servlet and add it to your web.xml or define a home page html file.
FYI, if you use the "Dynamic Web Project" setup; most of this is done for you. Here is a youtube video I always default to when I need to get a review on how to set up a quick tomcat instance in eclipse.

Using AWS Elastic Beanstalk with a Java/BlazeDS/Spring application

Is it possible to deploy my Spring/BlazeDS/Java application to elastic beanstalk? I'm using MyEclipse and built a Java Web Project with the required jar files etc. Do you need to specifically create an AWS Java Web Project - reason I ask is the options to include the BlazeDS files aren't there - so I'm wondering if Spring / BlazeDS is even supported? By default the turnkey blazeds runs through Port 8400 - so I imagine there are some additional tasks required to configure the endpoints to work through port 80?
Gracias!
Take a look at this example. Will be trying something similar over the next few weeks.
http://www.riaspace.com/tag/aws/
BlazeDS is not a standalone application, it consists from a bunch of jar files which should be added to your web application. You will also need to declare a servlet in the web.xml file. I wrote an article a couple of years ago how to add the blazeds jar files to a java web application (and what to configure), you can take a look here.

What are the Steps for Debugging Java Web Application?

I joined a project which has been already developed and its an Web Application deployed on Tomcat Server.
I have configured the Web Application on my local Tomcat Server and it is running fine. I want to start debugging the Application but I am not sure where to start from and how to debug an Java Web Application from Eclipse and so my question is
Q: How to Debug Java Web Application which is running on Tomcat Server on Local Machine in Eclipse Environment {Pointers to useful resources or other steps would be highly appreciated}?
There are at least a couple of ways to do this:
A quick search turned up a tutorial to use remote debugging in eclipse with tomcat to connect eclipse to the java process running tomcat.
If you create your project as a Dynamic Web Project using eclipses Web Tools Platform plugin then you can deploy to and debug tomcat from within eclipse easily.
Just stop your server from normal start mode and click on debug mode. Soon, after the server shows debugging,synchronised, continue using the web apps as you do normally. But before that, you must provide breakpoints and you can see the results that you need.
Works for me.
I have had to do this a few times. Often it is not convenient to create a Dynamic web project to debug a web application in tomcat. This technique is fairly simple but requires some configuration in tomcat and then using Elcipse (or netbeans) to attach to tomcat when its running.
http://wiki.apache.org/tomcat/FAQ/Developing, in particular
How do I configure Tomcat to support remote debugging? and
How do I remotely debug Tomcat using Eclipse?
First get the Java EE edition of Eclipse
You then need to have the Eclipse project containing the WEB-INF folder be a Dynamic Web Project. Then the full tooling becomes available and allow you to work with your projects inside any server including Tomcat. The trick is to locate the Server view pane, and right click to add a new Tomcat server adapter.

Categories