users@glassfish.java.net

Weld issue (migrating from GF 3.0.1 to 3.1) Unsatisfied dependencies for type [HttpSession]

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Wed, 19 Jan 2011 21:13:49 +0100

Hi there,
I have application which deploys and runs fine on Glassfish 3.0.1. I
am investigating a migration to a new version of Glassfish and found
an issue.
The problem is:

Error occurred during deployment: Exception while loading the app :
WELD-001408 Unsatisfied dependencies for type [HttpSession] with
qualifiers [@Default] at injection point [[parameter 1] of [method]
@Produces @Dependent public
pl.assetwell.demo.service.impl.WebUserProvider.currentUser(HttpSession)].

The WebUserProvider:

@ApplicationScoped
public class WebUserProvider {
        @Produces
        @Dependent
        public WebUser currentUser(HttpSession httpSession) {
                return (WebUser) httpSession.getAttribute("user");
        }
}

And in my business logic, when I need user, I use the above like this:

@Inject Instance<WebUser> webUserProvider;
[...]
WebUser user = webUserProvider.get();


At the beginning, I wanted to inject WebUser directly into my business
logic beans, allowing CDI to proxy it, so I wouldn't need to manually
pull the instance from Instance<WebUser>, but unfortunately Weld
complained it cannot proxy my WebUser class. I worked it around, but
the new problem with HttpSession being an unsatisfied dependency seems
to be a major problem to me. It seems strange that it works with Weld
used in GF 3.0 and stops working in GF 3.1.
Can you help me with this issue? Is this a bug?

Thanks,
Witold Szczerba