How to find out right URL to JSF page? Opening in IntelliJ IDEA causes 404 - jsf

I'm very new on Java Web dev. On intellij Idea 14, I started a new project with plain Java, JSF support (no JavaEE, will add Spring later). Tomcat 7.0.59 as server. When I hit run on the IDE, firefox opens up and hits on 'http://localhost:8080/index.xhtml', it should display the hello world in index.xhtml that the IDE makes on new project, but the page just displays 'HTTP 404'.
I think the problem is path on the browser, how can I find the correct path and configure it on IDE deploy settings?, how can I debug on tomcat?, where can I start looking?

http://localhost:8080/index.xhtml is an incomplete address. Where is the context root? It should be the name of your project/webapplication, where you would have
"http://localhost:8080/{application-name}/index.xhtml".
Unless you've set your application to be the default tomcat application (which I highly doubt), you should have the name of your project in there in the URL

%CATALINA_HOME% is Tomcat install directory. Use %CATALINA_HOME%\logs to read Tomcat log for debugging.
When you create a new Java web project, It also means you are diving to Java EE (Enterprise Edition).
Create new JSF web application by IntelliJ IDEA:
Offical tutorial for you: http://docs.oracle.com/javaee/7/tutorial/partwebtier.htm#BNADP .
You should use GlassFish 4 application server for simplicity at first one.

move the lib directory into WEB-INF

Related

How to get Eclipse EE to build classes in WEB-INF/classes (or better approach)

The default for Eclipse EE seems to be to build java code in build/classes not in WEB-INF/classes or WEB-INF/lib/my.jar. I can create a .war file which has the entire project, but then every time I build, I have to manually generate the war file. My current setup which has the WebContents directory symbolic linked to /var/lib/tomcat7/webapps/ROOT, in which case all the web pages are by definition in the right place, but the code is not there.
I'm willing to take a suggestion on how to get this to happen automatically, but I would like to know WHY there should be the need in the first place? Why would I want to have my build directory for a web application anywhere other than the directory where it should be executed? Is there any way to get eclipse to build the !%*#% class files in a sane place, or is there in fact a reason why an EE app would have code that does not go on the server? Is there something simple that I can add to trigger a rule in ant or mvn to move the code to the right place?
Compounding this problem, I am switching over to Ubuntu (Not that this works under windows at the moment either).
I was getting weird errors, and it turns out I didn't have jdk7 installed.
So I installed it, but how do I even know what java is being used to run tomcat and eclipse? How do I know it will use jdk7 and not the one that was used before? On windows, when I tried to run Eclipse, it gave a straightforward error when Java wasn't installed so this never happened.
I type javac -version and get the correct one, but this does not guarantee that some service like tomcat7 will use the same one.
The error (same on Windows)
An error occurred at line: 3 in the jsp file: /demos/post.jsp
ReadBody cannot be resolved to a type
1: <%# page import="org.adastraeducation.liquiz.servlet.*" %>
2: <%
3: ReadBody b;
4: %>
5: <html>
6: <body>
The current (ridiculous) way to stop this error is:
cd build/classes
jar -cf my.jar org
sudo mv my.jar /var/lib/tomcat7/webapps/ROOT/WEB-INF/lib
sudo service tomcat7 restart
Eclipse Web Tools can manage building and packaging a web-app (WAR) and automatically running it on a local server of your choice. This includes re-deployment when changes are made, debugging, etc. But you have to create or configure your project as a Dynamic Web project for Eclipse to know to do that for you.
For starters, you'll need to either download the Eclipse IDE for Java EE Developers package or use the Eclipse Installer to get it. Then you can peruse the Web Tools help (for example, start here).

Is it possible to deploy JSF application on Bluemix?

I have installed IBM Bluemix tools on Eclipse and created a 'Hello World' JSF and EAR project. While creating I have chosen a Bluemix runtime environment. Now I try to deploy EAR from Eclipse, it successfully deployed and started but when I try to open it I get the following error:
Not Found The application or context root for this request has not been found: [Ljava.lang.Object;#bdb04149
What have I missed? Is there comprehensive tutorial to deploy Java EE web applications on Bluemix available anywhere?
You can deploy complete EAR files on Bluemix yes. Using the eclipse tools also makes it much easier. This link has steps on how you can do this https://www.ng.bluemix.net/docs/#manageapps/eclipsetools.html
Further down the page (you can use the menu on the left too) there are steps on how to push an EAR. It might be with pushing a complete Liberty profile to get finer control on the application behavior. This link has further details on pushing Liberty apps and the profile itself https://www.ng.bluemix.net/docs/#starters/liberty/index.html#liberty
If you deployed an EAR (containing your JSF app) you need to add the web module name to the URL, for example, if your project is called testJSF, your URL will look like this:
http://testApp.mybluemix.net/testJSF/
And of course, if your web page is not called index.xxx you need to add the web page name as well, for example:
http://testApp.mybluemix.net/testJSF/textPage.xhtml
or
http://testApp.mybluemix.net/testJSF/textPage.faces

how to put my java web application in a server?

I made a Java Web Application with Netbeans. I used JSF, PrimeFaces and the Glassfish Server. Now I want to put my application in a server but i just dont have idea of how to do that. I think fist of all have to install Glassfish in the server. How do I do that? The server i will be using has Windows Server 2008 Enterprise. Do I have to look for a .exe to install Glassfish? The same to do with Java? I have already done the connection to the SQL Server database so that part must work. So please explain me step by step what i have to have, how to install and configure everything and how to try if everything worked please.
Thanks for Your answers! :)
Depending on what your web application requires you will need to install more than just the glassfish server.
You need to install:
-Java jdk (required)
-Glassfish server (required)
-Database (if using one)
-Apache (if needed)
After you install everything, you need to deploy the war file of the application to the glassfish server. To do this you must first create a war file by 'cleaning and building' the app (option in netbeans). The war file will be located in one of the folders in the project.
Then you must log in to your glassfish admin console (located at http://localhost:4848 if run on localhost) and click on one of the options in the left menu that lets you manage the applications on the server. There will then be an option that lets you add war files to the server.

Tomcat 6, Primefaces, JSF

A very strange issue happening.
I have developed an application under JSF and Primefaces on tomcat 6 on my local computer. Everything works perfect.
But when I deploy the application on remote tomcat 6 (Under enterprise RedHat Linux), the primefaces stops working. The funniest part:
the response takes a lot of time, and it returns the generated html (so it seems like it calls the lifecycle). But no components are rendered (there is plain lot of html intermixed with javascript functions) - p:tabView and other components` contents are rendered as simple lines of text.
But as for the Javascript, it states - ReferenceError: PrimeFaces is not defined.
Catalina log file states nothing.
I have no idea what it can be. Is there any idea?
1) Check what dependencies your project has in eclipse build path. Verify all of them are available in your remote server . All the dependencies in build path should be copied to the lib folder in war file you are generating(unless they are runtime like tomcat,jdk etc).
2) Verify your web.xml and faces-config.xml is same in your eclipse and war deployed in remote.
If it doesn't work then you can compare the temp folder in your eclipse to the war you are deploying contains everything that is in local.
You can find your local war by searching for your project file in eclipse under your workspace
The problem was security for Tomcat. It did not allow any redirections so the js-files were listed in the links but nothing was fetched. Problem was solved by reinstalling tomcat.

dyploying javafx on web

I want to build set of tools for my team and they will be as part of JavaFX application for which GUI will be build with help of SCENE BUILDER. I have seen everything that was available but I need an example how to embed this type of application on the server from which it can be invoked somehow. Please help with examples and links. I'd like to make it look as this one. http://download.oracle.com/otndocs/products/javafx/2.2/samples/Ensemble/index.html
Thank you.
Place a copy of the jar, jnlp and html file output by the NetBeans JavaFX project build or JavaFX packaging tools deploy command into a directory of your webserver, then access the html file in your browser.
For example, let's say you called your application MyPowerApp and netbeans output MyPowerApp.html and you wanted to deploy that to a local Tomcat server:
Download and install a copy of Tomcat
Copy the jar, jnlp and html file into tomcat's webapps/ROOT directory.
Start tomcat.
Access your application via http://localhost:8080/MyPowerApp.html
The applet will start automatically and you can click on the link to launch the application via WebStart.
To update the application just rebuild it in NetBeans, copy it over into the tomcat webapps/ROOT directory and refresh your browser link (no need to restart Tomcat).
In practice you will want to modify the html rather than use the generated html to embed either the applet or WebStart link somewhere on your website (you won't need both execution modes in a single page like the Netbeans generated sample).
You may need to sign your application if it refers to needs permissions outside of the jnlp application sandbox.
To get the application to fill a browser window like Ensemble, it's height and width need to be set to 100% and the HTML page template modified to not have any page margins (view source on the Ensemble page for a sample).
You can include your fxml in your application jar and load it from there or you can load it off your server relative to your application deployment directory.
The information above is a variation of my forum answer on deploying JavaFX web applications to a server.
See the JavaFX deployment guide and Ensemble sample application source for more info.
deployment guide
deployment QuickStart
ensemble sample application
JavaFX sample application source at the JavaFX demos and samples link

Resources