Skip to main content

Is this JSF2 Bug or am i missing something with Annotations

8 replies [Last post]
userjava1
Offline
Joined: 2009-06-03

When JSF2 Managed Beans are packaged as a JAR and deployed along with different Project which has all the xhtmls i am getting error accessing the Managed beans with Annotations

Work around is removing annotations and adding the Managed Bean names in faces-config xml file, Can some one help me what i am missing. Is there any way in Java i can say to scan my jars?

Scenario I have is
--------------------------
test.jar (has all my Managed Beans with annotations)
testweb.war lib's folder has test.jar.

Thanks,
User.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ed Burns

>>>>> On Wed, 26 May 2010 20:11:37 PDT, webtier@javadesktop.org said:

UJ1> When JSF2 Managed Beans are packaged as a JAR and deployed along
UJ1> with different Project which has all the xhtmls i am getting error
UJ1> accessing the Managed beans with Annotations

UJ1> Work around is removing annotations and adding the Managed Bean
UJ1> names in faces-config xml file, Can some one help me what i am
UJ1> missing. Is there any way in Java i can say to scan my jars?

This does appear to be a bug. I have tested it and it seems to fail.

I have filed this bug.

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1693

With this email, I am also asking Ryan Lubke to comment on the bug and
assert that this feature did indeed work in the past but now appears to
be broken. If Ryan says, "this never worked and never was intended to
work", then it's not a bug but is a new feature request.

However, my understanding is that this *should* work.

Thanks,

Ed
--
| edburns... |
| homepage: | http://ridingthecrest.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

edburns
Online
Joined: 2004-02-11

Ryan asserted that this does work an that there is a testcase to prove it.

I have executed the testcase and it does indeed work.

Now I have to explain why my external testcase does not work.

Ed

edburns
Online
Joined: 2004-02-11

Ahh, this is probably not a bug, as Ryan asserted.

Spec section 11.5.1 states

"For every jar in the application's WEB-INF/lib directory, if the jar contains a META-INF/faces-config.xml file, or a file that matches the regular expression ".*\.faces-config.xml" (even an empty one) all classes in the jar must be scanned."

When I add a non-empty META-INF/faces-config.xml file it works. But when I add an empty one, I do get an execption on deployment.

I'll fix this under the auspices of the issue I opened on this thread.

Ed

Joel Weight

When using the annotations, do you still have a faces-config.xml file in
your test.jar file? I believe you need a faces-config file with the version
being 2.0 in the test.jar in order for jsf to scan it for annotated classes.

Joel

On Wed, May 26, 2010 at 9:11 PM, wrote:

> When JSF2 Managed Beans are packaged as a JAR and deployed along with
> different Project which has all the xhtmls i am getting error accessing the
> Managed beans with Annotations
>
> Work around is removing annotations and adding the Managed Bean names in
> faces-config xml file, Can some one help me what i am missing. Is there any
> way in Java i can say to scan my jars?
>
> Scenario I have is
> --------------------------
> test.jar (has all my Managed Beans with annotations)
> testweb.war lib's folder has test.jar.
>
> Thanks,
> User.
> [Message sent by forum member 'userjava1']
>
> http://forums.java.net/jive/thread.jspa?messageID=471620
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>
[att1.html]

userjava1
Offline
Joined: 2009-06-03

I did not have it earlier

I tried to put on the same place where my .class files are and repackaged my jar and war but still no luck.

The Page Showup but when i submit the page using h:command button i get this error

javax.el.PropertyNotFoundException: /message/greeting.xhtml @10,88 action="#{helloWorld.getUpdatedName}": Target Unreachable, identifier 'helloWorld' resolved to null

Joel Weight

your faces-config needs to be in the META-INF directory in your jar file.

Joel

On Wed, May 26, 2010 at 9:38 PM, wrote:

> I did not have it earlier
>
> I tried to put on the same place where my .class files are and repackaged
> my jar and war but still no luck.
>
> The Page Showup but when i submit the page using h:command button i get
> this error
>
> javax.el.PropertyNotFoundException: /message/greeting.xhtml @10,88
> action="#{helloWorld.getUpdatedName}": Target Unreachable, identifier
> 'helloWorld' resolved to null
> [Message sent by forum member 'userjava1']
>
> http://forums.java.net/jive/thread.jspa?messageID=471626
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>
[att1.html]

userjava1
Offline
Joined: 2009-06-03

Are you sure? I tried no luck. Did it work for you?

jdlee
Offline
Joined: 2006-01-25

I'm pretty sure that's right. You need META-INF/faces-config.xml, with at least the faces-config root element, with the version set to 2.0 in each jar you want scanned for annotations. If you have a faces-config.xml in your war, make sure the version is set to 2.0 as well.