Table is not generated via jpa

Asked

Viewed 11 times

0

I am studying JSF through the book "The definitive guide to jsf in java ee 8", but I made an error I reviewed the code many times and did not find the origin of this error :

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.7.payara-p3): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Table "MESSAGE" not found; SQL statement:
SELECT ID, TEXT FROM MESSAGE [42102-196]
Error Code: 42102
Call: SELECT ID, TEXT FROM MESSAGE
Query: ReadAllQuery(referenceClass=Message sql="SELECT ID, TEXT FROM MESSAGE")
 at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:342)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:691)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:567)
 at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2099)
 at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:603)
 at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:277)
 at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:263)
 at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:334)
 at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:746)
 at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2759)
 at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2712)
 at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:584)
 at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1232)
 at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:911)
 at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1191)
 at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:485)
 at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1279)
 at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2983)
 at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1898)
 at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1880)
 at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1845)
 at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:262)
 at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:482)
 at com.sun.enterprise.container.common.impl.QueryWrapper.getResultList(QueryWrapper.java:84)
 at com.sun.enterprise.container.common.impl.TypedQueryWrapper.getResultList(TypedQueryWrapper.java:73)
 at com.example.project.service.MessageService.list(MessageService.java:21)
 at com.example.project.view.HelloWorld.init(HelloWorld.java:23)
 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.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:83)
 at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:66)
 at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:122)
 at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:164)
 at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
 at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
 at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:177)
 at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
 at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:694)
 at org.jboss.weld.module.web.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
 at org.jboss.weld.module.web.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
 at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:136)
 at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:156)
 at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:184)
 at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:91)
 at com.sun.el.parser.AstValue.getBase(AstValue.java:125)
 at com.sun.el.parser.AstValue.getValue(AstValue.java:173)
 at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
 at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
 at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
 at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:170)
 at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:157)
 at javax.faces.component.UIOutput.getValue(UIOutput.java:140)
 at javax.faces.component.UIInput.getValue(UIInput.java:287)
 at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:181)
 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:328)
 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:143)
 at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1654)
 at javax.faces.render.Renderer.encodeChildren(Renderer.java:152)
 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
 at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:468)
 at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170)
 at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132)
 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199)
 at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
 at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1636)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:259)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:757)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:577)
 at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:158)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
 at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
 at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
 at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
 at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
 at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
 at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
 at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
 at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
 at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
 at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
 at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
 at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
 at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
 at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
 at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
 at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
 at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
 at java.lang.Thread.run(Thread.java:748)
Caused by: org.h2.jdbc.JdbcSQLException: Table "MESSAGE" not found; SQL statement:
SELECT ID, TEXT FROM MESSAGE [42102-196]
 at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
 at org.h2.message.DbException.get(DbException.java:179)
 at org.h2.message.DbException.get(DbException.java:155)
 at org.h2.command.Parser.readTableOrView(Parser.java:5552)
 at org.h2.command.Parser.readTableFilter(Parser.java:1266)
 at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1946)
 at org.h2.command.Parser.parseSelectSimple(Parser.java:2095)
 at org.h2.command.Parser.parseSelectSub(Parser.java:1940)
 at org.h2.command.Parser.parseSelectUnion(Parser.java:1755)
 at org.h2.command.Parser.parseSelect(Parser.java:1743)
 at org.h2.command.Parser.parsePrepared(Parser.java:449)
 at org.h2.command.Parser.parse(Parser.java:321)
 at org.h2.command.Parser.parse(Parser.java:293)
 at org.h2.command.Parser.prepareCommand(Parser.java:258)
 at org.h2.engine.Session.prepareLocal(Session.java:578)
 at org.h2.engine.Session.prepareCommand(Session.java:519)
 at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1204)
 at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
 at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:677)
 at com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:609)
 at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:271)
 at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:53)
 at com.sun.gjc.spi.ManagedConnectionImpl.prepareCachedStatement(ManagedConnectionImpl.java:1080)
 at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareStatement(ConnectionWrapper40.java:183)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1595)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1544)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:806)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:628)
 ... 99 more

2021-05-13T16:10:40.481-0300|GRAVE: Error Rendering View[/hello.xhtml]
org.jboss.weld.exceptions.WeldException: WELD-000049: Unable to invoke public void com.example.project.view.HelloWorld.init() on com.example.project.view.HelloWorld@60548b57
 at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:85)
 at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:66)
 at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:122)
 at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:164)
 at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
 at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
 at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:177)
 at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
 at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:694)
 at org.jboss.weld.module.web.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
 at org.jboss.weld.module.web.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
 at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:136)
 at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:156)
 at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:184)
 at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:91)
 at com.sun.el.parser.AstValue.getBase(AstValue.java:125)
 at com.sun.el.parser.AstValue.getValue(AstValue.java:173)
 at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
 at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
 at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
 at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:170)
 at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:157)
 at javax.faces.component.UIOutput.getValue(UIOutput.java:140)
 at javax.faces.component.UIInput.getValue(UIInput.java:287)
 at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:181)
 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:328)
 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:143)
 at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1654)
 at javax.faces.render.Renderer.encodeChildren(Renderer.java:152)
 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
 at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:468)
 at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170)
 at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132)
 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199)
 at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
 at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1636)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:259)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:757)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:577)
 at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:158)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
 at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
 at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
 at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
 at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
 at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
 at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
 at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
 at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
 at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
 at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
 at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
 at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
 at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
 at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
 at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
 at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
 at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
 at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
 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.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:83)
 ... 69 more

persistence.xml file

<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
    version="2.1">

    <persistence-unit name="PersistenceUnitName"
        transaction-type="JTA">
        <jta-data-source>java:global/DataSourceName</jta-data-source>
        <properties>
            <property name="javax.persistence.schema-generation.database.action" value="drop-and-create" />
        </properties>
    </persistence-unit>
</persistence>

message class


import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Entity implementation class for Entity: Message
 *
 */
@Entity
public class Message  {
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    @Column(nullable = false) @Lob
    private @NotNull String text;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getText() {
        return text;
    }
    public void setText(String text) {
        this.text = text;
    }
    
    
    
}

even with the @Entity annotation and javax.persistence.schema-Generation.database.action with "drop-and-create" value the Message table is not generated, I did some tests, even if I put any random value of the same error in the same, I also noticed that in the schema tab Generation of eclipesis, it is possible to select values like Drop and create and other options, when I selected some option I threw an error "An error has occurred. See error log for more Details. java.lang.Unsupportedoperationexception" I believe the error is in the persistence.xml file but I’m unable to find it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.