- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在练习一个使用 spring、hibernate 库和 Weblogic JTA 平台作为 JTA 事务管理器的 Web 应用程序,该应用程序已成功部署在 Oracle weblogic 12c Server 上。当我尝试使用 Hibernate DAO 执行任何数据库操作时,我收到以下错误
<May 10, 2018 9:40:56 AM IST> <Warning> <org.apache.cxf.phase.PhaseInterceptorChain> <BEA-000000> <Application {http://stockquote.cxf.deployable.wls.com/}StockQuotePortTypeImplService#{http://wls.deployable.cxf.com/stockquote}GetLastTradePrice has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:267)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:85)
Truncated. see log file for complete stacktrace
Caused By: javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:288)
at com.sun.proxy.$Proxy263.persist(Unknown Source)
at com.wls.deployable.cxf.jms.dao.impl.AbstractGenericDAOImpl.save(AbstractGenericDAOImpl.java:54)
at com.wls.deployable.cxf.jms.bo.impl.MobileBOImpl.save(MobileBOImpl.java:32)
at com.wls.deployable.cxf.stockquote.StockQuotePortTypeImpl.getLastTradePrice(StockQuotePortTypeImpl.java:51)
Truncated. see log file for complete stacktrace
请帮帮我。下面是配置文件和DAO类
================applicationContext.xml========================
<!-- Database Configuration -->
<import resource="../database/DataSource.xml" />
<import resource="../database/Hibernate.xml" />
<context:component-scan base-package="com.wls.deployable.cxf" />
<bean id="stock" class="com.wls.deployable.cxf.stockquote.StockQuotePortTypeImpl" />
<jaxws:endpoint id="stockService" implementor="#stock" address="/StockService" />
<bean id="abstractGenericDao" class="com.wls.deployable.cxf.jms.dao.impl.AbstractGenericDAOImpl" abstract="true" />
<bean id="mobileDAO" class="com.wls.deployable.cxf.jms.dao.impl.MobileDAOImpl" parent="abstractGenericDao" />
<bean id="mobileBO" class="com.wls.deployable.cxf.jms.bo.impl.MobileBOImpl">
<property name="mobileDAO" ref="mobileDAO"></property>
</bean>
==============DataSource.xml======================
<jee:jndi-lookup id="devUserDatasource" jndi-name="jdbc.devUserDatasource1" expected-type="javax.sql.DataSource" />
==============Hibernate.xml============================
<import resource="DataSource.xml" />
<tx:jta-transaction-manager />
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="oracleEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</prop>
<prop key="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform</prop>
</props>
</property>
<property name="packagesToScan" value="com.wls.deployable.cxf" />
<property name="persistenceUnitName" value="oraclePU" />
<property name="jtaDataSource" ref="devUserDatasource" />
<property name="persistenceXmlLocation" value="classpath:META-INF/oraclePersistence.xml" />
</bean>
========================DAO 类================================
public abstract class AbstractGenericDAOImpl<T> implements GenericDAO<T> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractGenericDAOImpl.class);
@PersistenceContext(name="oraclePU")
@Qualifier("oracleEntityManagerFactory")
private EntityManager em;
public EntityManager getEm() {
return em;
}
public void setEm(EntityManager em) {
this.em = em;
}
@Transactional(isolation=Isolation.READ_COMMITTED, readOnly=false, rollbackFor=Exception.class, propagation=Propagation.REQUIRED)
public T get(Class<T> clazz, Serializable id) {
return em.find(clazz, id);
}
@Transactional(isolation=Isolation.READ_COMMITTED, readOnly=false, rollbackFor=Exception.class, propagation=Propagation.REQUIRED)
public void update(T domain) {
em.merge(domain);
}
@Transactional(isolation=Isolation.READ_COMMITTED, readOnly=false, rollbackFor=Exception.class, propagation=Propagation.REQUIRED)
public void remove(T domain) {
em.remove(domain);
}
@Transactional(isolation=Isolation.READ_COMMITTED, readOnly=false, rollbackFor=Exception.class, propagation=Propagation.REQUIRED)
public void save(T domain) {
if(em != null) {
LOG.info("========> PERSISTING MOBILE <========");
}
em.persist(domain);
}
}
========================WebService 实现==============================
@WebService(endpointInterface="com.cxf.deployable.wls.stockquote.StockQuotePortType")
public class StockQuotePortTypeImpl implements StockQuotePortType {
@Autowired
MobileBOImpl mobileBO;
@Autowired
DataSource ds;
private static final Logger LOGGER = LoggerFactory.getLogger(StockQuotePortTypeImpl.class);
@Override
public TradePrice getLastTradePrice(TradePriceRequest body) {
JdbcTemplate temp = new JdbcTemplate(ds);
temp.update("UPDATE MOBILE SET MODELNAME ='iPhone' WHERE ID = 3");
LOGGER.info("Done JDBCTEMPLATE update ...");
Mobile mobile = new Mobile();
mobile.setId(9);
mobile.setBrand("Samsung");
mobile.setModelName("Galaxy S8");
mobile.setOs("Android");
LOGGER.info("Update DB with Hibernate BO/DO .. !!!");
mobileBO.save(mobile);
LOGGER.info("Database updated .. !!!");
TradePrice tradePrice = new TradePrice();
tradePrice.setPrice(100f);
return tradePrice;
}
}
==================oraclePersistence.xml====================
<persistence-unit name="oraclePU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>devUserDatasource</jta-data-source>
<class>com.distributed.tx.demo.distTxDemo.entities.Feature</class>
<class>com.distributed.tx.demo.distTxDemo.entities.Mobile</class>
</persistence-unit>
==================web.xml==============================
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring/config/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
下面是我的 Maven 依赖树
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ wls-deployable-cxf ---
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2
[INFO] wls.springcxf:wls-deployable-cxf:war:0.0.1-SNAPSHOT
[INFO] +- com.oracle:ojdbc6:jar:11.2.0:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.12:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:test
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:3.2.1:compile
[INFO] | +- xml-resolver:xml-resolver:jar:1.2:compile
[INFO] | +- org.apache.cxf:cxf-core:jar:3.2.1:compile
[INFO] | | +- com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[INFO] | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | | \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.2:compile
[INFO] | +- org.apache.cxf:cxf-rt-bindings-soap:jar:3.2.1:compile
[INFO] | | +- org.apache.cxf:cxf-rt-wsdl:jar:3.2.1:compile
[INFO] | | | \- wsdl4j:wsdl4j:jar:1.6.3:compile
[INFO] | | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:3.2.1:compile
[INFO] | +- org.apache.cxf:cxf-rt-bindings-xml:jar:3.2.1:compile
[INFO] | +- org.apache.cxf:cxf-rt-frontend-simple:jar:3.2.1:compile
[INFO] | \- org.apache.cxf:cxf-rt-ws-addr:jar:3.2.1:compile
[INFO] | \- org.apache.cxf:cxf-rt-ws-policy:jar:3.2.1:compile
[INFO] | \- org.apache.neethi:neethi:jar:3.1.0:compile
[INFO] +- org.apache.cxf:cxf-rt-transports-http:jar:3.2.1:compile
[INFO] +- org.apache.cxf.xjc-utils:cxf-xjc-runtime:jar:3.0.5:compile
[INFO] | \- javax.xml.bind:jaxb-api:jar:2.2.12:compile
[INFO] +- org.springframework:spring-web:jar:5.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-beans:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:5.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-jcl:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-expression:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:5.0.5.RELEASE:test
[INFO] +- org.springframework:spring-jms:jar:5.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-messaging:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-asm:jar:3.1.4.RELEASE:compile
[INFO] +- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.8.13:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.3.1.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
[INFO] | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | +- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.4.Final:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.3.1.Final:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] +- antlr:antlr:jar:2.7.7:compile
[INFO] +- javassist:javassist:jar:3.12.0.GA:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.5:compile
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] +- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- javax.servlet:servlet-api:jar:3.0-alpha-1:compile
[INFO] +- org.apache.activemq:activemq-all:jar:5.15.3:compile
[INFO] +- com.oracle.weblogic:weblogic-t3thinclient:jar:1.0:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.7:compile
[INFO] +- commons-io:commons-io:jar:1.3.2:compile
[INFO] +- org.ow2.asm:asm:jar:6.1.1:compile
[INFO] +- org.springframework:spring-aspects:jar:5.0.5.RELEASE:compile
[INFO] \- cglib:cglib-nodep:jar:3.2.6:compile
请帮帮我,我已经为此苦苦挣扎了很长时间。
提前致谢.!!
最佳答案
我找到了问题的解决方案,我在 spring 的 applicationContext.xml 中缺少 tx:annotationDriven 元素。添加该元素启动了 Spring aop 启用的事务管理,它使用 WeblogicJtaTransactionManager 来管理事务隐式..!!
关于java - 由 : javax. persistence.TransactionRequiredException 引起:在带有 Spring JTA 事务的 Weblogic 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50208203/
我想使用 li 和 ul 制作一个多级下拉列表,以便显示我博客中按年和月排序的所有文章。我希望我的下拉菜单看起来像 Google Blogspot 下拉菜单: 这是我的 CSS 和 HTML 代码 u
我在 Win 7 64 机器上将 CodeBlocks 与 gcc 4.7.2 和 gmp 5.0.5 结合使用。开始使用 gmpxx 后,我看到一个奇怪的段错误,它不会出现在 +、- 等运算符中,但
我正在使用 tern 为使用 CodeMirror 运行的窗口提供一些增强的智能感知,它工作正常,但我遇到了一个问题,我想添加一些自定义“types”,可以这么说,这样下拉列表中它们旁边就有图标了。我
我正在尝试让我的 PC 成为 Android 2.3.4 设备的 USB 主机,以便能够在不需要实际“附件”的情况下开发 API。为此,我需要将 PC 设置为 USB 主机和“设备”(在我的例子中是运
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
我在设置服务器方面几乎是个新手,但遇到了一个问题。我有一个 Ubuntu 16.04 VPS 并安装了 Apache2 和 Tomcat7。我正在为 SSL 使用 LetsEncrypt 和 Cert
我在一个基于谷歌地图的项目上工作了超过 6 个月。我使用的是 Google Maps API V1 及其开发人员 API key 。当我尝试发布应用程序时,我了解到 Google API V1 已被弃
我是 Python 的新手,所以如果我对一些简单的事情感到困惑,请原谅。 我有一个这样的对象: class myObject(object): def __init__(self):
这个问题已经有答案了: How can I access object properties containing special characters? (2 个回答) 已关闭 9 年前。 我正在尝
我有下面的 CSS。我想要的是一种流体/液体(因为缺乏正确的术语)css。我正在为移动设备开发,当我改变模式时 从纵向 View 到陆地 View ,我希望它流畅。现在的图像 在陆地 View 中效
我正在尝试使用可以接受参数的缓存属性装饰器。 我查看了这个实现:http://www.daniweb.com/software-development/python/code/217241/a-cac
这个问题在这里已经有了答案: Understanding slicing (36 个答案) 关闭 6 年前。 以a = [1,2,3,4,5]为例。根据我的直觉,我认为 a[::-1] 与 a[0:
mysqldump -t -u root -p mytestdb mytable --where=datetime LIKE '2014-09%' 这就是我正在做的事情,它会返回: mysqldum
我正在制作销售税计算器,除了总支付金额部分外,其他一切都正常。在我的程序中,我希望能够输入一个数字并获得该项目的税额我还希望能够获得支付的总金额,包括交易中的税金。到目前为止,我编写的代码完成了所有这
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为
我是否必须进行任何额外的设置才能让 apache-airflow 在任务失败时向我发送电子邮件。我的配置文件中有以下内容(与默认值保持不变): [email] email_backend = airf
这个问题在这里已经有了答案: What does the $ symbol do in VBA? (5 个回答) 3年前关闭。 使用返回字符串(如 Left)的内置函数有什么区别吗?或使用与 $ 相同
我有一个用VB6编写的应用程序,我需要使用一个用.NET编写的库。有什么方法可以在我的应用程序上使用该库吗? 谢谢 最佳答案 这取决于。您可以控制.NET库吗? 如果是这样,则可以修改您的库,以便可以
当我创建一个以 ^ 开头的类方法时,我尝试调用它,它给了我一个错误。 class C { method ^test () { "Hi" } } dd C.new.test; Too m
我已经使用 bower 安装了 angularjs 和 materialjs。 凉亭安装 Angular Material 并将“ngMaterial”注入(inject)我的应用程序,但出现此错误。
我是一名优秀的程序员,十分优秀!