我正在尝试使用 JPAcontainer 显示使用 vaadin 表的内容,但我在 JPAContainer 实例中植入了 NullPointerException。
我已经使用了hibernate和eclipselink,并且使用它们我有相同的结果......
我正在使用 Glassfish 3.1、java 7、vaadin 7.1.5、JPAContainer 3.1.0 和 Hibernate 4
我还没有在网上找到解决方案,也没有找到有类似问题的论坛。我希望有人能帮助我。
这是我的持久性文件。
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="admin" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>jdbc/admin</non-jta-data-source>
<class>entities.Proyecto</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
</properties>
</persistence-unit>
</persistence>
这是我的实体类:
@Entity
public class Proyecto extends AbstractEntity {
private String nombre;
private String urlBase;
public Proyecto() {
}
public Proyecto(String nombre, String urlBase) {
this.nombre = nombre;
this.urlBase = urlBase;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return super.id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getUrlBase() {
return urlBase;
}
public void setUrlBase(String urlBase) {
this.urlBase = urlBase;
}
}
这里是我用 JPAContainer 调用表的地方:
JPAContainer<Proyecto> cont = JPAContainerFactory.make(Proyecto.class, "admin");
proysTable = new Table(null, cont);
proysTable.setImmediate(true);
proysTable.setVisibleColumns("nombre", "urlBase");
proysTable.setWidth("100.0%");
proysTable.setHeight("100.0%");
proyectosLayout.addComponent(proysTable);
最后,堆栈跟踪如下:
**SEVERE: java.lang.NullPointerException
at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.doGetEntityCount(LocalEntityProvider.java:505)
at com.vaadin.addon.jpacontainer.provider.CachingSupport$FilterCacheEntry.getEntityCount(CachingSupport.java:157)
at com.vaadin.addon.jpacontainer.provider.CachingSupport.getEntityCount(CachingSupport.java:826)
at com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider.getEntityCount(CachingMutableLocalEntityProvider.java:130)
at com.vaadin.addon.jpacontainer.JPAContainer.size(JPAContainer.java:912)
at com.vaadin.ui.AbstractSelect.size(AbstractSelect.java:762)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1632)
at com.vaadin.ui.Table.attach(Table.java:4147)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:478)
at com.vaadin.ui.AbstractSingleComponentContainer.setContent(AbstractSingleComponentContainer.java:137)
at com.vaadin.ui.UI.setContent(UI.java:1158)
at Admin.init(Admin.java:33)
at com.vaadin.ui.UI.doInit(UI.java:610)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:223)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:73)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:724)
WARNING: StandardWrapperValve[Admin$Servlet]: PWC1406: Servlet.service() for servlet Admin$Servlet threw exception
java.lang.NullPointerException
at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.doGetEntityCount(LocalEntityProvider.java:505)
at com.vaadin.addon.jpacontainer.provider.CachingSupport$FilterCacheEntry.getEntityCount(CachingSupport.java:157)
at com.vaadin.addon.jpacontainer.provider.CachingSupport.getEntityCount(CachingSupport.java:826)
at com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider.getEntityCount(CachingMutableLocalEntityProvider.java:130)
at com.vaadin.addon.jpacontainer.JPAContainer.size(JPAContainer.java:912)
at com.vaadin.ui.AbstractSelect.size(AbstractSelect.java:762)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1632)
at com.vaadin.ui.Table.attach(Table.java:4147)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:571)
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:478)
at com.vaadin.ui.AbstractSingleComponentContainer.setContent(AbstractSingleComponentContainer.java:137)
at com.vaadin.ui.UI.setContent(UI.java:1158)
at Admin.init(Admin.java:33)
at com.vaadin.ui.UI.doInit(UI.java:610)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:223)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:73)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:724)**