[
https://jira.jboss.org/browse/SEAMFACES-18?page=com.atlassian.jira.plugin...
]
Lincoln Baxter III commented on SEAMFACES-18:
---------------------------------------------
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
package org.jboss.seam.faces.util;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionTarget;
import javax.inject.Inject;
import org.jboss.seam.faces.component.FormValidationTypeOverrideExtension;
/**
* A utility providing common functions to simply use of {@link BeanManager}
*
* @author <a href="mailto:lincolnbaxter@gmail.com>Lincoln Baxter,
III</a>
*
*/
public class BeanManagerUtils
{
@Inject
private BeanManager manager;
@Inject
FormValidationTypeOverrideExtension classExtension;
/**
* Perform @{@link Inject} on an object as if it were a bean managed by CDI.
*
* @param instance
*/
@SuppressWarnings("unchecked")
public void injectNonContextualInstance(final Object instance)
{
if (instance != null)
{
CreationalContext<Object> creationalContext =
manager.createCreationalContext(null);
InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>)
manager.createInjectionTarget(getAnnotatedType(instance));
injectionTarget.inject(instance, creationalContext);
}
}
private AnnotatedType<? extends Object> getAnnotatedType(final Object instance)
{
AnnotatedType<?> result = null;
if (classExtension.hasOverriddenType(instance.getClass()))
{
result = classExtension.getOverriddenType(instance.getClass());
}
else
{
result = manager.createAnnotatedType(instance.getClass());
}
return result;
}
@SuppressWarnings("unchecked")
public <T> boolean isDependentScoped(final Class<T> type)
{
Bean<T> bean = (Bean<T>) manager.resolve(manager.getBeans(type));
if (bean != null)
{
return Dependent.class.equals(bean.getScope());
}
return false;
}
/**
* Get a single CDI managed instance of a specific class. Return only the
* first result if multiple beans are available.
*
* @param type The class for which to return an instance.
* @return The managed instance, or null if none could be provided.
*/
@SuppressWarnings("unchecked")
public <T> T getContextualInstance(final Class<T> type)
{
Bean<T> bean = (Bean<T>) manager.resolve(manager.getBeans(type));
if (bean != null)
{
CreationalContext<T> context = manager.createCreationalContext(bean);
T result = (T) manager.getReference(bean, type, context);
return result;
}
return null;
}
/**
* Get all CDI managed instances of a specific class. Return results in a
* {@link List} in no specific order.
*
* @param type The class for which to return instances.
*/
@SuppressWarnings("unchecked")
public <T> List<T> getContextualInstances(final Class<T> type)
{
List<T> result = new ArrayList<T>();
for (Bean<?> bean : manager.getBeans(type))
{
CreationalContext<T> context = (CreationalContext<T>)
manager.createCreationalContext(bean);
result.add((T) manager.getReference(bean, type, context));
}
return result;
}
}
NPE when deploying an app with Seam Faces
-----------------------------------------
Key: SEAMFACES-18
URL:
https://jira.jboss.org/browse/SEAMFACES-18
Project: Seam Faces
Issue Type: Bug
Components: JSF CDI Integration
Affects Versions: 3.0.0.Alpha2
Environment: Glassfish v3 on Fedora 12 with Sun Java 1.6 u20
Reporter: Brian Leathem
I've developed an app using custom @ViewScoped and @FlashScoped annotations (see:
http://github.com/verborghs/jsf-cdi). I swapped out the custom scope implementations with
ones from the Seam3 project (changing the import statements accordingly). On deploying
the app, I get the NPE below.
I'll work on creating a small test project to reproduce this error.
java.lang.NullPointerException
at org.jboss.weld.BeanManagerImpl.getReference(BeanManagerImpl.java:980)
at
org.jboss.seam.faces.util.BeanManagerUtils.getContextualInstance(BeanManagerUtils.java:69)
at
org.jboss.seam.faces.environment.SeamApplicationWrapper.createConverter(SeamApplicationWrapper.java:77)
at
com.sun.faces.facelets.tag.jsf.ConverterTagHandlerDelegateImpl.createConverter(ConverterTagHandlerDelegateImpl.java:148)
at
com.sun.faces.facelets.tag.jsf.ConverterTagHandlerDelegateImpl.applyAttachedObject(ConverterTagHandlerDelegateImpl.java:118)
at
javax.faces.view.facelets.FaceletsAttachedObjectHandler.applyAttachedObject(FaceletsAttachedObjectHandler.java:91)
at
com.sun.faces.facelets.tag.jsf.ConverterTagHandlerDelegateImpl.apply(ConverterTagHandlerDelegateImpl.java:73)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
com.sun.faces.facelets.tag.composite.ImplementationHandler.apply(ImplementationHandler.java:74)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
at
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:75)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:145)
at
com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyCompositeComponent(CompositeComponentTagHandler.java:342)
at
com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:179)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
com.sun.faces.facelets.tag.composite.ImplementationHandler.apply(ImplementationHandler.java:74)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
at
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:75)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:145)
at
com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyCompositeComponent(CompositeComponentTagHandler.java:342)
at
com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:179)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:97)
at
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:172)
at
com.sun.faces.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:386)
at
com.sun.faces.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:357)
at com.sun.faces.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:102)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at com.sun.faces.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:149)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
at
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:75)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:301)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:360)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:339)
at
com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:191)
at
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:149)
at
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
at
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:75)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:301)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:360)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:339)
at
com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:191)
at
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:149)
at
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
at
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:75)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:145)
at
com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:716)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira