Jboss + Jpa + Flex + BlazeDs

To com um problema galera, se alguem tiver uma luz

é o seguinte… tenho a seguinte pilha de erro quando vou criar o meu entityManagerFactory

segue o erro:

17:29:41,807 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured 17:29:41,807 INFO [SchemaUpdate] Running hbm2ddl schema update 17:29:41,807 INFO [SchemaUpdate] fetching database metadata 17:29:41,807 INFO [SchemaUpdate] updating schema 17:29:41,838 INFO [TableMetadata] table found: siag_teste.setor 17:29:41,838 INFO [TableMetadata] columns: [id, percentual, descricao] 17:29:41,838 INFO [TableMetadata] foreign keys: [] 17:29:41,838 INFO [TableMetadata] indexes: [primary] 17:29:41,838 INFO [SchemaUpdate] schema update complete 17:29:56,367 ERROR [STDERR] javax.persistence.PersistenceException: [PersistenceUnit: TesteSiag] Unable to build EntityManagerFactory 17:29:56,367 ERROR [STDERR] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677) 17:29:56,367 ERROR [STDERR] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126) 17:29:56,367 ERROR [STDERR] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52) 17:29:56,367 ERROR [STDERR] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34) 17:29:56,367 ERROR [STDERR] at JPAJNDIHelper.initEMF(JPAJNDIHelper.java:15) 17:29:56,367 ERROR [STDERR] at OlaMundo.ola(OlaMundo.java:19) 17:29:56,367 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 17:29:56,367 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 17:29:56,367 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 17:29:56,367 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 17:29:56,367 ERROR [STDERR] at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:406) 17:29:56,367 ERROR [STDERR] at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183) 17:29:56,367 ERROR [STDERR] at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1417) 17:29:56,367 ERROR [STDERR] at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:878) 17:29:56,367 ERROR [STDERR] at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:121) 17:29:56,367 ERROR [STDERR] at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158) 17:29:56,367 ERROR [STDERR] at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:49) 17:29:56,367 ERROR [STDERR] at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67) 17:29:56,367 ERROR [STDERR] at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:146) 17:29:56,367 ERROR [STDERR] at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:274) 17:29:56,367 ERROR [STDERR] at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:377) 17:29:56,367 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 17:29:56,367 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 17:29:56,367 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) 17:29:56,367 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) 17:29:56,367 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) 17:29:56,367 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 17:29:56,367 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 17:29:56,367 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) 17:29:56,367 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) 17:29:56,367 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598) 17:29:56,367 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) 17:29:56,367 ERROR [STDERR] at java.lang.Thread.run(Unknown Source) 17:29:56,367 ERROR [STDERR] Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager 17:29:56,367 ERROR [STDERR] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:361) 17:29:56,367 ERROR [STDERR] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327) 17:29:56,367 ERROR [STDERR] at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867) 17:29:56,367 ERROR [STDERR] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)

Segue o meu persistence.xml


<?xml version="1.0" encoding="UTF-8" ?> 
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" 
						   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
						   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
	<persistence-unit name="TesteJPA" transaction-type="JTA">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<jta-data-source>java:/mysql</jta-data-source>
		<class>br.com.meuteste.bean.Setor</class>
		<properties>
			<property name="hibernate.hbm2ddl.auto" value="update" /> 
			<property name="hibernate.show_sql" value="true" /> 
			<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" /> 
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
		</properties>
	</persistence-unit>
</persistence>

Segue o meu datasource ( mysql-ds.xml )


<datasources>
  <local-tx-datasource>
    <jndi-name>mysql</jndi-name>
    <connection-url>jdbc:mysql://10.1.1.5:3306/banco_teste</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>java</user-name>
    <password>java</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
    <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
    <metadata>
       <type-mapping>mySQL</type-mapping>
    </metadata>
  </local-tx-datasource>
</datasources>

Quando eu tento executar o método no meu backend que seria responsavel por criar o EntityManagerFactory eu tenho a pilha de erro acima, segue a classe de teste que fiz:

public class JPAJNDIHelper {

    public static void initEMF(String unitName ) {
        String bindingName = "JPAJNDIHelper_" + unitName;
        try {
            InitialContext ctx = new InitialContext();
            EntityManagerFactory emf = Persistence.createEntityManagerFactory(unitName);
            ctx.rebind(bindingName, emf);
        } catch( NamingException e ) {
            throw new RuntimeException(e);
        }
    }
}
public class OlaMundo {
    public String ola(String nome){
        
        Setor setor = new Setor();
        
        setor.setDescricao( "Jpa Teste" );
        setor.setPercentual(new BigDecimal(54.6));
        
        EntityManager em= null;
        UserTransaction utx = null;
        try {
            JPAJNDIHelper.initEMF("TesteJPA");
            em = JPAJNDIHelper.getEntityManager("TesteJPA");
            utx = JPAJNDIHelper.getUserTransaction();

            utx.begin();
            em.joinTransaction();
            em.persist(setor);
            utx.commit();
            }
     }
// Codigo omitido 

No caso é o método Ola que é chamado.

Se algeum tiver alguma ideia… valeu

Opa, blz?

O programa está tentando criar uma PersistenceUnit com o nome “TesteSiag”, não vi onde está esta String no seu código…
pode ser uma versão que você subiu antes para o servidor e ainda ficou por lá… faz o undeploy e depois o deploy novamente da app.
você pode simplificar o código tb e testar.


        Setor setor = new Setor();  
         
        setor.setDescricao( "Jpa Teste" );  
        setor.setPercentual(new BigDecimal(54.6));  

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("TesteJPA");
        EntityManager entityManager = emf.createEntityManager();

        entityManager.getTransaction().begin();
        entityManager.persist(setor);
        entityManager.getTransaction().commit();

        entityManager.close();
        emf.close();

espero que ajude.
abraço

Tenta mudar o nome do PersistenceUnit, pois é no persistence.xml ele referencia TesteJPA, e no log no erro ele diz que não encontrou o TesteSiag, portanto o JBoss, tenta buscar pelo JNDI e não acha nada dando assim PersistenceException em relação nome. Conserta e posta o resultado. Valew.

Foi erro de digitação do post galera … na verdade os nomes estão iguais … =/

Não consigo configurar o maldito JTA pra trabalhar no JBOSS . =/