Deploying JSF application on tomcat getting exception - jsf-2

When I'm deploying JSF2.0 application on tomcat6.0 I'm getting following exception:
com.sun.faces.lifecycle.ELResolverInitPhaseListener populateFacesELResolverForJsp
INFO: JSF1027: [null] The ELResolvers for JSF were not registered with the JSP c
ontainer.
I have included el-api2.2 and el-impl2.2 jar files in $TOMCAT_HOME/lib directory,as well as i have also included el-impl2.2.jar in my Project lib's folder.

I have included el-api2.2 and el-impl2.2 jar files in $TOMCAT_HOME/lib directory
Remove them. They don't belong there.
i have also included el-impl2.2.jar in my Project lib's folder.
If I guess right the concrete functional requirement which you didn't tell anything about, then you actually just want to get EL 2.2 to work on Tomcat 6.0. In that case, you should drop the mentioned JAR files in /WEB-INF/lib folder of your webapp and add the following entry to webapp's web.xml, assuming that you're indeed using Mojarra JSF implementation as hinted by the exception.
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>

Related

ASP.NET MVC project with a section written in Angular2: a build error occurs when using MvcBuildViews

Ok it could be a singular combination...
INTRODUCTION
I have an existing ASP.NET MVC 5 project.
It contains a private "Admin" area. I'm planning to change this area migrating it to Angular2 (+ WebAPI) :)
Due to some business requirements, I can't change the architecture of the original "Main" website (separating the Admin section into another website) so I must host inside it the new "Admin" area written in Angular2.
Main website url: http://www.example.com
Admin area url: http://www.example.com/admin
This is also true for the Visual Studio Project:
I created a folder "admin" and put all Angular2 stuff in it.
All works fine...
THE ISSUE
My ASP.NET project uses the MvcBuildViews parameter to build the MVC views on Release mode.
Now when I run the build in Release mode I receive this error:
\node_modules\selenium-webdriver\lib\test\data\web.config(29): error
ASPCONFIG: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS.
The error doesn't have sense for me...
MSBUILD has analyzed a web.config file inside the "node_modules".
The node_modules folder has been created in the project root folder after "npm install" (necessary to prepare angular2's stuff).
These folder should be ignored by msbuild... IMHO
HEY... node_modules IT IS NOT included in the VS project. MSBUILD is scanning the folder because it is only present inside the project...
WORKAROUNDS
Give up the MvcBuildViews... but I think this setting is very useful to detect errors during development phase
Hide the node_modules folder. This is the current workaround I'm using. I've added this pre-build event attrib +h "$(ProjectDir)node_modules"
Some other solution?
I've googled with no success...
I had the same issue recently. I found the solution to this issue in the following article:
Excluding node_modules folder from ASP.NET compilation
The article suggest to replace the AspNetCompiler task in your csproj for a direct call to aspnet_compiler.exe which support excluding folders. In the article, it does so by hardcoding the path to that .exe file. Which for most of the cases is Ok.
You may also use $(FrameworkDir) and $(FrameworkVersion) to avoid hardcoding the path or if you are unsure where the aspnet_compiler.exe may be:
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<Exec Command="$(FrameworkDir)\$(FrameworkVersion)\aspnet_compiler.exe -v temp -p $(WebProjectOutputDir) -x node_modules"/>
</Target>

Common Facelets files in shared library JAR outside /WEB-INF/lib

I have a common shared Library (that is setup as a Shared Library in Websphere Application server).
The folder structure of that jar is:
UtilityJAR
----src
-com
-test
-TestClass.java
---- META-INF
-resources
-template.xhtml
-css
-style.css
In my web Project, I have a template client file called User.xhtml that uses the template file from the above Shared Library using
ui:composition template="/template.xhtml"
When I have the above jar file in the WEB-INF/lib folder of the Web application, the application works fine without any issues (template.xhtml is recognized). When I remove the jar from the Lib folder of this application and put it as a Shared Library in Websphere (because I need this jar file from more than 4 applications and I don't want to copy this jar in all the 4 applications), I get the following error message.
[9/24/14 14:09:17:936 EDT] 00000113 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: java.io.FileNotFoundException: /template.xhtml Not Found in ExternalContext as a Resource
The Utility jar has faces-config in it and has #ManagedBean annotations that work when the jar is inside the application's WEB-INF/lib folder.
Anybody faced this problem before? thanks for your help.
Web fragment JARs containing webapp resources MUST be placed in webapp's /WEB-INF/lib.
From Servlet 3.0 specification page 37 (emphasis mine):
4.6 Resources
...
The getResource and getResourceAsStream methods take a String with a leading
“/” as an argument that gives the path of the resource relative to the root of the
context or relative to the META-INF/resources directory of a JAR file inside the
web application’s WEB-INF/lib directory. These methods will first search the root
of the web application context for the requested resource before looking at any of the
JAR files in the WEB-INF/lib directory. The order in which the JAR files in the
WEB-INF/lib directory are scanned is undefined. This hierarchy of documents may
exist in the server’s file system, in a Web application archive file, on a remote server,
or at some other location.
...
If you really want to place them elsewhere (bad idea!), then you'd need to homegrow a custom Facelets resource resolver. You can find a kickoff example here: How to create a modular JSF 2.0 application?
See also:
JSF facelets template packaging

cast error with addCallbackParam in primefaces

Using the requestContext demo example in my system
http://www.primefaces.org/showcase-labs/ui/requestContext.jsf
I am getting the following error
Caused by: java.lang.ClassCastException: org.primefaces.context.DefaultRequestContext cannot be cast to org.primefaces.context.RequestContext
at org.primefaces.context.RequestContext.getCurrentInstance(RequestContext.java:38) [primefaces-3.4.1.jar:]
the error occur when the java command running
RequestContext context = RequestContext.getCurrentInstance();
Using primefaces-3.4.1 under jboss seam 2.3.0.Final with Jboss AS 7.1
Amir
You've multiple different versioned PrimeFaces JAR files in your webapp's runtime classpath. For example, one PrimeFaces 3.3 and another PrimeFaces 3.4.1. They're conflicting with each other.
Cleanup the webapp's runtime classpath so that only the most recent version remains and this problem should disappear. Paths which are by default covered by the webapp's runtime classpath are the webapp's own /WEB-INF/lib folder, server's and/or JRE's own /lib and /lib/ext folders.
Update: another, actually more rare, cause is that you've multiple PrimeFaces JAR files of the same version which are loaded by different classloaders. The getClass() on the both classes would then never match the == check. You'd need to remove one of both.

JSF with External Resource Bundle

I'm doing a JSF 2.0 application on Tomcat 6.x. I have a resource bundle in different languages, is it possible to externalize the properties files outside the webapp?
For the moment I have this in my faces-config.xml:
<locale-config>
<default-locale>fr</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>es</supported-locale>
</locale-config>
<resource-bundle>
<base-name>front</base-name>
<var>messages</var>
</resource-bundle>
What should I do?
Thanks.
Yes, that's definitely possible. To the point, just put the files in the classpath. You can do that by placing it in any of existing paths covered by the webapp's runtime classpath, or by adding the new path to the webapp's runtime classpath.
You could add a new path to the classpath by specifying it in shared.loader of Tomcat's /conf/catalina.properties. Assuming that you've placed front*.properties files in /var/webapp/conf folder, then you need to specify the shared.loader as follows:
shared.loader = /var/webapp/conf
May be because of the spaces in the folder name; try to put the resource bundle file in another place, eg.: c:/temp/resources/

EJB calls from grails to glassfish

I need to use EJB remote calls from my grails application. For this in previouse Servlet application I used client glassfish jar(gf-client.jar) and is's worked.
How I can include gf-client.jar into build path in grails app for call EJB methodth?
thank you.
the answer was to copy all libraries of GlassFish application server to client mashine (directory with gf-client.jar and 2 levels up, check dependencies in gf-client.jar) and add only gf-client.jar to classpath of application. Ather dependencies will loaded automatically, when gf-client will loaded.
note 1: in my case for grails application witch I deploying to tomcat servlet container write full path to gf-client.jar to shared.loader section of catalina.properties file in conf dir, and restart tomcat.
note 2: for GlassFish v3.1 and up, replace gf-client.jar with gf-client-module.jar
Put gf-client.jar into the lib directory of your grails app. Any jar files in the lib directory of your grails app will automatically be included when you run your application as well as be packaged in generated war files.

Resources