Can EL 2.2 capable JSF web applications be deployed to shared Tomcat 6 hosting environment? - jsf-2

I know that by replacing the el-api.jar in the lib folder of the Tomcat 6 directory with an EL 2.2 capable version that it is possible to utilize the power of EL 2.2 in Tomcat 6. See the following questions:
http://code2inspire.wordpress.com/2010/11/05/how-to-enable-el-2-2-on-tomcat-6/
http://www.javaplex.com/blog/for-jsf-2-how-to-enable-el-2-2-on-tomcat-6/
I have an app that I need to deploy for a public facing site and I want to do it as cheaply as possible. The best bargain for me would be to go with a Shared Tomcat hosting provider where you share a Tomcat instance with others, however the one I talked to doesn't offer Tomcat 7 environments.
It would be a lot more expensive and time consuming for me to setup a VPS to do this, so I was wondering if there is anyway I can swing this on Tomcat 6 without the ability to modify the lib directory?

Use JBoss EL instead. It is EL 2.1 based, but offers the same enhancements as done in EL 2.2. Drop jboss-el.jar in /WEB-INF/lib and add the following to the web.xml:
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
No need to modify Tomcat's /lib. You only need to ensure that you're using Facelets instead of JSP.

Related

How to deploy multiple Grails 3.x applications in Tomcat 8 with shared jars?

I want to deploy few Grails 3.x web applications in Tomcat 8 with all commons jars in a tomcat/shared/lib directory.
Found similar question How to deploy multiple applications in Tomcat, share jars and have different datasources? but this is having information about Grails 1.x and 2.x versions?
Can someone help me with Grails 3.x and Tomcat 8+ versions?
With lot of research, I finally found a way to have shared libraries for Grails 3 app deployment on Tomcat 8.5.x.
I have explored the resources element in Tomcat context.xml and where we can add external Jars to webapp classloader using JarResources tag. This way we can have all jars in one shared location and all applications having them in webapp class loader.
https://tomcat.apache.org/tomcat-8.5-doc/config/resources.html - Follow this link for more info.

How to correctly export a JSF 2.0 web application into war?

I have a JSF 2.0 web project and I use Glassfish 3.1.2 server. In this project, I have among other things :
a class called AjaxServlet annotated with #javax.servlet.annotation.WebServlet
a class called Session annotated with #javax.ejb.Stateful
When I deploy this project to Glassfish from eclipse, everything runs perfectly : in the administration console of Glassfish, the engines associated with the application are [ejb, jpa, web, weld]. But when I first export the project as a war, then from the admin console I deploy the war, the application doesn't work : the engines associated to the application are then [web] only.
How can I export an application to a war without loosing any information (all the engines)? I didn't declare my Servlet in web.xml because in JSF 2.0, we don't need that: the annotations are enough. Does anyone have an idea about what is going on here? I'm quite sure it is not a problem of Glassfish distributions (Web Profile Vs Full Platform) as the same Glassfish server is used for the 2 scenarios above.
Note for those who erroneously think my question is off-topic : Jsf is a framework for programming Java EE web applications. war is a way to package a Jsf application, in the same as jar is a way to package java classes. So my question is totally a programming topic! It is totally legitimate to have it here in StackOverflow. If exporting JSF application into war is not a programming issue, then compiling java classes into .class should not be a programming topic neither! So Pleaze don't downgrade for this reason!
You have to understand the difference between your eclipse environment and your glassfish environment. Not all your libraries that are available in eclipse might be included in your external environment. There are cases where programs compile in eclipse, but not when run from console.
Here's a tip:
Right click on project -> Navigate to Properties > Java Build Path > Order and Export, and ensure that all libraries you require are going to be exported.

Why to use JBoss for Grails deployment?

I'm working on the project that uses Grails as Web framework and JBoss for deploying web-applications. JBoss allows to configure connection to database and then Grails could use JNDI datasource. However in our project we don't use JNDI datasources, we configure data sources for both development and production in DataSource.groovy. Other JBoss services are not used also.
I understand that if we are using JNDI datasource connections then we may benefit if several grails applications are deployed, because in this case there is no need for each grails application to establish its own connection.
So I wonder is there any sense to use JBoss instead of, say, Tomcat or Jetty, if not using it's services?
JBoss is a J2EE container. Compared to Tomcat which is a Servlet and JSP container only, the JBoss AS has a lot more features. Thus JBoss is also "heavier" than Tomcat, and depending on the size of your project this may not fit well with your development team since it has a longer development cycle (I heard there were a lot of improvements in JBoss 7, haven't tried it yet though.)
If you are not using any of the J2EE container features (JMS, EJB, etc.) then you could be fine going with Tomcat using a grails application. We use Tomcat at work for hosting one of our web applications.
In regards to connection pooling managed by JBoss, Tomcat can also do that. Take a look at this documentation page. Hope this helps.

Remove JSF completely from JBoss 6 or from Glassfish 3?

I have a JSF Mojarra 2.0.3 app that was developed entirely on Tomcat 7 where it works superbly. I need to deploy this application on JBoss or on Glassfish and the application runs but in some parts behaves strangely. On both JBoss 6 and on Glassfish 3 this exact same bizarre behavior occurs.
I believe this happens for a number of reasons:
1) These app servers have their own version of Mojarra JSF bundled within them and these are being used in lieu of the Mojarra 2.0.3 I have in the applications web_inf/lib folder.
2) I am using a third party rich control toolkit that is probably behaving strangely because it expects this specific version of Mojarra (2.0.3 to be exact).
Bottom line is, I am floundering in every attempt to surgically remove JSF from one of these app servers because I strongly suspect this is the reason why these app servers behave differently from Tomcat, which does not have JSF joined at the hip.
Due to client prejudices and inhouse expertise, JBoss is required to host on production so using Tomcat in production is not an option.
Help?
I'm not sure where the libs are in JBoss(simple Google might tell you) but in Glassfish you'll just want to replace the JSF 2.0 jars. They are located in .
install directory\glassfish\modules
Just replace the jsf-api and jsf-impl with the ones you used in the Tomcat version. Then you'll be on the same page.

New URLStreamHandlers in glassfish

I have a legacy application that I'm trying to port to Java EE. Presently this application calls URL.setURLStreamHandlerFactory() to register some custom URL protocol handlers. This call fails under Glassfish v 2.1 and 3 because glassfish has already registered a factory.
I've tried using the java.protocol.handler.pkgs system property, but that doesn't work for me due to classloader issues. The handler classes are all part of the application and I'm not keen on trying to extract them and put a jar in the container's classpath.
I've got a whiff of osgi bundles - apparently I could write a Bundle that'll deal with the new protocols. I'm not keen on making this web application an osgi bundle (one step at a time! EE first, then osgi if the need arises).
Is it possible to pop a bundle jar in to my WEB-INF/lib directory and have Glassfish load it as a bundle? The bundle will need to import packages from the web applications (another jar in WEB-INF/lib or in WEB-INF/classes). I'm willing to package this app as an EAR if that'll work, I just can't justify osgifying the entire application without knowing more.
I've solved my issue. Apparently I had some wires crossed as the java.protocol.handler.pkgs system property works fine.
For any one else tripping up, I put a jar with my handlers in $DOMAINDIR/lib/ext/ as well as in my WAR's WEB-INF/lib directory. In my application's configuration I've also put a jvm option -Djava.protocol.handler.pkgs=my.handlers.pkg.prefix
I've noticed in glassfish 2.1 it works without the jvm option if I put the prefix in to some startup code, but in glassfish 3 the jvm option is necessary because felix (the osgi implementation glassfish is using) only consults the property upon the server startup, not for each request.

Resources