C0deuniversal 13 de jun. de 2016
Poste as classes, qual o tipo de transação você está usando?
clebiovieira 13 de jun. de 2016
@Singleton
@Startup
public class SecurityInitializer {
@PersistenceContext
private EntityManager em ;
@PostConstruct
@Transactional
public void ini (){
Usuario usuario = new Usuario ();
usuario . setNome ( "Administrador Padrão" );
usuario . setTemplateSkin ( "skin-blue" );
em . persist ( usuario );
}
}
clebiovieira 13 de jun. de 2016
DETALHE DO ERRO:
14 : 18 : 40 , 303 ERROR [ org . jboss . msc . service . fail ] ( ServerService Thread Pool – 64 ) MSC000001 : Failed to start service jboss . deployment . unit . “ EnterpriseContactCenter . war ” . component . SecurityInitializer . START : org . jboss . msc . service . StartException in service jboss . deployment . unit . “ EnterpriseContactCenter . war ” . component . SecurityInitializer . START : java . lang . IllegalStateException : WFLYEE0042 : Failed to construct component instance
at org . jboss . as . ee . component . ComponentStartService $1 . run ( ComponentStartService . java : 57 )
at java . util . concurrent . Executors $RunnableAdapter . call ( Unknown Source )
at java . util . concurrent . FutureTask . run ( Unknown Source )
at java . util . concurrent . ThreadPoolExecutor . runWorker ( Unknown Source )
at java . util . concurrent . ThreadPoolExecutor $Worker . run ( Unknown Source )
at java . lang . Thread . run ( Unknown Source )
at org . jboss . threads . JBossThread . run ( JBossThread . java : 320 )
Caused by : java . lang . IllegalStateException : WFLYEE0042 : Failed to construct component instance
at org . jboss . as . ee . component . BasicComponent . constructComponentInstance ( BasicComponent . java : 163 )
at org . jboss . as . ee . component . BasicComponent . constructComponentInstance ( BasicComponent . java : 134 )
at org . jboss . as . ee . component . BasicComponent . createInstance ( BasicComponent . java : 88 )
at org . jboss . as . ejb3 . component . singleton . SingletonComponent . getComponentInstance ( SingletonComponent . java : 124 )
at org . jboss . as . ejb3 . component . singleton . SingletonComponent . start ( SingletonComponent . java : 138 )
at org . jboss . as . ee . component . ComponentStartService $1 . run ( ComponentStartService . java : 54 )
… 6 more
Caused by : javax . ejb . EJBException : org . jboss . weld . context . ContextNotActiveException : WELD - 001303 : No active contexts for scope type javax . enterprise . context . SessionScoped
at org . jboss . as . ejb3 . tx . CMTTxInterceptor . handleExceptionInOurTx ( CMTTxInterceptor . java : 187 )
at org . jboss . as . ejb3 . tx . CMTTxInterceptor . invokeInOurTx ( CMTTxInterceptor . java : 277 )
at org . jboss . as . ejb3 . tx . CMTTxInterceptor . requiresNew ( CMTTxInterceptor . java : 349 )
at org . jboss . as . ejb3 . tx . LifecycleCMTTxInterceptor . processInvocation ( LifecycleCMTTxInterceptor . java : 66 )
at org . jboss . invocation . InterceptorContext . proceed ( InterceptorContext . java : 340 )
at org . jboss . as . weld . injection . WeldInjectionContextInterceptor . processInvocation ( WeldInjectionContextInterceptor . java : 43 )
at org . jboss . invocation . InterceptorContext . proceed ( InterceptorContext . java : 340 )
at org . jboss . as . ejb3 . component . interceptors . CurrentInvocationContextInterceptor . processInvocation ( CurrentInvocationContextInterceptor . java : 41 )
at org . jboss . invocation . InterceptorContext . proceed ( InterceptorContext . java : 340 )
at org . jboss . as . ee . concurrent . ConcurrentContextInterceptor . processInvocation ( ConcurrentContextInterceptor . java : 45 )
at org . jboss . invocation . InterceptorContext . proceed ( InterceptorContext . java : 340 )
at org . jboss . invocation . ContextClassLoaderInterceptor . processInvocation ( ContextClassLoaderInterceptor . java : 64 )
at org . jboss . invocation . InterceptorContext . proceed ( InterceptorContext . java : 340 )
at org . jboss . invocation . InterceptorContext . run ( InterceptorContext . java : 356 )
at org . jboss . invocation . PrivilegedWithCombinerInterceptor . processInvocation ( PrivilegedWithCombinerInterceptor . java : 80 )
at org . jboss . invocation . InterceptorContext . proceed ( InterceptorContext . java : 340 )
at org . jboss . invocation . ChainedInterceptor . processInvocation ( ChainedInterceptor . java : 61 )
at org . jboss . as . ee . component . BasicComponent . constructComponentInstance ( BasicComponent . java : 161 )
… 11 more
Caused by : org . jboss . weld . context . ContextNotActiveException : WELD - 001303 : No active contexts for scope type javax . enterprise . context . SessionScoped
clebiovieira 13 de jun. de 2016
@Singleton
@Startup
public class SecurityInitializer {
@PersistenceContext
private EntityManager em ;
@PostConstruct
@Transactional
public void ini (){
Usuario usuario = new Usuario ();
usuario . setNome ( “ Administrador Padrão ” );
usuario . setTemplateSkin ( “ skin - blue ” );
em . persist ( usuario );
}
clebiovieira 15 de jun. de 2016
Pessoal, já resolvi.
Na verdade o erro estava sendo causado por um @EntityListeners (xxxx).
O que ocorre é que a minha estratégia era utiliza-lo como ser fosse uma auditoria.
O problema é que eu buscava o usuario logado na session ativa. Como no momento do start da aplicaçã
não há usuario logado e muito menos a session. Ele estava disparando a Exception que falei.
Um simples Try Catch resolveu minha dor de cabeça.