VRaptor com JPA

Bom dia, estou com uma dúvida. Acabei de concluir a apostila FJ28 da Caelum e está funcionando tudo corretamente. Quero usar VRaptor em um novo projeto que estou criando, porém antes estou tentando migrar a aplicação criada na FJ28 para JPA.

Estou usando JBOSS 7.1, e já adicionei no web.xml as configurações do VRaptor para utilizar jpa. Também já configurei o driver no JBoss como diz aqui (http://filosofisto.wordpress.com/2012/02/13/configurando-mysql-no-jboss-7-as/), porém, ainda estou com o erro abaixo, esqueci de algo?

10:24:32,175 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-4) HHH000102: Fetching database metadata 10:24:32,176 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-4) HHH000319: Could not get database metadata: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/fj28

o jar do driver do mysql está no classpath?

Está sim, até baixei esse (http://www.wbotelhos.com/2010/02/23/jpa-e-vraptor-3) projeto para testar e mesmo assim não rolou. Configurei o mysql nos modules do JBoss também.

vc colocou no WEB-INF/lib da aplicação?

tentou colocar na pasta lib do jboss?

tentou configurar um DataSource no jboss e apontar direto pra ele?

[quote=Lucas Cavalcanti]vc colocou no WEB-INF/lib da aplicação?

tentou colocar na pasta lib do jboss?

tentou configurar um DataSource no jboss e apontar direto pra ele?[/quote]

  1. SIM

  2. Então, criei a seguinte estrutura: JBOSS_HOME/modules/com/mysql/main/ e dentro:
    mysql-connector-java-5.1.14-bin.jar
    module.xml

<module xmlns="urn:jboss:module:1.1" name="com.mysql"> <resources> <resource-root path="mysql-connector-java-5.1.14-bin.jar" /> </resources> <dependencies> <module name="javax.api" /> <module name="javax.transaction.api" /> <module name="javax.servlet.api" optional="true" /> </dependencies> </module>
E no standalone.xml configurei o driver:

<driver name="mysql" module="com.mysql"> <xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class> </driver>
persistence.xml

[code]<?xml version="1.0" encoding="UTF-8"?>

org.hibernate.ejb.HibernatePersistence
	<properties>
		<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
		<property name="hibernate.connection.username" value="root" />
		<property name="hibernate.connection.password" value="" />
		<property name="hibernate.connection.url" value="jdbc:mysql://localhost/fj28" />
		<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />

		<property name="hibernate.hbm2ddl.auto" value="update" />
	</properties>
</persistence-unit>

[/code]

  1. SIM

como vc fez a configuração do dataSource?

Agora estou tentando sem o DS mesmo, mas já tentei com ele, você acha que pode ser isso? Pq pelo erro sei lá, parece que o JBoss 7 não está encontrado o jar que mapeei nos drivers, se eu usar o hibernate.cfg funciona normal, mas acho que nesse caso ele usa o jar do classpath e no JPA mesmo com o jar lá, ele deve estar tentando usar o driver que mapeei

se estivesse usando o jar não ia dar o erro de no suitable driver…

seu jboss não está identificando esse jar por algum motivo…

tenta ver algum tutorial de como configurar um datasource mysql no jboss 7 e aponte no persistence.xml pra ele (via … ou )

Vou dar uma olhada nisso e depois volto a postar aqui qualquer coisa. Obrigado Lucas

Vc tem que criar um módulo.

Aqui mostra como criar módulos com postgres e mysql utilizando o JBoss: Aplicação Web Completa JSF EJB JPA JAAS.

Pessoal, parece que consegui a parte do driver, pelo menos agora mudou o erro e acredito ser algo do VRaptor agora:

[code]14:25:59,628 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-7) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
14:25:59,630 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-7) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
14:25:59,631 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-7) HHH000397: Using ASTQueryTranslatorFactory
14:25:59,636 INFO [org.hibernate.cache.spi.UpdateTimestampsCache] (MSC service thread 1-7) HHH000250: Starting update timestamps cache at region: org.hibernate.cache.spi.UpdateTimestampsCache
14:25:59,638 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-7) Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@26b20a31: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,validatorFactoryCreator,paranamerNameProvider,noRoutesConfiguration,defaultResourceNotFoundHandler,encodingHandlerFactory,defaultMultipartConfig,defaultConverters,topologicalSortedInterceptorRegistry,defaultRouter,defaultTypeNameExtractor,defaultRoutes,defaultMethodNotAllowedHandler,objenesisProxifier,JSR303ValidatorFactory,defaultDeserializers,defaultResourceTranslator,pathAnnotationRoutesParser,defaultAcceptHeaderToFormat,hibernateProxyInitializer,interceptorListPriorToExecutionExtractor,defaultRestDefaults,defaultTypeFinder,messageInterpolatorFactory,XStreamXMLDeserializer,defaultInterceptorHandlerFactory,stereotypeHandler,converterHandler,interceptorStereotypeHandler,deserializesHandler,stereotypedBeansRegistrar,defaultSpringLocator,jsonDeserializer,defaultValidator,defaultRefererResult,defaultStatus,JSR303Validator,XStreamJSONPSerialization,defaultLogicResult,deserializingInterceptor,emptyElementsRemoval,replicatorOutjector,defaultExceptionMapper,defaultRepresentationResult,resourceLookupInterceptor,outjectResult,HTMLSerialization,defaultServletFileUploadCreator,XStreamXMLSerialization,defaultRestHeadersHandler,applicationConfiguration,defaultFormatResolver,executeMethodInterceptor,defaultResult,downloadInterceptor,defaultPathResolver,ognlParametersProvider,defaultMethodInfo,defaultPageResult,flashInterceptor,jstlLocalization,defaultValidationViewsFactory,defaultHttpResult,parametersInstantiatorInterceptor,commonsUploadMultipartInterceptor,XStreamJSONSerialization,exceptionHandlerInterceptor,forwardToDefaultViewInterceptor,instantiateInterceptor,emptyResult,uploadedFileConverter,primitiveBooleanConverter,localeBasedCalendarConverter,byteConverter,primitiveShortConverter,enumConverter,primitiveByteConverter,booleanConverter,primitiveFloatConverter,doubleConverter,integerConverter,localeBasedDateConverter,floatConverter,primitiveIntConverter,shortConverter,primitiveLongConverter,bigIntegerConverter,bigDecimalConverter,longConverter,stringConverter,characterConverter,primitiveCharConverter,primitiveDoubleConverter,VRaptorRequestProvider,httpServletRequestProvider,httpServletResponseProvider,httpSessionProvider,enhancedRequestExecution,defaultInterceptorStack,org.springframework.aop.config.internalAutoProxyCreator,carrinhoController,entityManagerCreator,usuarioWeb,produtoDao,entityManagerFactoryCreator,carrinho,JPATransactionInterceptor,produtosController,criadorDeSessionFactory,criadorDeSession,mundo,usuariosController,usuarioDao,autenticacaoInterceptor]; root of factory hierarchy
14:25:59,644 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/projetoweb]] (MSC service thread 1-7) Exception starting filter vraptor: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactoryCreator’: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) [org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.start(SpringBasedContainer.java:106) [vraptor-3.3.1.jar:]
at br.com.caelum.vraptor.ioc.spring.SpringProvider.start(SpringProvider.java:87) [vraptor-3.3.1.jar:]
at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:110) [vraptor-3.3.1.jar:]
at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:103) [vraptor-3.3.1.jar:]
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_37]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_37]
at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_37]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at br.com.caelum.vraptor.util.jpa.EntityManagerFactoryCreator.create(EntityManagerFactoryCreator.java:41) [vraptor-3.3.1.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [classes.jar:1.6.0_37]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [classes.jar:1.6.0_37]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [classes.jar:1.6.0_37]
at java.lang.reflect.Method.invoke(Method.java:597) [classes.jar:1.6.0_37]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:340) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:293) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130) [org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
… 24 more
Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]
at org.hibernate.cache.internal.NoCachingRegionFactory.buildTimestampsRegion(NoCachingRegionFactory.java:81) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cache.spi.UpdateTimestampsCache.(UpdateTimestampsCache.java:63) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:470) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
… 36 more

14:25:59,672 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-7) Error filterStart
14:25:59,672 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-7) Context [/projetoweb] startup failed due to previous errors
14:25:59,687 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.web.deployment.default-host./projetoweb: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./projetoweb: JBAS018040: Failed to start context
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_37]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_37]
at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_37]

14:25:59,895 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment “projetoweb.war” was rolled back with failure message {“JBAS014671: Failed services” => {“jboss.web.deployment.default-host./projetoweb” => “org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./projetoweb: JBAS018040: Failed to start context”}}
14:25:59,935 INFO [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011403: Stopping Persistence Unit Service 'projetoweb.war#default’
14:25:59,939 INFO [org.jboss.as.clustering.infinispan] (MSC service thread 1-4) JBAS010282: Stopped projetoweb.war#default.org.hibernate.cache.internal.StandardQueryCache cache from hibernate container
14:25:59,942 INFO [org.jboss.as.clustering.infinispan] (MSC service thread 1-4) JBAS010282: Stopped projetoweb.war#default.org.hibernate.cache.spi.UpdateTimestampsCache cache from hibernate container
14:26:08,215 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment projetoweb.war in 8319ms
14:26:08,216 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.web.deployment.default-host./projetoweb: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./projetoweb: JBAS018040: Failed to start context

14:26:08,217 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {“JBAS014653: Composite operation failed and was rolled back. Steps that failed:” => {“Operation step-2” => {“JBAS014671: Failed services” => {“jboss.web.deployment.default-host./projetoweb” => “org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./projetoweb: JBAS018040: Failed to start context”}}}}[/code]

No web.xml eu configurei:

<context-param> <param-name>br.com.caelum.vraptor.packages</param-name> <param-value>br.com.caelum.vraptor.util.jpa</param-value> </context-param>

Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]

ainda é do hibernate… provavelmente vc tá usando @Cache sem ter habilitado

Obrigado pessoal, deu certo a parte do mysql.

Lucas, uma dúvida, escrevi os Daos com JPA e aparentemente tudo ok, porém qdo tento acessar algum método que utilizará o dao, ocorre o seguinte erro:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'produtosController': Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.caelum.goodbuy.dao.ProdutoDao]: : Error creating bean with name 'produtoDao': Unsatisfied dependency expressed through constructor argument with index 0 of type [javax.persistence.EntityManager]: : Error creating bean with name 'br.com.caelum.vraptor.util.jpa.EntityManagerCreator': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerCreator': Invocation of init method failed; nested exception is java.lang.NullPointerException; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'br.com.caelum.vraptor.util.jpa.EntityManagerCreator': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerCreator': Invocation of init method failed; nested exception is java.lang.NullPointerException; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'produtoDao': Unsatisfied dependency expressed through constructor argument with index 0 of type [javax.persistence.EntityManager]: : Error creating bean with name 'br.com.caelum.vraptor.util.jpa.EntityManagerCreator': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerCreator': Invocation of init method failed; nested exception is java.lang.NullPointerException; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'br.com.caelum.vraptor.util.jpa.EntityManagerCreator': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerCreator': Invocation of init method failed; nested exception is java.lang.NullPointerException org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:730) org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:329) org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:263) org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.instanceFor(SpringBasedContainer.java:86) br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:46) br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54) br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54) br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69) br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54) br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54) br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23) br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92) br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58) br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)

Veja meu ProdutoDao

[code]@Component
public class ProdutoDao {

private EntityManager manager;
private EntityTransaction utx;

public ProdutoDao(EntityManager manager) {
	this.manager = manager;
	this.utx = manager.getTransaction();
}

@SuppressWarnings("unchecked")
public List<Produto> listaTudo() {
	// return session.createCriteria(Produto.class).list();
	try {
		Query query = manager.createQuery("select * from produto");
		return query.getResultList();
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}[/code]

vc tá usando o entityManagerCreator do VRaptor, certo?

dá uma olhada na inicialização do sistema, deve ter dado alguma exception.

Esse entityManagerCreator é gerenciado pelo VRaptor apenas utilizando a configuração abaixo no web.xml ?

<context-param> <param-name>br.com.caelum.vraptor.provider</param-name> <param-value>br.com.caelum.vraptor.util.jpa.JPACustomProvider</param-value> </context-param>
No log do JBoss não deu nenhum erro não, esse erro ocorre qdo a aplicação tenta acessar o ProdutoDao.

15:36:46,348 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA 15:36:46,544 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA 15:36:46,585 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting 15:36:47,351 INFO [org.xnio] XNIO Version 3.0.3.GA 15:36:47,351 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http) 15:36:47,361 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA 15:36:47,369 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA 15:36:47,382 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers 15:36:47,385 INFO [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem 15:36:47,391 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem. 15:36:47,402 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem 15:36:47,407 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem 15:36:47,420 INFO [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem 15:36:47,441 INFO [org.jboss.as.security] (MSC service thread 1-6) JBAS013100: Current PicketBox version=4.0.7.Final 15:36:47,444 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension 15:36:47,454 INFO [org.jboss.as.connector] (MSC service thread 1-8) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final) 15:36:47,520 INFO [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service 15:36:47,531 INFO [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default] 15:36:47,623 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 15:36:47,637 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services - Stack CXF Server 4.0.2.GA 15:36:47,650 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1) 15:36:47,805 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-7) Starting Coyote HTTP/1.1 on http--192.168.0.100-8080 15:36:48,146 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS] 15:36:48,149 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) JBAS015012: Started FileSystemDeploymentService for directory /Programas/jboss-as-7.1.1.Final/standalone/deployments 15:36:48,157 WARN [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015002: Deployment of 'goodbuy.war' requested, but the deployment is not present 15:36:48,158 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found projetoweb.war in deployment directory. To trigger deployment create a file called projetoweb.war.dodeploy 15:36:48,164 INFO [org.jboss.as.remoting] (MSC service thread 1-6) JBAS017100: Listening on /192.168.0.100:4447 15:36:48,164 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:9999 15:36:48,166 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:/TESTE_MYSQL] 15:36:48,274 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "projetoweb.war" 15:36:49,734 INFO [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for default 15:36:50,331 INFO [org.jboss.as.jpa] (MSC service thread 1-5) JBAS011402: Starting Persistence Unit Service 'projetoweb.war#default' 15:36:50,423 INFO [org.hibernate.annotations.common.Version] (MSC service thread 1-5) HCANN000001: Hibernate Commons Annotations {4.0.1.Final} 15:36:50,427 INFO [org.hibernate.Version] (MSC service thread 1-5) HHH000412: Hibernate Core {4.0.1.Final} 15:36:50,429 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-5) HHH000206: hibernate.properties not found 15:36:50,431 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-5) HHH000021: Bytecode provider name : javassist 15:36:50,452 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-5) HHH000204: Processing PersistenceUnitInfo [ name: default ...] 15:36:50,634 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-5) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider 15:36:50,679 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-5) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect 15:36:50,695 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-5) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory 15:36:50,699 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-5) HHH000397: Using ASTQueryTranslatorFactory 15:36:50,738 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-5) Hibernate Validator 4.2.0.Final 15:36:51,068 INFO [br.com.caelum.vraptor.config.BasicConfiguration] (MSC service thread 1-5) Using class br.com.caelum.goodbuy.infra.CustomProvider as Container Provider 15:36:51,079 INFO [br.com.caelum.vraptor.ioc.spring.DefaultSpringLocator] (MSC service thread 1-5) No application context found 15:36:51,099 INFO [br.com.caelum.vraptor.scan.WebAppBootstrapFactory] (MSC service thread 1-5) No static WebAppBootstrap found. 15:36:51,100 INFO [br.com.caelum.vraptor.config.BasicConfiguration] (MSC service thread 1-5) br.com.caelum.vraptor.scanning = null 15:36:51,258 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-5) Refreshing Root WebApplicationContext: startup date [Sun Dec 02 15:36:51 BRST 2012]; root of context hierarchy 15:36:51,286 INFO [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] (MSC service thread 1-5) JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning 15:36:51,290 INFO [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] (MSC service thread 1-5) JSR-330 'javax.inject.Named' annotation found and supported for component scanning 15:36:51,397 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-5) Overriding bean definition for bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor': replacing [Root bean: class [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [br.com.caelum.vraptor.ioc.spring.InjectionBeanPostProcessor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] 15:36:51,420 INFO [br.com.caelum.vraptor.ioc.spring.InjectionBeanPostProcessor] (MSC service thread 1-5) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 15:36:51,466 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-5) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@ed5714b: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,defaultMethodNotAllowedHandler,defaultMultipartConfig,messageInterpolatorFactory,interceptorListPriorToExecutionExtractor,defaultDeserializers,defaultRoutes,defaultConverters,defaultTypeNameExtractor,XStreamXMLDeserializer,defaultResourceTranslator,defaultInterceptorHandlerFactory,defaultRestDefaults,noRoutesConfiguration,JSR303ValidatorFactory,paranamerNameProvider,pathAnnotationRoutesParser,hibernateProxyInitializer,encodingHandlerFactory,defaultResourceNotFoundHandler,defaultRouter,topologicalSortedInterceptorRegistry,objenesisProxifier,validatorFactoryCreator,defaultTypeFinder,defaultAcceptHeaderToFormat,stereotypeHandler,converterHandler,interceptorStereotypeHandler,deserializesHandler,stereotypedBeansRegistrar,defaultSpringLocator,emptyElementsRemoval,defaultValidationViewsFactory,exceptionHandlerInterceptor,defaultExceptionMapper,defaultValidator,JSR303Validator,applicationConfiguration,forwardToDefaultViewInterceptor,defaultServletFileUploadCreator,defaultRefererResult,XStreamJSONSerialization,defaultRepresentationResult,HTMLSerialization,defaultStatus,resourceLookupInterceptor,defaultLogicResult,jstlLocalization,executeMethodInterceptor,flashInterceptor,defaultHttpResult,defaultResult,instantiateInterceptor,ognlParametersProvider,defaultPageResult,emptyResult,replicatorOutjector,outjectResult,defaultRestHeadersHandler,defaultPathResolver,defaultMethodInfo,parametersInstantiatorInterceptor,XStreamJSONPSerialization,XStreamXMLSerialization,deserializingInterceptor,jsonDeserializer,defaultFormatResolver,commonsUploadMultipartInterceptor,downloadInterceptor,primitiveByteConverter,enumConverter,stringConverter,booleanConverter,primitiveCharConverter,longConverter,localeBasedDateConverter,primitiveShortConverter,uploadedFileConverter,characterConverter,bigIntegerConverter,localeBasedCalendarConverter,doubleConverter,floatConverter,primitiveIntConverter,primitiveBooleanConverter,byteConverter,shortConverter,integerConverter,primitiveDoubleConverter,primitiveLongConverter,primitiveFloatConverter,bigDecimalConverter,VRaptorRequestProvider,httpServletRequestProvider,httpServletResponseProvider,httpSessionProvider,defaultInterceptorStack,enhancedRequestExecution,org.springframework.aop.config.internalAutoProxyCreator,produtosController,usuariosController,usuarioWeb,autenticacaoInterceptor,entityManagerCreator,mundo,carrinho,produtoDao,JPATransactionInterceptor,carrinhoController,usuarioDao,entityManagerFactoryCreator]; root of factory hierarchy 15:36:51,639 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-5) HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect 15:36:51,641 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-5) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory 15:36:51,643 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-5) HHH000397: Using ASTQueryTranslatorFactory 15:36:51,690 INFO [br.com.caelum.vraptor.core.DefaultConverters] (MSC service thread 1-5) Registering bundled converters 15:36:51,753 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /produtos/{id} [DELETE] -> ProdutosController.remove(Long) 15:36:51,755 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /produtos [POST] -> ProdutosController.adiciona(Produto) 15:36:51,757 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /produtos/busca [GET] -> ProdutosController.busca(String) 15:36:51,758 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /produtos [GET] -> ProdutosController.lista() 15:36:51,759 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /produtos/novo [GET] -> ProdutosController.formulario() 15:36:51,761 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /produtos/{id} [GET] -> ProdutosController.edita(Long) 15:36:51,773 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /produtos/{produto.id} [PUT] -> ProdutosController.altera(Produto) 15:36:51,774 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /produtos/busca.json [GET] -> ProdutosController.buscaJson(String) 15:36:51,776 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /login [POST] -> UsuariosController.login(Usuario) 15:36:51,779 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /logout [ALL] -> UsuariosController.logout() 15:36:51,780 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /usuarios [POST] -> UsuariosController.adiciona(Usuario) 15:36:51,781 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /usuarios/novo [ALL] -> UsuariosController.novo() 15:36:51,782 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /login [GET] -> UsuariosController.loginForm() 15:36:51,783 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /mundo/boasVindas [ALL] -> Mundo.boasVindas() 15:36:51,784 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /mundo/paises [ALL] -> Mundo.paises() 15:36:51,786 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /carrinho/{indiceItem} [DELETE] -> CarrinhoController.remove(int) 15:36:51,788 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /carrinho [POST] -> CarrinhoController.adiciona(Item) 15:36:51,789 INFO [br.com.caelum.vraptor.http.route.DefaultRouteBuilder] (MSC service thread 1-5) /carrinho [GET] -> CarrinhoController.visualiza() 15:36:51,791 INFO [br.com.caelum.vraptor.VRaptor] (MSC service thread 1-5) VRaptor 3.3.1 successfuly initialized 15:36:51,800 INFO [org.jboss.web] (MSC service thread 1-5) JBAS018210: Registering web context: /projetoweb 15:36:51,804 INFO [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990 15:36:51,805 INFO [org.jboss.as] (MSC service thread 1-2) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 5761ms - Started 331 of 409 services (76 services are passive or on-demand) 15:36:51,869 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "projetoweb.war"

Não consigo resolver, rsrs as configurações estão corretas certo?

web.xml:

[code]
br.com.caelum.vraptor.packages
br.com.caelum.vraptor.util.jpa

br.com.caelum.vraptor.provider br.com.caelum.vraptor.util.jpa.JPACustomProvider [/code] E meu DAO: [code]@Component public class ProdutoDao {
private EntityManager manager;

public ProdutoDao(EntityManager manager) {
	this.manager = manager;
}

}[/code]

Estranho…

em todo caso, tente trocar essa configuração do Provider por essa:

<context-param>
    <param-name>br.com.caelum.vraptor.packages</param-name>
    <param-value>br.com.caelum.vraptor.util.jpa</param-value>
</context-param>

Retirei a parte do JPACustomProvider e deu o mesmo erro. Poderia ser algo com JAR faltando ou algo assim Lucas? Acredito que não né!? Estou quase perguntando se vc quer que eu zip o projeto e te mande, rsrsrs

PS: Tentei com CustomProvider igual explica na documentação do VRaptor mas tbm não rolou, se bem que no caso não teria diferença nenhuma. :confused:

cara, é algum problema com a configuração que vc fez… deve estar escondido em alguma exception que acontece… a última que vc mandou tinha um NullPointer… geralmente só acontece isso quando deu erro na inicialização do EntityManagerCreator…

verifica se o nome do data source que vc tá usando tá direitinho e se não tem nenhuma outra exception relacionada…

As configurações do web.xml são só essas mesmas certo? E o Dao está OK tbm ? To quebrando a cabeça faz tempo, rsrsrs, eu não entendi mto bem o erro, pelo que entendi, ele indica que o parametro no construtor do Dao estão errados, ou que falta alguma coisa, poderia me dar uma explicada melhor para eu dar uma pesquisada?

Quanto ao persistence.xml / standalone.xml do JBoss, já conferi e é isso mesmo, fiz um outro projeto para testar uma persistência com o MySQL no JBoss usando JPA e ta rolando certinho.