You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Alan <om...@gmail.com> on 2010/10/18 17:54:21 UTC
Need help getting started with GlassFish, MyFaces, and Trinidad
I have been using GlassFish 3 to host a JSF 2.0 so far with some success,
but with no imported libraries. For some odd reason I can't seem to find
documentation that can get me started with MyFaces.
I added a Maven dependency as follows:
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl-ee6</artifactId>
<version>2.0.2</version>
<type>jar</type>
</dependency>
But I don't know what other steps to take, particularly with regard to
web.xml or faces-config.xml. The documentation I can find all seems
appropriate for MyFaces 1.x -- are all the setups the same?
Do I need to remove the dependencies on com.sun.faces? What about the
javax.faces.webapp.FacesServlet? Do I still use that or is it optional?
So far I can't get past the following error from
GlassFish: NoClassDefFoundError:
org/apache/myfaces/shared_impl/webapp/webxml/DelegatedFacesServlet
Any pointers much appreciated.
OO.
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Alan <om...@gmail.com>.
On Mon, Oct 18, 2010 at 12:53 PM, Jakob Korherr <ja...@gmail.com>wrote:
> [1] http://blogs.sun.com/theaquarium/entry/how_to_use_myfaces_with
>
>
Thanks a lot for this. I am not usually so clueless but the details kept
piling up to the point I thought I was drowning for a while there. I'm
going to give it a try now.
Regards,
A.
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Werner Punz <we...@gmail.com>.
Can you check your build, you might bundle mojarra as well as myfaces,
here is an excerpt of a sun-web.xml which works for me:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application
Server 9.0 Servlet 2.5//EN"
"http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
<context-root>/helloworld</context-root>
<class-loader delegate="false"/>
<property name="useMyFaces" value="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java
code.</description>
</property>
</jsp-config>
</sun-web-app>
but that does not help you you bundle both implementations in your ear
or war, it just overrides the one bundled with Glassfish.
Werner
Am 20.10.10 10:07, schrieb burghard.britzke:
> but even if I set those elements in my sun-web.xml, I get
>
> -->INFO: Mojarra 2.0.2 (FCS b10) für Kontext '/myapp' wird initialisiert.
> ...
> --> SCHWERWIEGEND: Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.
> ...
> INFO: Starting up MyFaces-package : myfaces-api in version : 2.0.2 from path : file:/Users/Shared/.../myapp/WEB-INF/lib/myfaces-api-2.0.2.jar
> INFO: Starting up MyFaces-package : myfaces-impl in version : 2.0.2 from path : file:/Users/Shared/.../myapp/WEB-INF/lib/myfaces-impl-2.0.2.jar
> ..
> INFO: ServletContext '/Users/Shared/glassfishv3/.../myapp/' initialized.
>
> what is wrong?
>
> burghard.
>
> Am 20.10.2010 um 09:51 schrieb Werner Punz:
>
>>> OK, thanks to Jakob's hints I got MyFaces-2 running under GlassFish. One
>>> thing that is essential (I am putting it here for reference) is the format
>>> of the sun-web.xml entry has to be:
>>>
>>> <property name="useMyFaces" value="true"/>
>>>
>>> Also you have to set:
>>>
>>> <class-loader delegate="false"/>
>>>
>>> I encountered something very disturbing when experimenting with this. In
>>> many cases something actually over-writes the sun-web.xml file when I try to
>>> run the application. It seems to happen somewhere in the deployment
>>> process. I don't know if this is a bug in netbeans or the MyFaces servlet
>>> is doing something. Has anyone else seen this?
>>
>
>
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by "burghard.britzke" <bu...@charmides.in-berlin.de>.
but even if I set those elements in my sun-web.xml, I get
-->INFO: Mojarra 2.0.2 (FCS b10) für Kontext '/myapp' wird initialisiert.
...
--> SCHWERWIEGEND: Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.
...
INFO: Starting up MyFaces-package : myfaces-api in version : 2.0.2 from path : file:/Users/Shared/.../myapp/WEB-INF/lib/myfaces-api-2.0.2.jar
INFO: Starting up MyFaces-package : myfaces-impl in version : 2.0.2 from path : file:/Users/Shared/.../myapp/WEB-INF/lib/myfaces-impl-2.0.2.jar
..
INFO: ServletContext '/Users/Shared/glassfishv3/.../myapp/' initialized.
what is wrong?
burghard.
Am 20.10.2010 um 09:51 schrieb Werner Punz:
>> OK, thanks to Jakob's hints I got MyFaces-2 running under GlassFish. One
>> thing that is essential (I am putting it here for reference) is the format
>> of the sun-web.xml entry has to be:
>>
>> <property name="useMyFaces" value="true"/>
>>
>> Also you have to set:
>>
>> <class-loader delegate="false"/>
>>
>> I encountered something very disturbing when experimenting with this. In
>> many cases something actually over-writes the sun-web.xml file when I try to
>> run the application. It seems to happen somewhere in the deployment
>> process. I don't know if this is a bug in netbeans or the MyFaces servlet
>> is doing something. Has anyone else seen this?
>
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Werner Punz <we...@gmail.com>.
Am 19.10.10 06:27, schrieb Alan:
> On Mon, Oct 18, 2010 at 12:53 PM, Jakob Korherr<ja...@gmail.com>wrote:
>
>>
>> You need to have myfaces-api and myfaces-impl dependencies in your
>> project like this:
>>
>>
> OK, thanks to Jakob's hints I got MyFaces-2 running under GlassFish. One
> thing that is essential (I am putting it here for reference) is the format
> of the sun-web.xml entry has to be:
>
> <property name="useMyFaces" value="true"/>
>
> Also you have to set:
>
> <class-loader delegate="false"/>
>
> I encountered something very disturbing when experimenting with this. In
> many cases something actually over-writes the sun-web.xml file when I try to
> run the application. It seems to happen somewhere in the deployment
> process. I don't know if this is a bug in netbeans or the MyFaces servlet
> is doing something. Has anyone else seen this?
>
Actually myfaces does not alter anything...
> Another thing I discovered is that when using MyFaces, the CDI services no
> longer work for managed beans. You have to use the
> @java.faces.bean.ManagedBean annotation. The @javax.enterprise.inject.Model
> annotation will not work. This is sort of a show-stopper for me since I
> have a fair amount of code that uses CDI now and I read that the faces
> annotations may end up deprecated. Is there any workaround on this or any
> word if this is going to be fixed?
>
Ok I am doing a wild guessing here, maybe you have to add an el resolver
entry for weld, I assume weld/cdi comes from the container and since
myfaces is hosted in your ear, some kind of auto configuration which
otherwise would be picked up is not in this case, due to the
classloading order and different jar locations.
It might either resolve itself by adding weld to your application as
dependency or even better try to locate the el resolver entry and add it
to your faces-config.xml
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Werner Punz <we...@gmail.com>.
Am 20.10.10 17:50, schrieb Alan:
> Does trinidad rely on MyFaces (which I don't have in this project) for this
> resource, or am I missing a filter in my configuration?
Actually I cannot help perse with the configuration, but Trinidad does
not rely on myfaces in anything, it is implementation independend.
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Alan <om...@gmail.com>.
On Tue, Oct 19, 2010 at 3:20 AM, Jakob Korherr <ja...@gmail.com>wrote:
>
> Great to here that the app is running now!
>
>
Thanks again. Now for my next trick ...
(I feel like one of those incompetent magicians where every part of the act
goes wrong.)
I now set up my project to use the Mojarra implementation and imported the
trinidad libraries. I was able to get a <tr:chart > tag to work first try
(the rabbit came out of the hat) but encountered a problem with the
<tr:inputDate> tag. The component renders properly but if you click on the
popup to get a calendar I get the error below instead of the calendar.
Does trinidad rely on MyFaces (which I don't have in this project) for this
resource, or am I missing a filter in my configuration?
An Error Occurred:
/__ADFv__.xhtml Not Found in ExternalContext as a Resource
Here is the section of web.xml I am using:
<!--To make Trinidad Work -->
<servlet>
<servlet-name>resources</servlet-name>
<servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>
</servlet>
<!-- This cannot be configured currently -->
<servlet-mapping>
<servlet-name>resources</servlet-name>
<url-pattern>/adf/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>trinidad</filter-name>
<filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>trinidad</filter-name>
<servlet-name>Fases Servlet</servlet-name>
</filter-mapping>
<!-- Trinidad prefers client-side state saving -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
Regards,
A.
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Alan <om...@gmail.com>.
On Tue, Oct 19, 2010 at 3:20 AM, Jakob Korherr <ja...@gmail.com>wrote:
>
> Those things you're encountering really seem like GlassFish (or
> NetBeans) bugs to me.
>
> Actually @Model really should work, because it is just a Stereotype
> for @Named @RequestScoped. My guess here is that GlassFish does not
> enable CDI correctly when running with MyFaces, because if you test
> @Model in Tomcat using MyFaces-2 and Apache OpenWebBeans it works
> fine!
>
> Regards,
> Jakob
>
>
Right you are. I had to go over to the Glassfish forum to learn this, but
as it turns out CDI does not work unless you have a beans.xml file -- even
if it has nothing in it.
A.
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Jakob Korherr <ja...@gmail.com>.
Hi Alan,
Great to here that the app is running now!
Those things you're encountering really seem like GlassFish (or
NetBeans) bugs to me.
Actually @Model really should work, because it is just a Stereotype
for @Named @RequestScoped. My guess here is that GlassFish does not
enable CDI correctly when running with MyFaces, because if you test
@Model in Tomcat using MyFaces-2 and Apache OpenWebBeans it works
fine!
Regards,
Jakob
2010/10/19 Alan <om...@gmail.com>:
> On Mon, Oct 18, 2010 at 12:53 PM, Jakob Korherr <ja...@gmail.com>wrote:
>
>>
>> You need to have myfaces-api and myfaces-impl dependencies in your
>> project like this:
>>
>>
> OK, thanks to Jakob's hints I got MyFaces-2 running under GlassFish. One
> thing that is essential (I am putting it here for reference) is the format
> of the sun-web.xml entry has to be:
>
> <property name="useMyFaces" value="true"/>
>
> Also you have to set:
>
> <class-loader delegate="false"/>
>
> I encountered something very disturbing when experimenting with this. In
> many cases something actually over-writes the sun-web.xml file when I try to
> run the application. It seems to happen somewhere in the deployment
> process. I don't know if this is a bug in netbeans or the MyFaces servlet
> is doing something. Has anyone else seen this?
>
> Another thing I discovered is that when using MyFaces, the CDI services no
> longer work for managed beans. You have to use the
> @java.faces.bean.ManagedBean annotation. The @javax.enterprise.inject.Model
> annotation will not work. This is sort of a show-stopper for me since I
> have a fair amount of code that uses CDI now and I read that the faces
> annotations may end up deprecated. Is there any workaround on this or any
> word if this is going to be fixed?
>
> Thanks for all the help.
>
> Regards,
>
> A.
>
--
Jakob Korherr
blog: http://www.jakobk.com
twitter: http://twitter.com/jakobkorherr
work: http://www.irian.at
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Alan <om...@gmail.com>.
On Mon, Oct 18, 2010 at 12:53 PM, Jakob Korherr <ja...@gmail.com>wrote:
>
> You need to have myfaces-api and myfaces-impl dependencies in your
> project like this:
>
>
OK, thanks to Jakob's hints I got MyFaces-2 running under GlassFish. One
thing that is essential (I am putting it here for reference) is the format
of the sun-web.xml entry has to be:
<property name="useMyFaces" value="true"/>
Also you have to set:
<class-loader delegate="false"/>
I encountered something very disturbing when experimenting with this. In
many cases something actually over-writes the sun-web.xml file when I try to
run the application. It seems to happen somewhere in the deployment
process. I don't know if this is a bug in netbeans or the MyFaces servlet
is doing something. Has anyone else seen this?
Another thing I discovered is that when using MyFaces, the CDI services no
longer work for managed beans. You have to use the
@java.faces.bean.ManagedBean annotation. The @javax.enterprise.inject.Model
annotation will not work. This is sort of a show-stopper for me since I
have a fair amount of code that uses CDI now and I read that the faces
annotations may end up deprecated. Is there any workaround on this or any
word if this is going to be fixed?
Thanks for all the help.
Regards,
A.
Re: Need help getting started with GlassFish, MyFaces, and Trinidad
Posted by Jakob Korherr <ja...@gmail.com>.
Hi Alan,
You need to have myfaces-api and myfaces-impl dependencies in your
project like this:
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>2.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>2.0.2</version>
<scope>runtime</scope>
</dependency>
You don't need myfaces-impl-ee6, this one is just an internal helper
module which is already included in myfaces-impl.
The rest of the configuration (e.g. FacesServlet) is pretty much the
same as for Mojarra, though you need some extra configuration to run
MyFaces on GlassFish, see [1|.
Regards,
Jakob
[1] http://blogs.sun.com/theaquarium/entry/how_to_use_myfaces_with
2010/10/18 Alan <om...@gmail.com>:
> I have been using GlassFish 3 to host a JSF 2.0 so far with some success,
> but with no imported libraries. For some odd reason I can't seem to find
> documentation that can get me started with MyFaces.
>
> I added a Maven dependency as follows:
>
> <dependency>
> <groupId>org.apache.myfaces.core</groupId>
> <artifactId>myfaces-impl-ee6</artifactId>
> <version>2.0.2</version>
> <type>jar</type>
> </dependency>
>
> But I don't know what other steps to take, particularly with regard to
> web.xml or faces-config.xml. The documentation I can find all seems
> appropriate for MyFaces 1.x -- are all the setups the same?
>
> Do I need to remove the dependencies on com.sun.faces? What about the
> javax.faces.webapp.FacesServlet? Do I still use that or is it optional?
>
> So far I can't get past the following error from
> GlassFish: NoClassDefFoundError:
> org/apache/myfaces/shared_impl/webapp/webxml/DelegatedFacesServlet
>
> Any pointers much appreciated.
>
> OO.
>
--
Jakob Korherr
blog: http://www.jakobk.com
twitter: http://twitter.com/jakobkorherr
work: http://www.irian.at