简体   繁体   中英

JPA query syntax issue or what ?! JPA SELECT NEW syntax issue?

I have a TextHistory entity object and then I have this JPA query.

SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i")

In the entity object I have provided the corresponding constructor.

I am trying to deploy my app under Payara 4.1 but I get this exception at deploy time:

Error occurred during deployment: Exception while deploying the app    
[app-name] : Exception [EclipseLink-28019] 
(Eclipse Persistence Services - 2.6.2.qualifier):   
org.eclipse.persistence.exceptions.EntityManagerSetupException 
Exception Description:  
Deployment of PersistenceUnit [unit-name] failed. 
Close all factories for this PersistenceUnit. Internal Exception:  
Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): 
org.eclipse.persistence.exceptions.JPQLException   
Exception Description: Internal problem encountered while compiling 
[SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].   
Internal Exception: java.lang.NullPointerException. 
Please see server.log for more details.

I think my JPA query syntax is correct. I've been struggling with this for several hours now.

What is the problem? Any ideas?

In the server.log I am seeing this exception.

        [2017-08-15T21:32:24.546+0200] [Payara 4.1] [INFO] [] [org.eclipse.persistence.session./file:/D:/Work/TSSB_DEV_ENV_MASTER/domains/tssb_ms_gf4_domain_srm_tsbg/applications/tsbgam-application-2017-T3-SNAPSHOT/tsbgam-business_jar/_tsms_tsbg.connection] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544546] [levelValue: 800] [[
          /file:/D:/Work/TSSB_DEV_ENV_MASTER/domains/tssb_ms_gf4_domain_srm_tsbg/applications/tsbgam-application-2017-T3-SNAPSHOT/tsbgam-business_jar/_tsms_tsbg logout successful]]

        [2017-08-15T21:32:24.546+0200] [Payara 4.1] [SEVERE] [] [org.eclipse.persistence.session./file:/D:/Work/TSSB_DEV_ENV_MASTER/domains/tssb_ms_gf4_domain_srm_tsbg/applications/tsbgam-application-2017-T3-SNAPSHOT/tsbgam-business_jar/_tsms_tsbg.ejb] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544546] [levelValue: 1000] [[

        Local Exception Stack: 
        Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
        Exception Description: Internal problem encountered while compiling [SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].
        Internal Exception: java.lang.NullPointerException
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildUnexpectedException(HermesParser.java:207)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:296)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:163)
            at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142)
            at org.eclipse.persistence.internal.jpa.JPAQuery.processJPQLQuery(JPAQuery.java:223)
            at org.eclipse.persistence.internal.jpa.JPAQuery.prepare(JPAQuery.java:184)
            at org.eclipse.persistence.queries.DatabaseQuery.prepareInternal(DatabaseQuery.java:624)
            at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQuery(AbstractSession.java:4366)
            at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:4326)
            at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:598)
            at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:818)
            at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:762)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:265)
            at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:731)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:305)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:303)
            at org.glassfish.persistence.jpa.JPADeployer$2.visitPUD(JPADeployer.java:451)
            at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
            at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:492)
            at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:395)
            at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:487)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
            at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:487)
            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(Subject.java:360)
            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(Subject.java:360)
            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.utils.ResourceUtil.runCommand(ResourceUtil.java:253)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:231)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:275)
            at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:136)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            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:326)
            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:305)
            at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
            at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:384)
            at org.glassfish.admin.rest.adapter.RestAdapter$2.service(RestAdapter.java:316)
            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(Thread.java:745)
        Caused by: java.lang.NullPointerException
            at org.eclipse.persistence.queries.ReportQuery.beginAddingConstructorArguments(ReportQuery.java:558)
            at org.eclipse.persistence.internal.jpa.jpql.ReportItemBuilder.visit(ReportItemBuilder.java:263)
            at org.eclipse.persistence.jpa.jpql.parser.ConstructorExpression.accept(ConstructorExpression.java:84)
            at org.eclipse.persistence.internal.jpa.jpql.ReportItemBuilder.visitAbstractSelectClause(ReportItemBuilder.java:695)
            at org.eclipse.persistence.internal.jpa.jpql.ReportItemBuilder.visit(ReportItemBuilder.java:545)
            at org.eclipse.persistence.jpa.jpql.parser.SelectClause.accept(SelectClause.java:42)
            at org.eclipse.persistence.internal.jpa.jpql.ReportQueryVisitor.visitAbstractSelectClause(ReportQueryVisitor.java:82)
            at org.eclipse.persistence.internal.jpa.jpql.AbstractObjectLevelReadQueryVisitor.visit(AbstractObjectLevelReadQueryVisitor.java:173)
            at org.eclipse.persistence.jpa.jpql.parser.SelectClause.accept(SelectClause.java:42)
            at org.eclipse.persistence.internal.jpa.jpql.AbstractObjectLevelReadQueryVisitor.visitAbstractSelectStatement(AbstractObjectLevelReadQueryVisitor.java:327)
            at org.eclipse.persistence.internal.jpa.jpql.ReportQueryVisitor.visitAbstractSelectStatement(ReportQueryVisitor.java:92)
            at org.eclipse.persistence.internal.jpa.jpql.AbstractObjectLevelReadQueryVisitor.visit(AbstractObjectLevelReadQueryVisitor.java:183)
            at org.eclipse.persistence.jpa.jpql.parser.SelectStatement.accept(SelectStatement.java:101)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser$DatabaseQueryVisitor.visit(HermesParser.java:438)
            at org.eclipse.persistence.jpa.jpql.parser.SelectStatement.accept(SelectStatement.java:101)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser$DatabaseQueryVisitor.visit(HermesParser.java:418)
            at org.eclipse.persistence.jpa.jpql.parser.JPQLExpression.accept(JPQLExpression.java:135)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:282)
            ... 85 more
        ]]

        [2017-08-15T21:32:24.548+0200] [Payara 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544548] [levelValue: 1000] [[
          Exception while deploying the app [tsbgam-application-2017-T3-SNAPSHOT]]]

        [2017-08-15T21:32:24.548+0200] [Payara 4.1] [SEVERE] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544548] [levelValue: 1000] [[
          Exception during lifecycle processing
        org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
        Exception Description: Deployment of PersistenceUnit [tsms_tsbg] failed. Close all factories for this PersistenceUnit.
        Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
        Exception Description: Internal problem encountered while compiling [SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].
        Internal Exception: java.lang.NullPointerException
            at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:869)
            at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:809)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:305)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:303)
            at org.glassfish.persistence.jpa.JPADeployer$2.visitPUD(JPADeployer.java:451)
            at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
            at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:492)
            at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:395)
            at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:487)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
            at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:487)
            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(Subject.java:360)
            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(Subject.java:360)
            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.utils.ResourceUtil.runCommand(ResourceUtil.java:253)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:231)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:275)
            at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:136)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            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:326)
            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:305)
            at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
            at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:384)
            at org.glassfish.admin.rest.adapter.RestAdapter$2.service(RestAdapter.java:316)
            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(Thread.java:745)
        ]]

        [2017-08-15T21:32:24.562+0200] [Payara 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544562] [levelValue: 1000] [[
          Exception while deploying the app [tsbgam-application-2017-T3-SNAPSHOT] : Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
        Exception Description: Deployment of PersistenceUnit [tsms_tsbg] failed. Close all factories for this PersistenceUnit.
        Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
        Exception Description: Internal problem encountered while compiling [SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].
        Internal Exception: java.lang.NullPointerException]]

        [2017-08-15T21:32:24.663+0200] [Payara 4.1] [INFO] [] [org.glassfish.admingui] [tid: _ThreadID=47 _ThreadName=admin-listener(5)] [timeMillis: 1502825544663] [levelValue: 800] [[
          Exception Occurred :Error occurred during deployment: Exception while deploying the app [tsbgam-application-2017-T3-SNAPSHOT] : Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
        Exception Description: Deployment of PersistenceUnit [tsms_tsbg] failed. Close all factories for this PersistenceUnit.
        Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
        Exception Description: Internal problem encountered while compiling [SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].
        Internal Exception: java.lang.NullPointerException. Please see server.log for more details.          ]]

Any hints on why do you actually want to use the SELECT NEW syntax? This syntax is mostly used in (the rare) case that you want to select fields from one entity and construct a different object using the values of those fields.

In your case you are constructing the very same entity you are selecting from. This is usually done as select e from SomeEntity e . (Actually, in contrast to SQL, in JPQL the select clause is optional as long as you are selecting from a single entity. So from SomeEntity e just selects the whole table, and from SomeEntity e where e <whatever> selects all <whatever> records.)

In case the entity has some heavyweight attributes (like @Lob s) or @ManyToOne associations that you don't want to load initially, the proper way to do this is to make them lazily loaded. For LOBs this is done via @Basic(fetchType = LAZY) and for associations via @ManyToOne(fetchType = LAZY) . Note that for @ManyToMany and @OneToMany lazy loading is the default anyway.

My impression is that you are trying to do JPA "the SQL way". A solid SQL knowledge is a must to properly use JPA, but you need to always do this "paradigm switch" from relational to object-oriented perspective in order to do things the way they are supposed to.

BTW, regarding

I don't even know what Eclipselink is

This pretty much says it all :-) JPA is a standardized Java API - it defines how things are supposed to work, no more, no less. It does not actually do the real work - this is left to the particular JPA implementation, aka persistence provider. There are a bunch of JPA implementations out there, the most prominent being Hibernate and Eclipselink. Every Java EE application server is required to include a JPA persistence provider, and it seems like your server comes with Eclipselink. Eclipselink came into existence when Oracle donated their proprietary JPA implementation named TopLink to the Eclipse Foundation.

Update: I did a bit more research and it seems like the reason for your error is quite mundane: The SELECT NEW syntax requires you to use the fully quialified name of the constructor, ie including package name. This is because you can select new into any POJO class you want, it does not require the class to be a JPA entity. In contrast, the from clause uses simple names because only @Entity classes are allowed there (which JPA enumerates and parses at deployment time).

Why not using a fully qualified name leads to a NullPointer in the Eclipselink code, is another story - seems like a bug in Eclipselink.

==> This leads to the question which one is better, select new or lazy loading. As always, it depends on your usecase. Annotating the fields for lazy loading will always be honored, no matter how the objects got into memory. For example, using EnitytManager.find() always returns a complete instance of the entity, use can't use a custom constructor there. But annotations on fields of course apply. The same goes when accessing entities by association - if A contains a reference to B , and you call A.getB() you get an instance of B initialized according to its annotations.

Using select new is a one-off technique in case you deliberately want to divert from the default.

Not familiar with this SELECT NEW syntax, but can see you are using Eclipselink ( http://wiki.eclipse.org/EclipseLink/Examples/JPA )

About a year ago I was stuck with one problem and at the end of the day it appeared to be an Eclipselink bug. Worth checking on that ( https://bugs.eclipse.org/bugs/query.cgi ), maybe it's known or maybe you just found it.

Another guess: org.eclipse.persistence.exceptions.EntityManagerSetupException might lead to incorrect EntityManager's settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM