java.lang.VerifyError: Expecting a stackmap frame at branch... JPA+postgresql

java.lang.VerifyError: Expecting a stackmap frame at branch... JPA+postgresql

我在启动方法 return 将一些对象从服务器发送到 ExtJs 时不断收到错误,这让我苦苦挣扎。 我是 JavaEE 的新手,我想我在某个地方犯了错误。

这是来自 JBossDevStudio 控制台的日志:

11:04:37,217 ERROR [io.undertow.request] (default task-20) UT005023: Exception handling request to /SimpleApp/rest/person: org.jboss.resteasy.spi.UnhandledException: java.lang.VerifyError: Expecting a stackmap frame at branch target 18
Exception Details:
Location:
entity/Person._persistence_isAttributeFetched(Ljava/lang/String;)Z @4: ifnull
Reason:
Expected stackmap frame at this location.
Bytecode:
0000000: 2ab4 005f c600 0e2a b400 5f2b b600 bd99
0000010: 0007 04a7 0004 03ac                    

at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.10.Final.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.access[=10=]0(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.server.HttpServerExchange.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_67]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_67]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_67]
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 18
Exception Details:
Location:
entity/Person._persistence_isAttributeFetched(Ljava/lang/String;)Z @4: ifnull
Reason:
Expected stackmap frame at this location.
Bytecode:
0000000: 2ab4 005f c600 0e2a b400 5f2b b600 bd99
0000010: 0007 04a7 0004 03ac                    

at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_67]
at java.lang.Class.forName(Unknown Source) [rt.jar:1.7.0_67]
at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName(PrivilegedAccessHelper.java:88) [eclipselink.jar:2.0.2.v20100323-r6872]
at org.eclipse.persistence.descriptors.ClassDescriptor.convertClassNamesToClasses(ClassDescriptor.java:1214) [eclipselink.jar:2.0.2.v20100323-r6872]
at org.eclipse.persistence.sessions.Project.convertClassNamesToClasses(Project.java:362) [eclipselink.jar:2.0.2.v20100323-r6872]
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:322) [eclipselink.jar:2.0.2.v20100323-r6872]
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151) [eclipselink.jar:2.0.2.v20100323-r6872]
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207) [eclipselink.jar:2.0.2.v20100323-r6872]
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195) [eclipselink.jar:2.0.2.v20100323-r6872]
at org.jboss.as.jpa.container.TransactionScopedEntityManager.createEntityManager(TransactionScopedEntityManager.java:177) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.jpa.container.TransactionScopedEntityManager.getEntityManager(TransactionScopedEntityManager.java:82) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.as.jpa.container.AbstractEntityManager.createQuery(AbstractEntityManager.java:130) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
at main.Controller.getPeople(Controller.java:38) [classes:]
at main.Controller.personSort(Controller.java:48) [classes:]
at main.Controller$Proxy$_$$_WeldClientProxy.personSort(Unknown Source) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_67]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_67]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_67]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_67]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.10.Final.jar:]
... 31 more

当我在 ExtJS 中单击网格上的列标签时,我在服务器上触发方法,该方法应向数据库请求记录,使用我提供的参数对它们进行排序,然后 return 返回给客户端。首先,我想调用 getPeople() 方法而不发生任何崩溃,稍后我会考虑其余部分。 ExtJS 和服务器之间的通信工作正常。 这是我实现的 类 和 persistence.xml:

控制器:

package main;

import java.util.List;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import entity.IPersonDao;
import entity.Person;


  @Path("/")

public class Controller {

@Inject
RestService helloService;

@Inject
IPersonDao personDAO;

@GET
@Path("/person")
@Produces({ "application/json" })
public List<Person> personSort(@QueryParam("page") int page,@QueryParam("start") int start,@QueryParam("limit") int limit,@QueryParam("sort") SortParamList sort)
{
    List<Person> people=personDAO.getPeople(); //after that instruction everything crashes
    //return Response.ok("Ok",MediaType.APPLICATION_JSON).build();
    return people;
}

}

人:

package entity;

import java.io.Serializable;

import javax.inject.Inject;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

@SuppressWarnings("serial")

@XmlRootElement
@Table(name="People")
@Entity
public class Person implements Serializable{
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long Id;

    protected String Imie;
    protected String Nazwisko;
    protected String Pesel;

    @Inject
    public Person()
    {}

    public Person(String imie,String nazwisko,String pesel)
    {
        this.Imie=imie;
        this.Nazwisko=nazwisko;
        this.Pesel=pesel;

    }

    public String getImie() {
        return Imie;
    }

    public void setImie(String imie) {
        Imie = imie;
    }

    public String getNazwisko() {
        return Nazwisko;
    }

    public void setNazwisko(String nazwisko) {
        Nazwisko = nazwisko;
    }

    public String getPesel() {
        return Pesel;
    }

    public void setPesel(String pesel) {
        Pesel = pesel;
    }



}

IPersonDao:

package entity;

import java.util.List;

import javax.ejb.Local;

@Local
public interface IPersonDao {

    public abstract List<Person> getPeople();

}

PersonDao:

package entity;

import java.util.List;

import javax.ejb.Stateful;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;


@Stateful
public class PersonDAO implements IPersonDao {

//  @PersistenceContext(unitName="SimpleApp")
    @Inject
    private EntityManager em;

    //public void Persist(Person person){ ???!?!?!!? O_o
    //  em.persist(person);
    //}
    /* (non-Javadoc)
     * @see entity.IPersonDao#getPeople()
     */

    public List<Person> getPeople(){
        TypedQuery<Person> query=em.createQuery("Select p FROM Person p Order by p.Id",Person.class);
        return query.getResultList();
    }
}

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
       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">
       <persistence-unit name="SimpleApp" transaction-type="JTA">
             <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
             <jta-data-source>java:jboss/datasources/sampleDS</jta-data-source>

             <class>entity.Person</class>
              <properties>
                    <!-- Properties for Hibernate -->
                    <property name="hibernate.connection.url" value="jdbc:postgresql://localhost/sampleDB"/>
                    <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
                    <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
                    <property name="hibernate.connection.username" value="postgres"/>
                    <property name="hibernate.connection.password" value="admin"/>
                    <!--property name="hibernate.archive.autodetection" value="class"/ -->
                    <property name="hibernate.show_sql" value="true" />
                    <property name="hibernate.format_sql" value="true" />
                    <!--property name="hibernate.hbm2ddl.auto" value="update" /-->
                    <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
                    <property name="javax.persistence.sql-load-script-source" value="META-INF/db_init.sql"/>
                    <property name="javax.persistence.schema-generation.scripts.action" value="none"/>

             </properties>
       </persistence-unit>
</persistence>

我尝试了很多与@Inject 或 PersistenContext 的组合。 我尝试了 UseSplitVerifier 选项但没有任何效果。

原来是ExtJs客户端和JavaEE服务器之间的REST通信有问题。我已经设置了新的动态项目并像这样放置 persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" 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">
  <persistence-unit name="y" transaction-type="JTA">
    <jta-data-source>java:jboss/datasources/sampleDS</jta-data-source>
    <class>entity.Person</class>
    <properties>
      <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
      <property name="javax.persistence.jdbc.url"    value="jdbc:postgresql://localhost/sampleDB" />
      <property name="javax.persistence.jdbc.user" value="postgres" />    
      <property name="javax.persistence.jdbc.password" value="admin" />
      <property name="eclipselink.ddl-generation" value="create-tables" />
      <property name="eclipselink.ddl-generation.output-mode" value="database" />
    </properties>
  </persistence-unit>
</persistence>

我还在这个数据源中加入了 wildfly 配置:

 <datasource jndi-name="java:jboss/datasources/sampleDS" pool-name="sampleDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:postgresql://localhost/sampleDB</connection-url>
                    <driver>postgresql</driver>
                    <security>
                        <user-name>postgres</user-name>
                        <password>admin</password>
                    </security>
                </datasource>

剩下的只是从一个项目到另一个项目的 copy/paste 操作。目前一切正常。但是我无法解释问题的根源。