- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个我认为是简单的项目,其中我使用 Spring 来管理 JPA,并使用 EclipseLink 作为我的持久性单元。我在前端使用 JavaFX,并将项目分为客户端模块、公共(public)模块和服务器模块。我正在使用 Maven 进行构建。这几天我一直在用头撞墙,试图弄清楚这一点。我尝试了不同的持久性单元配置和 servlet 配置,但似乎没有任何效果。而且错误似乎总是非常相似:事务管理器配置或使用中的某些内容值得怀疑。
非常感谢所有帮助。我是 Spring JPA 领域的新手,如果问题没有得到充分定义,请原谅。
这是我的 pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lamtec</groupId>
<artifactId>NewTrialServer</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>NewTrialServer</name>
<!-- Spring Web MVC -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>unknown-jars-temp-repo</id>
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
<url>file:${project.basedir}/lib</url>
</repository>
<repository>
<url>http://download.eclipse.org/rt/eclipselink/maven.repo/</url>
<id>eclipselink</id>
<layout>default</layout>
<name>Repository for library EclipseLink (JPA 2.0)</name>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.lamtec</groupId>
<artifactId>NewTrialCommon</artifactId>
<version>1.0</version>
</dependency>
<!-- Spring Web MVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<!-- Spring data -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
<!-- JPA -->
<dependency>
<groupId>org.hibernate.java-persistence</groupId>
<artifactId>jpa-api</artifactId>
<version>2.0-cr-1</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.8.Final</version>
</dependency>
<!-- HSQL DB -->
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
</dependency>
<!-- Injection framework -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
这是我的 persistence.xml:
<?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="NewTrialsPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>NewTrials</jta-data-source>
<class>com.lamtec.newtrial.service.Trial</class>
<class>com.lamtec.newtrial.service.TrialCtWtCheck</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
这是我的 servlet:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:data="http://www.springframework.org/schema/data/jpa"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.lamtec"/>
<bean name="trialServiceImpl" class="com.lamtec.newtrial.service.TrialServiceImpl"/>
<bean name="/new-trial.service" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="trialServiceImpl"/>
<property name="serviceInterface" value="com.lamtec.newtrial.service.TrialService"/>
</bean>
<!-- Database Setup -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="NewTrialsPU" />
</bean>
<data:repositories base-package="com.lamtec.newtrial.service.repository"/>
<!-- Transaction Setup -->
<tx:annotation-driven/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
我有两个实体类,试用:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.lamtec.newtrial.service;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "Trial")
public class Trial implements Serializable{
private static final long serialVersionUID = 1L;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Id
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "TRIAL_ID")
private Long trial_Id;
@Column(name = "AUX_ADHESIVE1_WEIGHT")
private String auxAdhesive1Weight;
@Column(name = "AUX_ADHESIVE2_WEIGHT")
private String auxAdhesive2Weight;
@Column(name = "AUX_ADHESIVE_1")
private String auxAdhesive1;
@Column(name = "AUX_ADHESIVE_2")
private String auxAdhesive2;
@Column(name = "CT_WT_RANGE")
private String ctWtRange;
@Column(name = "DRIVE")
private String drive;
@Column(name = "DRIVE_WEIGHT")
private String driveWeight;
@Column(name = "FINISH_WT_ACCEPTABLE_RANGE")
private String finishWtAcceptableRange;
@Basic(optional = false)
@Column(name = "LAMINATOR")
private String laminator;
@Column(name = "LOWER_ADHESIVE")
private String lowerAdhesive;
@Column(name = "LOWER_ADHESIVE_WEIGHT")
private String lowerAdhesiveWeight;
@Column(name = "LOWER_AUX_WEIGHT")
private String lowerAuxWeight;
@Column(name = "LOWER_AUXILLIARY")
private String lowerAuxilliary;
@Column(name = "LOWER_UNWIND")
private String lowerUnwind;
@Column(name = "LOWER_UNWIND_WEIGHT")
private String lowerUnwindWeight;
@Column(name = "TARGET_CT_WEIGHT")
private String targetCtWeight;
@Column(name = "TARGET_TOTAL_FINISHED_WEIGHT")
private String targetTotalFinishedWeight;
@Column(name = "TRIAL_DATE")
private String trialDate;
@Basic(optional = false)
@Column(name = "TRIALNO")
private String trialno;
@Lob
@Column(name = "TRIAL_NOTES")
private String trialNotes;
@Column(name = "TRIAL_START_TIME")
private String trialStartTime;
@Column(name = "UPPER_ADHESIVE")
private String upperAdhesive;
@Column(name = "UPPER_ADHESIVE_WEIGHT")
private String upperAdhesiveWeight;
@Column(name = "UPPER_AUX_WEIGHT")
private String upperAuxWeight;
@Column(name = "UPPER_AUXILLIARY")
private String upperAuxilliary;
@Column(name = "UPPER_UNWIND")
private String upperUnwind;
@Column(name = "UPPER_UNWIND_WEIGHT")
private String upperUnwindWeight;
@Column(name = "YARN")
private String yarn;
@Column(name = "YARN_WEIGHT")
private String yarnWeight;
@OneToMany(cascade={CascadeType.ALL}, mappedBy="trialId", targetEntity=TrialCtWtCheck.class, fetch= FetchType.EAGER)
// @JoinColumn(name="ID")
private List<TrialCtWtCheck> trialCtWtCheckList;
public List<TrialCtWtCheck> getTrialCtWtCheckList() {
return trialCtWtCheckList;
}
public void setTrialCtWtCheckList(List<TrialCtWtCheck> trialCtWtCheckList) {
this.trialCtWtCheckList = trialCtWtCheckList;
}
public Trial() {
super();
}
public Trial(Trial t) {
// this.trial_Id = t.getTrialId();
this.auxAdhesive1Weight = t.getAuxAdhesive1Weight();
this.auxAdhesive2Weight = t.getAuxAdhesive2Weight();
this.auxAdhesive1 = t.getAuxAdhesive1();
this.auxAdhesive2 = t.getAuxAdhesive2();
this.ctWtRange = t.getCtWtRange();
this.drive = t.getDrive();
this.driveWeight = t.getDriveWeight();
this.finishWtAcceptableRange = t.getFinishWtAcceptableRange();
this.laminator = t.getLaminator();
this.lowerAdhesive = t.getLowerAdhesive();
this.lowerAdhesiveWeight = t.getLowerAdhesiveWeight();
this.lowerAuxWeight = t.getLowerAuxWeight();
this.lowerAuxilliary = t.getLowerAuxilliary();
this.lowerUnwind = t.getLowerUnwind();
this.lowerUnwindWeight = t.getLowerUnwindWeight();
this.targetCtWeight = t.getTargetCtWeight();
this.targetTotalFinishedWeight = t.targetTotalFinishedWeight;
this.trialDate = t.getTrialDate();
this.trialno = t.getTrialno();
this.trialNotes = t.getTrialNotes();
this.trialStartTime = t.getTrialStartTime();
this.upperAdhesive = t.getUpperAdhesive();
this.upperAdhesiveWeight = t.getUpperAdhesiveWeight();
this.upperAuxWeight = t.getUpperAuxWeight();
this.upperAuxilliary = t.getUpperAuxilliary();
this.upperUnwind = t.getUpperUnwind();
this.upperUnwindWeight = t.getUpperUnwindWeight();
this.yarn = t.getYarn();
this.yarnWeight = t.getYarnWeight();
this.trialCtWtCheckList = t.getTrialCtWtCheckList();
}
... and getters and setters....
}
和 TrialCtWtCheck:
package com.lamtec.newtrial.service;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
@Entity
@Table(name = "TrialCtWtCheck")
@XmlRootElement
public class TrialCtWtCheck implements Serializable {
private static final long serialVersionUID = 1L;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Id
@Basic(optional = false)
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "COAT_WEIGHT")
private String coatWeight;
@Column(name = "FINISHED_MATERIAL_WT")
private String finishedMaterialWt;
@Column(name = "RAW_MATERIAL_TOT")
private String rawMaterialTot;
@ManyToOne
@JoinColumn(name="TRIAL_ID")
private Trial trialId;
public Trial getTrialId() {
return trialId;
}
public void setTrialId(Trial trialId) {
this.trialId = trialId;
}
public TrialCtWtCheck() {
super();
}
public TrialCtWtCheck(Long id, String coatWeight, String finishedMaterialWt, String rawMaterialTot, Trial trialId) {
this.id = id;
this.coatWeight = coatWeight;
this.finishedMaterialWt = finishedMaterialWt;
this.rawMaterialTot = rawMaterialTot;
}
public TrialCtWtCheck(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCoatWeight() {
return coatWeight;
}
public void setCoatWeight(String coatWeight) {
this.coatWeight = coatWeight;
}
public String getFinishedMaterialWt() {
return finishedMaterialWt;
}
public void setFinishedMaterialWt(String finishedMaterialWt) {
this.finishedMaterialWt = finishedMaterialWt;
}
public String getRawMaterialTot() {
return rawMaterialTot;
}
public void setRawMaterialTot(String rawMaterialTot) {
this.rawMaterialTot = rawMaterialTot;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof TrialCtWtCheck)) {
return false;
}
TrialCtWtCheck other = (TrialCtWtCheck) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.lamtec.newtrials.entity.TrialCtWtCheck[ id=" + id + " ]";
}
}
存储库文件如下所示:
package com.lamtec.newtrial.service.repository;
import com.lamtec.newtrial.service.Trial;
import org.springframework.data.repository.CrudRepository;
public interface TrialRepository extends CrudRepository<Trial, Long> {
}
我的服务:
package com.lamtec.newtrial.service;
import com.lamtec.newtrial.service.repository.TrialRepository;
import java.util.List;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Repository
@Transactional(readOnly=true)
public class TrialServiceImpl implements TrialService {
@Inject private TrialRepository trialRepository;
@Override
public void addTrial(Trial trial) {
trialRepository.save(trial);
}
@Override
@Transactional(readOnly=true)
public List<Trial> listTrials() {
return (List<Trial>)trialRepository.findAll();
}
@Override
public Trial findTrial(Long Id) {
return trialRepository.findOne(Id);
}
@Override
@Transactional(readOnly=false)
public void updateTrial(Trial trial) {
trialRepository.save(trial);
}
}
war 文件在 GlassFish 3.1.2.2 服务器上成功构建并部署。我的开发环境是NetBeans 7.2。
当我针对服务运行客户端时,我得到以下堆栈跟踪:
org.springframework.remoting.RemoteAccessException: Could not deserialize result from HTTP invoker remote service [http://localhost:8080/NewTrialServer/new-trial.service]; nested exception is java.lang.ClassNotFoundException: org.springframework.transaction.CannotCreateTransactionException
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:208)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:145)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy7.listTrials(Unknown Source)
at com.lamtec.newtrialclient.app.TrialsUIPresenter$1.call(TrialsUIPresenter.java:540)
at com.lamtec.newtrialclient.app.TrialsUIPresenter$1.call(TrialsUIPresenter.java:536)
at javafx.concurrent.Task$TaskCallable.call(Task.java:1229)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.springframework.transaction.CannotCreateTransactionException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:622)
at org.springframework.core.ConfigurableObjectInputStream.resolveClass(ConfigurableObjectInputStream.java:79)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.doReadRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:290)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.readRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:241)
at org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.doExecuteRequest(CommonsHttpInvokerRequestExecutor.java:143)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:136)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:192)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:174)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:142)
... 9 more
我在堆栈跟踪中没有看到的一件事是,我在客户端和服务器之间的线路流量中看到的是:
4317 [Thread-4] DEBUG httpclient.wire.content - << "Exception Description: Cannot use an EntityTransaction while using JTA."
这是新的堆栈跟踪:
org.springframework.remoting.RemoteAccessException: Could not deserialize result from HTTP invoker remote service [http://localhost:8080/NewTrialServer/new-trial.service]; nested exception is java.lang.ClassNotFoundException: org.springframework.transaction.CannotCreateTransactionException
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:208)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:145)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy7.listTrials(Unknown Source)
at com.lamtec.newtrialclient.app.TrialsUIPresenter$1.call(TrialsUIPresenter.java:540)
at com.lamtec.newtrialclient.app.TrialsUIPresenter$1.call(TrialsUIPresenter.java:536)
at javafx.concurrent.Task$TaskCallable.call(Task.java:1229)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.springframework.transaction.CannotCreateTransactionException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:622)
at org.springframework.core.ConfigurableObjectInputStream.resolveClass(ConfigurableObjectInputStream.java:79)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.doReadRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:290)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.readRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:241)
at org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.doExecuteRequest(CommonsHttpInvokerRequestExecutor.java:143)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:136)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:192)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:174)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:142)
... 9 more
服务器和 IDE(我在其中启动客户端)之间的消息流量是:
"Could not open JPA EntityManager for transaction"
最佳答案
Caused by: java.lang.ClassNotFoundException: org.springframework.transaction.CannotCreateTransactionException
创建交易时似乎出现错误。这可能是由于 persistance.xml
或 glassfish 配置文件中的配置错误造成的。
<persistence-unit name="NewTrialsPU" transaction-type="JTA">
EntityManagerFactory
无法从 JNDI 找到事务。我没怎么用过glassfish。但这应该是找到实际问题的线索。应该有某种方法来验证 JNDI 资源是否在 glassfish 中创建并相应地使用它。
编辑
要快速解决问题,请考虑使用transaction-type="RESOURCE_LOCAL"
并提供相关的数据库连接
、用户名
和密码
数据库信息应该会有所帮助。
关于java - Spring JPA TransactionManager 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11674722/
我找到了 this excellent question and answer它以 x/y(加上 center x/y 和 degrees/radians)开始并计算旋转- 到 x'/y'。这个计算很
全部: 我已经创建了一个 Windows 窗体和一个按钮。在另一个线程中,我试图更改按钮的文本,但它崩溃了;但是如果我尝试更改按钮的颜色,它肯定会成功。我认为如果您更改任何 Windows 窗体控件属
本网站的另一个问题已证实,C 中没有缩写的字面后缀,并且可以执行以下操作: short Number = (short)1; 但是转换它和不这样做有什么区别: short Number = 1; 您使
我有下表: ID (int) EMAIL (varchar(50)) CAMPAIGNID (int) isSubscribe (bit) isActionByUser (bit) 此表存储了用户对事
也就是说,无需触发Javascript事件即可改变的属性,如何保留我手动选中或取消选中的复选框的状态,然后复制到另一个地方? 运行下面的代码片段并选中或取消选中其中的一些,然后点击“复制”: $('#
我在网上找到的所有关于递增指针导致段错误的示例都涉及指针的取消引用 - 如果我只想递增它(例如在 for 循环的末尾)并且我不在乎它是否最终进入无效内存,因为我不会再使用它。例如,在这个程序中,每次迭
我有一个 Spring MVC REST 服务,它使用 XStream 将消息与 XML 相互转换。 有什么方法可以将请求和响应中的 xml(即正文)打印到普通的 log4j 记录器? 在 Contr
做我的任务有一个很大的挑战,那就是做相互依赖的任务我在这张照片中说的。假设我们有两个任务 A 和 B,执行子任务 A1、A2 和 B1、B2,假设任务 B 依赖于 A。 要理想地执行任务 B,您应该执
通过阅读该网站上的几个答案,我了解到 CoInitialize(Ex) should be called by the creator of a thread 。然后,在该线程中运行的任何代码都可以使
这个问题已经困扰我一段时间了。我以前从未真正使用过 ListViews,也没有使用过 FirebaseListAdapters。我想做的就是通过显示 id 和用户位置来启动列表的基础,但由于某种原因,
我很难解释这两个(看似简单)句子的含义: “受检异常由编译器在编译时检查” 这是什么意思?编译器检查是否捕获了所有已检查的异常(在代码中抛出)? “未经检查的异常在运行时检查,而不是编译时” 这句话中
我有一个包含排除子字符串的文本文件,我想迭代该文件以检查并返回不带排除子字符串的输入项。 这里我使用 python 2.4,因此下面的代码可以实现此目的,因为 with open 和 any 不起作用
Spring 的缓存框架能否了解请求上下文的身份验证状态,或者更容易推出自己的缓存解决方案? 最佳答案 尽管我发现这个用例 super 奇怪,但您可以为几乎任何与 SpEL 配合使用的内容设置缓存条件
我有以下函数模板: template HeldAs* duplicate(MostDerived *original, HeldAs *held) { // error checking omi
如果我的应用程序具有设备管理员/设备所有者权限(未获得 root 权限),我如何才能从我的应用程序中终止(或阻止启动)另一个应用程序? 最佳答案 设备所有者可以阻止应用程序: DevicePolicy
非常简单的问题,但我似乎无法让它正常工作。 我有一个组件,其中有一些 XSLT(用于导航)。它通过 XSLT TBB 使用 XSLT Mediator 发布。 发布后
我正在将一个对象拖动到一个可拖放的对象内,该对象也是可拖动的。放置对象后,它会嵌套在可放置对象内。同样,如果我将对象拖到可放置的外部,它就不再嵌套。 但是,如果我经常拖入和拖出可放置对象,则可拖动对象
我正在尝试为按钮和弹出窗口等多个指令实现“取消选择”功能。也就是说,我希望当用户单击不属于指令模板一部分的元素时触发我的函数。目前,我正在使用以下 JQuery 代码: $('body').click
我从 this question 得到了下面的代码,该脚本用于在 Google tasks 上更改 iframe[src="about:blank"] 内的 CSS使用 Chrome 扩展 Tempe
我有一些 @Mock 对象,但没有指定在该对象上调用方法的返回值。该方法返回 int (不是 Integer)。我很惊讶地发现 Mockito 没有抛出 NPE 并返回 0。这是预期的行为吗? 例如:
我是一名优秀的程序员,十分优秀!