I am taking over an old colleague's code and he used JHipster to build a Maven-Spring-Angular project.
I am able to compile, package his code and I used a simple Chrome Web Server (plugin), point it at the project's "target" folder which contains all the web components (i.e. assets, bower_components, META-INF, WEB-INF, etc) and his code, a dashboard can run successfully on the Chrome Web Server.
Problem is, all API calls to the Java back-end are failing.
IMAGE: API calls 404 error
IMAGE: Sample endpoint, api/data
Am I missing any steps when trying to run the project locally on my PC?
Will update the answer in details soon but just want to share the solution.
Chrome Web Server is not a proper Servlet Container hence Spring wasn't able to start. Since Spring did not start, requests to the endpoints could not be handled.
I'm working on a beta release of an application. This is a Java app that runs on Glassfish. Obviously we are getting bug reports from time to time. I would like to provide my users with a simple one-click button to get the server log from /domains/domain1/logs . I am not sure if the application is sandboxed in such a way that it can get to this log file.
Does glassfish sandbox the application in such a way that I would be prevented from getting the file? Is there a standard method or library I can use to get the logs?
If the file permissions on the server are correct, can I just have my application read the file using an absolute path?
You application can read the server.log file directly. Note that the logs are rotated, so your application would have to reload the log file and maybe even provide access to the rotated logs.
If you are using a web server front end, such as Apache, you could just serve the log directory. I think you could just create a symbolic link to that directory in your webroot.
Be careful you are not logging any sensitive information as exposing a log file could be a security risk.
If you are using GlassFish 2.1, you should look at AMX. The AMX class Logging seems to have the data that you want.
If you are using GlassFish 3.1, you should use the RESTful interface to the admin data. If you have an instance of GlassFish 3.1 running locally, right now, you can click this link to see the log data: http://localhost:4848/management/domain/view-log...
If you are using a WebKit based
browser, like Chrome or Safari, you
probably need to view the source of
the 'empty' page....
If you are using GlassFish 3.0, you will need to open the file directly.
I have with me the client interface for a web service that was built using JBoss/RESTeasy. The web service calls work fine when they are invoked from a stand-alone app, but as soon as I put them into a webapp running in a Tomcat container (on the same machine), they start behaving weirdly. Some of the calls return empty results while some others simply fail with this exception:
org.jboss.resteasy.client.ClientResponseFailure: Error status 404 Not Found returned
Any idea of what might be going on? Could this be a result of a library conflict? All the required client libraries are in the WEB-INF/lib directory of the webapp.
Seems that your services are not deployed properly. Take a look at your catalina.out or some other logs for more details.
Something strange happened to my servlets and I think I've figured out why, yet I'm more confused. I used Netbean6.7 to develop a Paypal IPN (Instant Payment Notification) message servlet, it listens on port 8080 by default for Paypal IPN messages. I used some sample Java code from it's web site, but when it ran, only about 1 in 10 messages came through, and they looked correct, but why 1 in 10 ? Not 100% or none ?
So I asked some questions here and got some advices, one in particular points me to Google's App Engine, so I downloaded it and ran the demo guestbook while my IPN servlet is still running on Netbeans, the strange thing happened, after I entered "appengine-java-sdk-1.3.2\bin\dev_appserver.cmd appengine-java-sdk-1.3.2\demos\guestbook\war" from the command prompt, I went to the following url on my browser "http://localhost:8080/", I thought I would see the Google demo guestbook page, NO, what I saw was another servlet I developed 2 years ago : "Web Academy", online course registration app.
How can that happen? I never started it, and I haven't touch that project for years. I guess because it's also listening on port 8080, so now I understand why the IPN messages only came through 1 in 10 times, because another servlet was also listening on that port and could have got the messages intended for IPN, or some how those two servlets' processes mixed up and therefore couldn't respond to Paypal properly, and failed. In order to verify some of my guesses.
I turn off Netbeans, and ran the Google guestbook again at the prompt, this time on my browser http://localhost:8080/ points to the demo guestbook page.
My Urls look like this :
[A] Paypal IPN : http://localhost:8080/PayPal_App/PayPal_Servlet
[B] Web Academy : http://localhost:8080/
So now, my questions are :
Why the "Web Academy" servlet was auto started when I ran the Paypal servlet ?
If I change the IPN listening port to 8083, would that mean I can run both of them on my PC at the same time without affecting each other ?
But I still don't understand, [A] and [B] look different, if a page for [A] is refreshed, it should show the Paypal content, and another page looking at [B] should show the Web Academy content, and that's exactly what happens when I started Netbeans to run the Paypal servlet, both pages show their respective content correctly side by side without interfering with each other, how come the IPN messages couldn't get through 100% of the time ?
In Netbeans how to assign 8080 to servlet [A] and assign port 8083 to servlet [B] ?
How to turn off auto start of Web Academy by Netbeans ?
First: Servlet != Webserver. A servlet is a Java application programming interface which is supposed to run in a servletcontainer. A servletcontainer is usually part of a Java web server, like Apache Tomcat and Glassfish. A web server usually listens on a certain port for HTTP requests. A servletcontainer creates and instantiates servlets on startup. Every request whose URL matches the url-pattern of the servlet will let the servletcontainer execute the servlet.
Second: Netbeans != Webserver. Netbeans is an integrated development environment (IDE). It's just a development tool with a bunch of wizards which should ease the development. You can develop as perfectly fine with just cmd.exe and notepad.exe and a standalone server as with an IDE. You just has to know what you're doing.
As to your actual problem: you probably have developed the "Web Academy" project in Netbeans before and deployed it as "ROOT" project of the webserver in question. The GAE probably failed to startup because the port is in use by the webserver managed by Netbeans (did you note of any error messages during GAE startup?). Shutting down Netbeans (which is a bit drastically, just shutting down the webserver managed by Netbeans has been sufficient) would have freed up the port.
That said, honestly, all this confusion seems to boil down that you never learnt the basic Java / Servlet concepts separately and immediately dived in the deep hole with an all-in-one IDE where you have to learn 1000 different things altogether in a single place and assumed that it's the "only right" place to do it. I strongly recommend to take a pause and restart learning the basic concepts one by one. Get some good books and take the time to get it all right. Learn Java SE separately. Learn Servlets separately. Learn Netbeans separately. Learn webserver separately. And so on. Then do the Math. Good luck.
There are so much things questions mixed in your question that I don't know where to start. What is sure is that you need to go back to the basics and to take some time to understand how things work. Servlets are pieces of code packaged inside a web application which is deployed in a servlet container (a server). Let's look at how you access them:
http://<host>:<port>/<context>/<url-pattern>
A B C D
Where:
A is the machine (hostname or IP) where the servlet container is running.
B is the port to which the servlet container is listening to (not a servlet).
C is the path to a web application (typically the name of the web archive without the .war extension but a webapp can be mapped to "/" aka the root context).
D is the URL pattern to which a servlet is mapped.
Now, let's try to answer your questions:
Why the "Web Academy" servlet was auto started when I ran the Paypal servlet ?
My guess is that this old application is still deployed on the server you're using under NetBeans (maybe NetBeans built-in server). So when you "start" the new application (and actually the server), the old one is also accessible.
If I change the IPN listening port to 8083, would that mean I can run both of them on my PC at the same time without affecting each other ?
As we saw, this doesn't make sense, a server is listening to a port, not a servlet.
But I still don't understand, [A] and [B] look different, if a page for [A] is refreshed, it should show the Paypal content, and another page looking at [B] should show the Web Academy content, and that's exactly what happens when I started Netbeans to run the Paypal servlet, both pages show their respective content correctly side by side without interfering with each other, how come the IPN messages couldn't get through 100% of the time ?
The URL [A] points to the PayPal_Servlet of the PayPal_App. The URL [B] points to the default page of a web application mapped to the root context. In other words, both URLs points to different applications.
In Netbeans how to assign 8080 to servlet [A] and assign port 8083 to servlet [B] ?
Sorry to repeat that but this doesn't make sense. You can very likely change the port used by the server started in NetBeans but, still, both servlets would be served by the same server, running on a new port.
How to turn off auto start of Web Academy by Netbeans ?
I'm not sure but do some clean up in the directory where applications are deployed (with tomcat, check the webapps directory) or in the server.xml. Hard to say without more details on your configuration, on what you installed, etc.
Servlets are mapped to unique URLs, which includes the port, so it's perfectly okay to have several servlets listening to the same port number. It's common when you have a single web context with more than one servlet/JSP associated with a single URL.
The URL for your context usually looks like this:
http://host:port/context-name
In your case, host is localhost, port is 8080. But the context-name is "PayPal_App" for one and the root for another. I think you'd be wise to use another context like "demo" for your other app rather than the root context. Your apps don't belong there.
You cannot assigned a port to a servlet. You assign a port to your servlet container (being Tomcat, Jetty, Glassfish, JBoss, etc.) A servlet is simply an instance of javax.servlet.Servlet, not an entire server.
If you wish to have more than one servlet running in a server, you create a servlet (I'm thinking you'll want to extend javax.servlet.http.HttpServlet) and configure it in the web.xml for your application. As long as the names of your sevlets do not conflict you should be fine.
I'm guessing either you have a servlet container running externally and you simply configured NB to use it, or you have imported all your old NB projects, and they've all gotten deployed somehow. The reason you saw your registration app was that you weren't watching your GAE log files, so you didn't notice that it died when it couldn't listen on the port. You also didn't assign a unique URL to the app, so requests that went to the root were handled by the registration app. None of this explains why your PayPal requests are getting dropped, I'd start up snoop/wireshark/whatever and check your HTTP traffic. My guess is your app has a bug. Checking the servlet container log file may reveal some clues. To undeploy your registration app, find out where your app server stores the web apps and remove either the war file or the directory holding the registration app files.
How can I run a servlet programme?How can i set the classpath?
Please read this http://www.jsptube.com/servlet-tutorials/simple-servlet-example.html for your first steps.
Well, you generally run it in a servlet container such as Websphere Application Server or Tomcat. And the way you configure the classpath depends on the servlet container you choose.
just to repeat the basics: a servlet is a piece of java code that runs inside a servlet container (i.e. a spezialized web server). it listens to client requests (typically issued through a web browser) and answers them with a response (e.g. with an HTML page).
"running" a servlet can thus mean two different things:
deploying the servlet to a servlet container (and thereby making it listen to requests), or
actually making it process a client request
(1) is achieved by packaging the servlet code (+ 3rd party libraries) into a war file and deploying this web application archive to the server -- details may vary depending on the type of servlet container. (2) is triggered by issuing a http request, e.g. through typing the servlet URL (something like http://localhost:8080/servletexample) into the location bar of your browser.