- 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/
这个问题在这里已经有了答案: Different ways of loading a file as an InputStream (6 个答案) 关闭 8 年前。 在我的 gradle java
给定一个 User 类: class User end 我想使用 .class_eval 定义一个新常量.所以: User.class_eval { AVOCADO = 'fruit' } 如果我尝试
这可能听起来很奇怪,但我正在开发一个需要查找 div 内的元素或 div 本身的插件。 脚本根据用户选择查找元素,但内容(包括标记)是可变的。因此脚本将按如下方式查找元素: $('.block').f
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 Improve th
我需要在按我自己的函数排序的对的多集中查找并删除一个值。显然, .find 总是将迭代器返回到末尾,而不是返回到搜索到的值。有小费吗?这是函数: struct cmp { bool operato
求助!我将如何通过遍历查看字符并计算有效字符出现之前的下划线数量来查找和删除前导下划线。以及从字符串末尾向后迭代以查找任何尾随下划线。 我可以使用下面的方法来删除下划线,但是如何迭代才能找到下划线。
如果你在 $(xml) 中有下面的 xml,你会变得懒惰: $(xml).find("animal").find("dog").find("beagle").text() 在 jQuery 中是否有类
你如何找到4个文件的交集? 我用了grep -Fx -f 1.txt 2.txt 3.txt 4.txt ,但它似乎只适用于 2 个文件。同样comm -12 1.txt 2.txt无法扩展为 4 个
我已经完成了标记的姿势估计并获得了 rvec 和 tvec 值。我不知道如何找到它的中心,因为我需要绘制一个需要中心值的圆柱体。 我该怎么做? 最佳答案 标记的 tvec 是标记从原点的平移 (x,y
我有一个任务,我需要找到 2 个单链接(单对单)列表的交集。我还必须为 2 个双向链接(双重 vs 双重)列表执行此操作: 对于单链表,我使用 mergeSort() 对两个列表进行排序,然后逐项比较
我是 R 的新手,我有一个 100x100 的方阵。我想找到这个矩阵的最大特征值。我试过了 is.indefinite(x) 但是它写 is.indefinite(x) : argument x is
您好,我是 svg 和 JavaScript 的新手,当鼠标位于 svg 上方时,我试图使一些 svg 元素弹出(通过缩放),反之亦然,当鼠标离开 svg 元素时。 我已经能够通过使用转换使 svg
我正在尝试为 scala 项目编写一个类,但在多个地方使用 class、def、while 等关键字出现此错误。 它发生在这样的地方: var continue = true while (conti
我有两个 pandas 数据框,它们只取自一列并将日期列设置为索引,所以现在我有两个 Series。我需要找到这些系列的相关性。 这里有几行来自dfd: index change 2018-
我正在尝试调整我的 Vagrantfile,因此如果它丢失,它会自动在项目根目录中创建一个文件夹。创建文件夹没问题,但我无法找到创建该文件夹的位置。 我发现此信息可在 Vagrant::Environ
我正在尝试在 jquery 中找到 Test3 的位置,请有人引导我走上正确的道路。 我需要jquery来显示5 Test7 Test2 Test6 Test5 Test3 Test8 谢谢 最佳
大家早上好 我有一个像这样的图像列表: 使用 jQuery 如何查找 ul#preload 中包含特定字符串(例如“green”)的所有图像 src 类似... var new_src = j
我正在开发一个修改 Excel 文件的应用程序。 如何找到任意行中最后使用的单元格? 示例:行号 => 5 中最后使用的单元格 最佳答案 要找到一行中的最后一个单元格,您需要 Range 的 End
我刚刚陷入 react native ,需要一些帮助才能在找到 token 时导航到 protected 屏幕。我应该在哪里寻找应用程序加载时的 token ?如何在不多次调用导航的情况下导航用户一次
非常奇怪...此页面是 protected 内容还是我不知道的内容?我尝试单击下一页 anchor 。 参见this page first. 我试图用这个来抓取元素 var buttonNext =
我是一名优秀的程序员,十分优秀!