-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: @PersistenceContext - JTA problem?
PostPosted: Tue Dec 13, 2016 5:21 pm 
Newbie

Joined: Tue Dec 13, 2016 4:54 pm
Posts: 5
So, I've been trying for many days to do this work, without success. My Web project uses Glassfish 4.1.1, and have only three classes, one is a stateless EJB who receives a injected @PersistenceContext EntityManager. Another class is a servlet who receives this EJB injected either and by a parameter named "action" with value "generate" will create a table at PostgreSQL database. The last class is the entity to be persisted. Let's go for the classes:

Code:
import javax.persistence.*;
import java.util.*;
import javax.inject.*;
import javax.annotation.*;
import javax.annotation.sql.*;
import javax.ejb.*;

@DataSourceDefinition(
  name="java:app/jdbc/PostgreSQLResource",
  className="org.postgresql.ds.PGPoolingDataSource",
  user="postgres",
  password="password",
  url="jdbc:postgresql://localhost:5432/database"
)
@Stateless
public class CreateTable{

  @PersistenceContext
  private EntityManager em;

  public void go(){
    em.close();
  }

}


Code:
import java.io.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import javax.inject.*;
import javax.ejb.*;

@WebServlet("/server")
public class Server extends HttpServlet{

  @EJB private CreateTable ct;

  public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException{

    res.setContentType("text/html; charset=UTF-8");

    PrintWriter writer = res.getWriter();

    String param = "";

    if(req.getParameter("action") != null){
      param = req.getParameter("action");
    }

    switch(param){
      case "generate":
        ct.go();
        writer.print("Created table");
        break;
      default:
        writer.print("Parameter action with value undefined");
    }

    res.flushBuffer();

  }

}


Code:
import javax.persistence.*;
import java.util.*;

@NamedQuery(
  name="findByFinalizacao",
  query="select t from Task t where t.finalization = :finalization"
)

@Entity
@Table(name="tasks")
public class Task{

  @Id
  @GeneratedValue
  private Long id;
  private String description;
  private boolean finalization;
  @Temporal(TemporalType.DATE)
  private Calendar dateFinalization;

  public void setId(Long id){
    this.id = id;
  }
  public void setDescription(String description){
    this.description = description;
  }
  public void setFinalization(boolean finalization){
    this.finalization = finalization;
  }
  public void setDateFinalization(Calendar dateFinalization){
    this.dateFinalization = dateFinalization;
  }
  public Long getId(){
    return this.id;
  }
  public String getDescription(){
    return description;
  }
  public boolean getFinalization(){
    return finalization;
  }
  public Calendar getDateFinalization(){
    return dateFinalization;
  }

}


Code:
This is my server.log when I try to deploy the application:

[2016-12-13T19:04:40.625-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663080625] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.265-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081265] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.281-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081281] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.312-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081312] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.312-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081312] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.312-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081312] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.312-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081312] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.312-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081312] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.312-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081312] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.328-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081328] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.328-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081328] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.328-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081328] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.328-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081328] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.328-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081328] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.328-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081328] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.328-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081328] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.344-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081344] [levelValue: 800] [[
  visiting unvisited references]]

[2016-12-13T19:04:41.422-0200] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.tools.deployment.dol] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081422] [levelValue: 1000] [[
  enterprise.deployment.util.descriptor.duplicate]]

[2016-12-13T19:04:41.625-0200] [glassfish 4.1] [WARNING] [invalid.dynamic-reconfig.value] [javax.enterprise.resource.resourceadapter.com.sun.appserv.connectors.internal.api] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081625] [levelValue: 900] [[
  RAR8705: Invalid value for property dynamic-reconfiguration-wait-timeout-in-seconds : null]]

[2016-12-13T19:04:41.906-0200] [glassfish 4.1] [INFO] [] [org.hibernate.jpa.internal.util.LogHelper] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663081906] [levelValue: 800] [[
  HHH000204: Processing PersistenceUnitInfo [
   name: database
   ...]]]

[2016-12-13T19:04:42.844-0200] [glassfish 4.1] [INFO] [] [org.hibernate.Version] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663082844] [levelValue: 800] [[
  HHH000412: Hibernate Core {5.2.5.Final}]]

[2016-12-13T19:04:42.859-0200] [glassfish 4.1] [INFO] [] [org.hibernate.cfg.Environment] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663082859] [levelValue: 800] [[
  HHH000206: hibernate.properties not found]]

[2016-12-13T19:04:43.359-0200] [glassfish 4.1] [INFO] [] [org.hibernate.annotations.common.Version] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663083359] [levelValue: 800] [[
  HCANN000001: Hibernate Commons Annotations {5.0.1.Final}]]

[2016-12-13T19:04:44.828-0200] [glassfish 4.1] [INFO] [] [org.hibernate.dialect.Dialect] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663084828] [levelValue: 800] [[
  HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect]]

[2016-12-13T19:04:45.047-0200] [glassfish 4.1] [INFO] [] [org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663085047] [levelValue: 800] [[
  HHH000422: Disabling contextual LOB creation as connection was null]]

[2016-12-13T19:04:45.063-0200] [glassfish 4.1] [INFO] [] [org.hibernate.type.BasicTypeRegistry] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663085063] [levelValue: 800] [[
  HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@2b5d89]]

[2016-12-13T19:04:49.547-0200] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663089547] [levelValue: 1000] [[
  Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method]]

[2016-12-13T19:04:49.547-0200] [glassfish 4.1] [SEVERE] [] [] [tid: _ThreadID=43 _ThreadName=Thread-9] [timeMillis: 1481663089547] [levelValue: 1000] [[
  javax.persistence.PersistenceException: [PersistenceUnit: database] Unable to build Hibernate SessionFactory
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:967)
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892)
   at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:151)
   at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199)
   at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:107)
   at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223)
   at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
   at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230)
   at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
   at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.security.auth.Subject.doAs(Unknown Source)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.security.auth.Subject.doAs(Unknown Source)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
   at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:404)
   at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234)
   at sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
   at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
   at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:309)
   at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
   at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
   at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
   at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:292)
   at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1139)
   at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:375)
   at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:173)
   at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
   at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
   at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
   at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
   at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
   at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
   at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
   at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
   at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
   at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
   at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
   at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
   at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.HibernateException: DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; base JtaPlatform impl (org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform@e319da)?
   at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:46)
   at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:46)
   at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:178)
   at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:90)
   at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)
   at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
   at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
   at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889)
   ... 69 more]]

[2016-12-13T19:04:49.547-0200] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663089547] [levelValue: 1000] [[
  Exception while preparing the app]]

[2016-12-13T19:04:49.547-0200] [glassfish 4.1] [SEVERE] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663089547] [levelValue: 1000] [[
  Exception during lifecycle processing
javax.persistence.PersistenceException: [PersistenceUnit: database] Unable to build Hibernate SessionFactory
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:967)
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892)
   at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:151)
   at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199)
   at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:107)
   at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223)
   at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
   at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230)
   at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
   at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.security.auth.Subject.doAs(Unknown Source)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.security.auth.Subject.doAs(Unknown Source)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
   at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:404)
   at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234)
   at sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
   at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
   at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:309)
   at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
   at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
   at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
   at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:292)
   at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1139)
   at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:375)
   at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:173)
   at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
   at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
   at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
   at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
   at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
   at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
   at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
   at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
   at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
   at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
   at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
   at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
   at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.HibernateException: DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; base JtaPlatform impl (org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform@e319da)?
   at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:46)
   at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:46)
   at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:178)
   at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:90)
   at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)
   at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
   at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
   at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889)
   ... 69 more
]]

[2016-12-13T19:04:49.625-0200] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=43 _ThreadName=admin-listener(4)] [timeMillis: 1481663089625] [levelValue: 1000] [[
  Exception while preparing the app : [PersistenceUnit: database] Unable to build Hibernate SessionFactory
org.hibernate.HibernateException: DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; base JtaPlatform impl (org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform@e319da)?
   at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:46)
   at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:46)
   at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:178)
   at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:90)
   at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)
   at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
   at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
   at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889)
   at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:151)
   at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199)
   at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:107)
   at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223)
   at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
   at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230)
   at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
   at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
   at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.security.auth.Subject.doAs(Unknown Source)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.security.auth.Subject.doAs(Unknown Source)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
   at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
   at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:404)
   at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234)
   at sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
   at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
   at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
   at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
   at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:309)
   at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
   at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
   at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
   at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
   at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:292)
   at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1139)
   at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:375)
   at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:173)
   at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
   at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
   at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
   at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
   at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
   at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
   at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
   at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
   at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
   at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
   at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
   at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
   at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
   at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
   at java.lang.Thread.run(Unknown Source)
]]


This is my persistence.xml (inside WEB-INF/classes/META-INF/):

Code:
<persistence 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_2_0.xsd"
    version="2.0">

<persistence-unit name="database">

   <!-- provedor/implementacao do JPA -->
   <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

   <jta-data-source>java:app/jdbc/PostgreSQLResource</jta-data-source>

   <class>Task</class>

  <properties>

  <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
  <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/database" />
  <property name="javax.persistence.jdbc.user" value="postgres" />
  <property name="javax.persistence.jdbc.password" value="" />

  <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
  <property name="hibernate.show_sql" value="true" />
  <property name="hibernate.format_sql" value="true" />

  <property name="hibernate.hbm2ddl.auto" value="update" />
  <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
  <property name="hibernate.transaction.manager_lookup_class" value="javax.transaction.TransactionManager" />
   
   </properties>
</persistence-unit>
</persistence>


I have a beans.xml inside WEB-INF, so my injections are working (tested).
I also succedded to connect with database without @PersistenceContext, and I've this example succedded using @PersistenceUnit EntityManagerFactory and persistence.xml changed to transaction-type="RESOURCE_LOCAL", but I want to use the @PersistenceContext annotation.

Reading the server.log I see this two messages:

DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; base JtaPlatform impl...

and before:

Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method]]...

I have been researching internet for this two messages for too long, but still can't solve this.

Any help will be welcome. Thank you.


Top
 Profile  
 
 Post subject: Re: @PersistenceContext - JTA problem?
PostPosted: Wed Dec 14, 2016 2:38 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You're using old settings:

Code:
 
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
<property name="hibernate.transaction.manager_lookup_class" value="javax.transaction.TransactionManager" />


Try changing them to:

[url]<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform" />[/url]

The persistence.xml should use JTA transaction-type and a jta-data-source.


Top
 Profile  
 
 Post subject: Re: @PersistenceContext - JTA problem?
PostPosted: Wed Dec 14, 2016 8:15 pm 
Newbie

Joined: Tue Dec 13, 2016 4:54 pm
Posts: 5
Thank you very much vlad, I've changed persistence.xml like you said and JTA problem was solved. Now when the application is started the table is created. So I moved to the next step, insert a record to the table. But now I have another problem. I've been working on it this entirely day. Insert class stayed like this:

Code:
import org.hibernate.*;
import javax.persistence.*;
import java.io.*;
import java.util.*;
import javax.inject.*;
import javax.annotation.*;
import javax.annotation.sql.*;
import javax.transaction.*;
import javax.ejb.*;

@DataSourceDefinition(
  name="java:app/jdbc/PostgreSQLPool",
  className="org.postgresql.ds.PGPoolingDataSource",
  user="postgres",
  password="",
  url="jdbc:postgresql://localhost:5432/database",
  initialPoolSize=3,
  maxPoolSize=20
)

@Transactional
@Stateless
public class InsertTask implements Serializable{

  @PersistenceContext
  private EntityManager em;

  @Resource
  private EJBContext ctx;

  @Inject Task task;

  public void go(){
    try{
      task.setDescription("Study Hibernate");
      task.setFinalization(false);
      task.setDateFinalization(Calendar.getInstance());
      em.persist(task);
      em.flush();
    }
    catch(Throwable t){
      System.out.println("Error: " + t.toString());
      ctx.setRollbackOnly();
    }
  }

}


Server class:

Code:
import java.io.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import javax.inject.*;
import javax.ejb.*;

@WebServlet("/server")
public class Server extends HttpServlet{

  @EJB private InsertTask it;

  public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException{

    res.setContentType("text/html; charset=UTF-8");

    PrintWriter writer = res.getWriter();

    String param = "";

    if(req.getParameter("action") != null){
      param = req.getParameter("action");
    }

    switch(param){
      case "insert":
        it.go();
        writer.print("Task inserted");
        break;
      default:
        writer.print("Action parameter is undefined");
    }

    res.flushBuffer();

  }

}


Nothing changed at Task.class.

My server.log shows:

Code:
[2016-12-14T22:12:30.679-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool.monitor] [tid: _ThreadID=216 _ThreadName=pool-94-thread-1] [timeMillis: 1481760750679] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.monitor.PoolMonitoringLevelListener$PropertyChangeHandler] [METHODNAME: changed] [[
  A com.sun.enterprise.config.serverbeans.Applications was changed : GlassFishConfigBean.com.sun.enterprise.config.serverbeans.Applications]]

[2016-12-14T22:12:30.679-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool.monitor] [tid: _ThreadID=216 _ThreadName=pool-94-thread-1] [timeMillis: 1481760750679] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.monitor.PoolMonitoringLevelListener$PropertyChangeHandler] [METHODNAME: changed] [[
  A com.sun.enterprise.config.serverbeans.Server was changed : GlassFishConfigBean.com.sun.enterprise.config.serverbeans.Server]]

[2016-12-14T22:12:30.695-0200] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=40 _ThreadName=admin-listener(1)] [timeMillis: 1481760750695] [levelValue: 800] [[
  jpa3 was successfully deployed in 15.926 milliseconds.]]

[2016-12-14T22:12:38.274-0200] [glassfish 4.1] [INFO] [AS-JTA-00009] [javax.enterprise.resource.jta] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758274] [levelValue: 800] [[
  In REQUIRED TransactionalInterceptor]]

[2016-12-14T22:12:38.384-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758384] [levelValue: 500] [CLASSNAME: com.sun.enterprise.connectors.ConnectorRegistry] [METHODNAME: getInstance] [[
  returning the connector registry]]

[2016-12-14T22:12:38.384-0200] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=30 _ThreadName=Thread-8] [timeMillis: 1481760758384] [levelValue: 800] [[
  Hibernate:
    select
        nextval ('hibernate_sequence')]]

[2016-12-14T22:12:38.384-0200] [glassfish 4.1] [FINE] [poolmgr.no_resource_reference] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758384] [levelValue: 500] [CLASSNAME: com.sun.enterprise.connectors.ConnectionManagerImpl] [METHODNAME: allocateConnection] [[
  RAR5036:Resource reference is not defined for JNDI name [__SYSTEM/resource/__datasource_definition/jpa3/java:app/jdbc/PostgreSQLPool__pm]]]

[2016-12-14T22:12:38.384-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758384] [levelValue: 500] [CLASSNAME: com.sun.enterprise.connectors.ConnectorRegistry] [METHODNAME: getInstance] [[
  returning the connector registry]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionFactoryImpl] [METHODNAME: logFine] [[
  In equals]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.enterprise.connectors.ConnectorRegistry] [METHODNAME: getDescriptor] [[
  Found/returing Connector descriptor in connector registry.]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.enterprise.connectors.ConnectionManagerImpl] [METHODNAME: logFine] [[
  ConnectionMgr: poolName __SYSTEM/pools/__datasource_definition/jpa3/java:app/jdbc/PostgreSQLPool  txLevel : 1]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.PoolManagerImpl] [METHODNAME: logFine] [[
  Returning sysResourceManager]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionFactoryImpl] [METHODNAME: logFine] [[
  In matchManagedConnections]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionFactoryImpl] [METHODNAME: logFine] [[
  In equals]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionImpl] [METHODNAME: logFine] [[
  In getConnection]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [jdbc.execute_init_sql_start] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionImpl] [METHODNAME: executeInitSql] [[
  Starting Init SQL]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [jdbc.execute_init_sql_end] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionImpl] [METHODNAME: executeInitSql] [[
  Finished executing Init SQL]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.PoolManagerImpl] [METHODNAME: logFine] [[
  Returning sysResourceManager]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionImpl] [METHODNAME: logFine] [[
  In getLocalTransaction]]

[2016-12-14T22:12:38.399-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758399] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.PoolTxHelper] [METHODNAME: resourceEnlisted] [[
  Pool [ __SYSTEM/pools/__datasource_definition/jpa3/java:app/jdbc/PostgreSQLPool ]: resourceEnlisted: 33]]

[2016-12-14T22:12:38.415-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758415] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.PoolManagerImpl] [METHODNAME: logFine] [[
  Returning sysResourceManager]]

[2016-12-14T22:12:38.415-0200] [glassfish 4.1] [FINE] [connection_sharing_end] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758415] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.ConnectorXAResource] [METHODNAME: end] [[
  ConnectorXAResource.end() called]]

[2016-12-14T22:12:38.415-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758415] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.ConnectionPool] [METHODNAME: resourceClosed] [[
  Pool: resourceClosed: 33]]

[2016-12-14T22:12:38.415-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758415] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.ConnectionPool] [METHODNAME: resourceClosed] [[
  Pool: resourceFreed: 33]]

[2016-12-14T22:12:38.431-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758431] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionImpl] [METHODNAME: logFine] [[
  In getLocalTransaction]]

[2016-12-14T22:12:38.431-0200] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=30 _ThreadName=Thread-8] [timeMillis: 1481760758431] [levelValue: 800] [[
  Error: java.lang.IllegalStateException: This web container has not yet been started]]

[2016-12-14T22:12:38.431-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758431] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.PoolManagerImpl] [METHODNAME: transactionCompleted] [[
  calling transactionCompleted on __SYSTEM/pools/__datasource_definition/jpa3/java:app/jdbc/PostgreSQLPool]]

[2016-12-14T22:12:38.431-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758431] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.PoolTxHelper] [METHODNAME: transactionCompleted] [[
  Pool: transactionCompleted: 33]]

[2016-12-14T22:12:38.431-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758431] [levelValue: 500] [CLASSNAME: com.sun.gjc.spi.ManagedConnectionImpl] [METHODNAME: logFine] [[
  In cleanup]]

[2016-12-14T22:12:38.431-0200] [glassfish 4.1] [FINE] [] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool] [tid: _ThreadID=30 _ThreadName=http-listener-1(5)] [timeMillis: 1481760758431] [levelValue: 500] [CLASSNAME: com.sun.enterprise.resource.pool.ConnectionPool] [METHODNAME: logFine] [[
   Wait monitor is null]]


What means the "Error: java.lang.IllegalStateException: This web container has not yet been started" ?


Top
 Profile  
 
 Post subject: Re: @PersistenceContext - JTA problem?
PostPosted: Thu Dec 15, 2016 5:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Related to that error, I can't tell you exactly what's wrong. Maybe you should ask this question on the Glassfish forum. They should know better how to guide you.


Top
 Profile  
 
 Post subject: Re: @PersistenceContext - JTA problem?
PostPosted: Thu Dec 15, 2016 10:31 am 
Newbie

Joined: Tue Dec 13, 2016 4:54 pm
Posts: 5
I've been looking for this problem at Internet and Glassfish problems started to pop up. I'm thinking to change the application server to Wildfly. Thank you very much.


Top
 Profile  
 
 Post subject: Re: @PersistenceContext - JTA problem?
PostPosted: Fri Dec 16, 2016 11:07 am 
Newbie

Joined: Tue Dec 13, 2016 4:54 pm
Posts: 5
Exacly the same application successfully deployed at Wildfly.


Top
 Profile  
 
 Post subject: Re: @PersistenceContext - JTA problem?
PostPosted: Fri Dec 16, 2016 12:03 pm 
Newbie

Joined: Tue Dec 13, 2016 4:54 pm
Posts: 5
And with new experience with Wildfly I become able to make it work at Glassfish. I removed the annotation @DataSourceDefinition, and created the connection pool PosgreSQLPool and three resources, PostgreSQLResources, PostgreSQLResources__pm and PostgreSQLResources__nontx, (I'm not sure, but I think with annotation @DataSourceDefinition I don't need to create the resources). Probably I already has done this, so nothing new here... The true trick is to move the postgre JDBC driver, wich was located at WEB-INF/lib folder. When I deleted @DataSourceDefinition annotation, I started to see another error at console: no suitable driver for jdbc:postgre... So I used the command asadmin add-library <postgrejdbcdriver.jar> wich copied the postgre jdbc driver to folder lib inside domain folder. Then the magic happened. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.