Vraptor3 - Criação de objetos no startup [resolvido]

Atualizei hoje uma de minhas aplicações para o vraptor3.1. Como essas aplicações são muito robustas uso módulo EJB remoto e a camada web não possui conhecimento algum da camada de persistência. Ao inicializar a aplicação eis que noto o seguinte log.

SEVERE: Class [ Lorg/hibernate/SessionFactory; ] not found. Error while loading [ class br.com.caelum.vraptor.util.hibernate.SessionFactoryCreator ] WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: Lorg/hibernate/SessionFactory;

Estou usando Glassfish V3, e como uso JEE6 o vraptor já se configura automatico. Noto que o vraptor tenta inicializar uma session-factory por padrão.

Será que não é melhor o vraptor cuidar apenas dos componentes básicos para seu funcionamento e deixar esses componentes opcionais para carregar via alguma configuração?

Oi Garcia!

Ele so devia carregar o componente dele de Hibernate se alguem explicitasse. Algo esta errado entao. Voce pode lgiar o log no debug para a gente descobrir quando ele esta tentando carregar isso?

abracos

Paulo, qual é a category de logging usada pelo vraptor? Tentei colocar o br.caelum.vraptor e org.vraptor para FINEST só me aparece essa mensagem, nem mesmo o INFO está aparecendo.

Estou usando o SLF4J fazendo bridge para o JUL.

Ahh, mas tem um porém… agora que caiu minha ficha. O Vraptor não é inicializado em tempo de deploy, mas sim na primeira requisição web. Essa mensagem está aparecendo quando a aplicação é inicializa, ou seja, quando faço deploy do EAR.

SEVERE: Class [ Lorg/hibernate/SessionFactory; ] not found. Error while loading [ class br.com.caelum.vraptor.util.hibernate.SessionFactoryCreator ] WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: Lorg/hibernate/SessionFactory; INFO: Portable JNDI names for EJB EchoServiceImpl : [java:global/updater/updater-ejb/EchoServiceImpl!updater.model.service.EchoService, java:global/updater/updater-ejb/EchoServiceImpl] INFO: file:/opt/glassfishv3/glassfish/domains/domain1/eclipseApps/updater/updater-ejb_jar/_defaultPU login successful INFO: Loading application updater#updater-web.war at updater INFO: updater was successfully deployed in 5,055 milliseconds.

Quando faço a primeira requisição web aparece o log abaixo. Penso que como as mensagens estão antes do init do vraptor, parece não ser algo dele.

A estrutura que eu tenho é um projeto EAR, módulo ejb, ejb-cliente e módulo web, sendo que o módulo web só vê o ejb-cliente.

[code]
INFO: Scanning WEB-INF/classes: /opt/glassfishv3/glassfish/domains/domain1/eclipseApps/updater/updater-web_war/WEB-INF/classes

FINE: scanning []
FINE: Identified candidate component class: file [/opt/glassfishv3/glassfish/domains/domain1/eclipseApps/updater/updater-web_war/WEB-INF/classes/updater/web/EchoController.class]
INFO: Registering bundled converters
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.BigDecimalConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.BigIntegerConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.BooleanConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.ByteConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.CharacterConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.DoubleConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.EnumConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.FloatConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.IntegerConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.LocaleBasedCalendarConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.LocaleBasedDateConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.LongConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.PrimitiveBooleanConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.PrimitiveByteConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.PrimitiveCharConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.PrimitiveDoubleConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.PrimitiveFloatConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.PrimitiveIntConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.PrimitiveLongConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.PrimitiveShortConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.converter.ShortConverter
FINE: bundled converter to be registered: class br.com.caelum.vraptor.interceptor.multipart.UploadedFileConverter

FINE: scanning bean with type: class br.com.caelum.vraptor.http.ognl.EmptyElementsRemoval, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.route.PathAnnotationRoutesParser, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.core.DefaultConverters, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.ParanamerNameProvider, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.route.DefaultTypeFinder, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.core.DefaultRoutes, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.DefaultInterceptorRegistry, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.EncodingHandlerFactory, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.deserialization.XStreamXMLDeserializer, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.DefaultAcceptHeaderToFormat, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.route.NoRoutesConfiguration, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.route.DefaultRouter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.asm.AsmBasedTypeCreator, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.proxy.ObjenesisProxifier, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.deserialization.DefaultDeserializers, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.resource.DefaultResourceNotFoundHandler, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.multipart.DefaultMultipartConfig, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.resource.DefaultMethodNotAllowedHandler, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.DefaultTypeNameExtractor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.DefaultResourceTranslator, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.ioc.ResourceHandler, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.ioc.ConverterHandler, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.ioc.InterceptorStereotypeHandler, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.deserialization.DeserializesHandler, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.ioc.spring.StereotypedBeansRegistrar, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.ioc.spring.DefaultSpringLocator, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.config.ApplicationConfiguration, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.core.DefaultMethodInfo, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.InstantiateInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.serialization.xstream.XStreamXMLSerialization, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.DefaultPathResolver, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.download.DownloadInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.DefaultHttpResult, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.DeserializingInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.serialization.DefaultRepresentationResult, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.core.DefaultResult, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.InterceptorListPriorToExecutionExtractor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.FlashInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.DefaultStatus, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.DefaultRefererResult, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.multipart.MultipartInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.core.JstlLocalization, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.validator.DefaultOutjector, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.DefaultPageResult, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.DefaultFormatResolver, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.serialization.xstream.XStreamJSONSerialization, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.DefaultValidationViewsFactory, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.ParametersInstantiatorInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.EmptyResult, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.validator.DefaultValidator, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.http.ognl.OgnlParametersProvider, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.view.DefaultLogicResult, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.OutjectResult, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.extra.ForwardToDefaultViewInterceptor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.BigDecimalConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.BigIntegerConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.BooleanConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.ByteConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.CharacterConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.DoubleConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.EnumConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.FloatConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.IntegerConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.LocaleBasedCalendarConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.LocaleBasedDateConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.LongConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.PrimitiveBooleanConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.PrimitiveByteConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.PrimitiveCharConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.PrimitiveDoubleConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.PrimitiveFloatConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.PrimitiveIntConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.PrimitiveLongConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.PrimitiveShortConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.converter.ShortConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.interceptor.multipart.UploadedFileConverter, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.core.RequestInfo, to see if it is a component candidate
FINE: scanning bean with type: interface br.com.caelum.vraptor.http.MutableRequest, to see if it is a component candidate
FINE: scanning bean with type: interface br.com.caelum.vraptor.http.MutableResponse, to see if it is a component candidate
FINE: scanning bean with type: interface javax.servlet.http.HttpSession, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.core.DefaultRequestExecution, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.core.DefaultInterceptorStack, to see if it is a component candidate
FINE: scanning bean with type: class updater.web.EchoController, to see if it is a component candidate
FINE: Found resource: class updater.web.EchoController
FINE: Found parameter names with paranamer for public void updater.web.EchoController.now() as []
FINE: For /echo/now/ retrieved /echo/now/ with {}
INFO: /echo/now/ --> public void updater.web.EchoController.now()
FINE: Found parameter names with paranamer for public void updater.web.EchoController.echo() as []
FINE: For /echo/ retrieved /echo/ with {}
INFO: /echo/ --> public void updater.web.EchoController.echo()
FINE: Found parameter names with paranamer for public void updater.web.EchoController.who() as []
FINE: For /echo/who/ retrieved /echo/who/ with {}
INFO: /echo/who/ --> public void updater.web.EchoController.who()
FINE: scanning bean with type: class org.springframework.context.annotation.ConfigurationClassPostProcessor, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.ioc.spring.InjectionBeanPostProcessor, to see if it is a component candidate
FINE: scanning bean with type: class org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor, to see if it is a component candidate
FINE: scanning bean with type: class org.springframework.context.annotation.CommonAnnotationBeanPostProcessor, to see if it is a component candidate
FINE: scanning bean with type: class org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator, to see if it is a component candidate
FINE: scanning bean with type: class br.com.caelum.vraptor.reflection.CacheBasedTypeCreator, to see if it is a component candidate
INFO: VRaptor 3 successfuly initialized[/code]

o único jeito do vraptor tentar registrar o SessionFactoryCreator sem vc pedir é se vc colocou o package br.com.caelum.vraptor no base_packages… ou algo mto estranho está acontecendo…

Sim. O JUL possui os mesmos niveis de log do log4j, porém com nomes diferentes. DEBUG = FINEST.

Como estou usando JEE6 não configurei nada no web.xml. Apenas coloquei o jar do vraptor 3.1 e fiz o deploy. Mas note no meu relato acima que isso está acontecendo em tempo de deploy. Porém o vraptor só é inicializado após uma requisição. Está muito estranho isso.

acho que entendi o que está acontecendo…

primeiro uma pergunta: a aplicação inicia normalmente?

como o jar do vraptor está com a configuração do javaee6, o container lê todas as classes do jar procurando as anotações da Servlet 3.0… todas as classes inclui a SessionFactoryCreator, que depende da SessionFactory do hibernate…

se a aplicação inicia normalmente vc só tem que ignorar o erro… não sei se a gente tem como evitá-lo a menos que vc coloque os jars de todas as dependências diretas do vraptor no classpath

Lucas, pode ser isso sim. A aplicação inicializa normalmente, mesmo com esse log SEVERE. Acho que dá para ignorar isso mesmo. :slight_smile:

Abraços, e obrigado.