Problem with converting JSF1.2 applicationto JSF2.2 Glassfish deployment error: Exception while loading the app : CDI deployment failure:WELD-001408: - cdi

I am in the process of trying to convert a suite of applicationss from JSF1.2 to JSF2.2. I have successfully converted 2 but am having a problem with the third. When I try to deploy it to GlassFish 4.1, I get the following errors from the GF console:
Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Injector with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedMethod] #Inject public synchronized org.sonatype.guice.bean.locators.DefaultBeanLocator.add(Injector)
at org.sonatype.guice.bean.locators.DefaultBeanLocator.add(DefaultBeanLocator.java:0)
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Injector with qualifiers #Default
The program and its dependdencies are huge so I don't want to enter it all here, but here is the annotations I am using for the managed bean:
#ManagedBean(name="projectbean")
#SessionScoped
public class ProjectCreatorBean implements Serializable, ClientCreatorAware {
Any idea of what I should be looking for?This really has me stumped.
Thanks,
Mike

Related

How to inject FacesContext with JSF 2.3 and TomEE?

I've been trying to use JSF 2.3 with TomEE server and I'm having problems using the #Inject annotation with the FacesContext object.
When I use it, i get the following exception while starting my TomEE server:
SEVERE: CDI Beans module deployment failed
org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [javax.faces.context.FacesContext] is not found with the qualifiers
Qualifiers: [#javax.enterprise.inject.Default()]
Am I missing something?
Thanks.
Seems like some JSF2.3 features must be activated by setting the used JSF version.
Try setting JSF version by adding this empty class:
import javax.faces.annotation.FacesConfig;
/**
* The presence of the #FacesConfig annotation on a managed bean deployed within an application enables version specific
* features. In this case, it enables JSF CDI injection and EL resolution using CDI.
*
*/
#FacesConfig(version = FacesConfig.Version.JSF_2_3)
public class ConfigurationBean {
}
from https://github.com/javaee/glassfish/issues/22094

Inject an EJB into a JSF managed bean

I have a war application with some JSF managed beans and EJB for some business logic. I'm using JSF 1.2, JBoss 5 and java 1.6
My managed bean:
#ManagedBean(name = "managedBean")
#SessionScoped
public class MyManagedBean implements Serializable {
#EJB(mappedName = "ejbBean")
public MyEjbBean ejbBean;
....
}
EJB bean:
#Singleton(name = "ejbBean")
public class MyEjbBean {
....
}
Page not rendered, error:
javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: ejb not bound]
What am I doing wrong?
JBoss 5 doesn't support #Singleton EJB (added in EJB3.1 spec), you can use the JBoss #Service annotation to create a singleton.
See the instructions here.

Java EE 7 + GlassFish 4 - Run bean on startup

Using CDI is there a way to cause a bean to be instantiated when the application server starts up?
I would like to be able to do something like:-
#Singleton
#Startup
public class StartupBean {
...
}
Unfortunately, although the #Singleton annotation exists in the javax.inject.* package the #Startup annotation doesn't.
Use both of those from the javax.ejb.* package. EJBs support CDI and you can kick off anything you want.

Inject EJBs into a Seam Component

guys. I have a Seam project running on Tomcat 6.0.20 (webapp.war) and an EJB project running on JBoss 4.2.3 (ejbapp.ear).
I can access my EJBs in my Seam components using JNDI lookup [initialContext.lookup(...)].
I'd like to have them injected in my Seam components instead.
My Seam components ARE NOT EJBs, so I can't use #EJB annotation. I'd like to have something like this in my Tomcat (Web) app.
#Name("customerAction")
public class CustomerAction {
#In // even with (autoCreate=true) or the EJB name if necessary
private CustomerEJB customerEJB;
...
}
And this in the JBoss (EJB) app.
#Stateless(name="customerEJB")
public class CustomerEJBImpl implements CustomerEJB {
...
}
#Remote
public interface CustomerEJB {
...
}
In my components.xml I have the jndiPattern=ejbapp/#jndiPattern/remote specified just like I currently use to lookup the EJBs (ex: ejbapp/CustomerEJB/remote).
I'm probably missing something in my configuration to make this work.
PS: I'd like NOT HAVE to annotate my EJBs as #Name (Seam) components.
Any suggestions? Thanks in advance.
Thanks for your reply, but it didn't work.
When I declared the EJBs in components.xml, it did inject the object in my Action (Seam component), but as a POJO. I mean, the EntityManager and other EJB injections I had in the injected object didn't work.
I also tried to define the EJB as a Seam component, but, once they are in the webproject inside a JAR file, it didn't load automatically, and trying the scenario above, I got the same error.
Just an FYI, I also declared the Seam interceptor in ejb-jar.xml file.
I have no idea why this is happening, BTW I thought it would be quite a simple thing for Seam to handle.
Anyway..., any other suggestions, guys?
Define your EJB as Seam components in your components.xml

Seam - EJB3 in Web Module/WAR?

I'm writing an application using Seam 2.2.x which will be deployed on JBoss 5.1. I have an EJB module with all of the business logic en EJB's. However, I'd also like to have statless session EJBs in the web module to act as action classes. Is this possible? Do I need to perform any additional configuration to get this working? I have an interface I've defined:
#Local
public interface ContentItemSearchAction extends Serializable {
...
}
...and an implementing class...
#Name("contentItemSearchAction")
#AutoCreate
#Stateless
public class ContentItemSearchActionBean implements ContentItemSearchAction {
...
}
However, when I try to access the EJB in one of my JSF views, I get the following exception:
Caused by javax.naming.NameNotFoundException with message: "ContentItemSearchActionBean not bound"
Has anyone seen this before? What am I missing? Why is the EJB in my WAR module not being picked up?
EJBs do not go into WAR files. They're packaged into JARs, which go into the EAR along with the WAR.
The EJBs need not be in the WAR to be visible from your web tier.

Resources