ejb

Does OpenJPA work well with Glassfish?

南笙酒味 提交于 2019-12-19 21:19:23
问题 Is anyone successfully using OpenJPA with Glassfish? I'm trying to use OpenJPA 2.1 with Glassfish 3.1 Open Source. I've followed the instructions to integrate the two here -> http://weblogs.java.net/blog/ss141213/archive/2006/07/using_openjpa_a.html I have a very simple EJB project in Eclipse Indigo with the following: com.rares.test.Person - @Entity com.rares.test.PersonManager - interface com.rares.test.PersonDao - @Stateless However, when I try to deploy I get a ClassNotFoundException on

Does OpenJPA work well with Glassfish?

半城伤御伤魂 提交于 2019-12-19 21:19:11
问题 Is anyone successfully using OpenJPA with Glassfish? I'm trying to use OpenJPA 2.1 with Glassfish 3.1 Open Source. I've followed the instructions to integrate the two here -> http://weblogs.java.net/blog/ss141213/archive/2006/07/using_openjpa_a.html I have a very simple EJB project in Eclipse Indigo with the following: com.rares.test.Person - @Entity com.rares.test.PersonManager - interface com.rares.test.PersonDao - @Stateless However, when I try to deploy I get a ClassNotFoundException on

Can CDI inject standard library POJOs into an EJB?

柔情痞子 提交于 2019-12-19 17:46:02
问题 I can inject my own POJO into a managed object like this: import javax.ejb.Stateless; import javax.inject.Inject; @Stateless public class SomeEjb { @Inject private SomePojo somePojo; } And I have this POJO: // No annotations public class SomePojo { } This works fine. If I inject the EJB into a JSF backing-bean, I can see that the value of somePojo is non-null value, as expected. However, if I try to inject a java.util.Date into SomeEjb , I get the following exception on deployment: Severe:

Mocking EJB injection in tests

岁酱吖の 提交于 2019-12-19 08:12:55
问题 Whenever I want to test a class which uses resource injection I end up including a constructor that will only be used within the test: public class A { @EJB B b; // Used in tests to inject EJB mock protected A(B b) { this.b = b; } public A() {} // Method that I wish to test public void foo() { b.bar(); } } Is there another way of mocking resource injection or this is the correct pattern to follow? 回答1: you could use easy gloss to that effect, it mocks the EJBs injection system. another way is

Why do EJB beans with bean-managed transactions act as a “transaction barrier”?

左心房为你撑大大i 提交于 2019-12-19 07:49:58
问题 A quote from the EJB 3.1 specification: 13.6.1 Bean-Managed Transaction Demarcation The container must manage client invocations to an enterprise bean instance with bean-managed transaction demarcation as follows. When a client invokes a business method via one of the enterprise bean’s client views, the container suspends any transaction that may be associated with the client request. On the other hand, a transaction from a stand-alone client or another EJB is propagated into a bean using

JAVA新手学习指南

久未见 提交于 2019-12-19 04:48:03
http://hi.baidu.com/happyxjx/blog/item/8bf73cdfb84b9317622798e3.html 每个人的学习方法是不同的,一个人的方法不见得适合另一个人,我只能是谈自己的学习方法。因为我学习Java是完全自学的,从来没有问过别人,所以学习的过程基本上完全是自己摸索出来的。我也不知道这种方法是否是比较好的方法,只能给大家提供一点参考了。 学习Java的第一步是安装好JDK,写一个Hello World。其实JDK的学习没有那么简单,关于JDK有两个问题是很容易一直困扰 Java程序员的地方:一个是CLASSPATH的问题,其实从原理上来说,是要搞清楚JRE的ClassLoader是如何加载Class的;另一个问题是package和import问题,如何来寻找类的路径问题。把这两个问题摸索清楚了,就扫除了学习Java和使用JDK的最大障碍。推荐看一下王森的《Java深度历险》,对这两个问题进行了深入的探讨。 第二步是学习Java的语法。Java的语法是类C++的,基本上主流的编程语言不是类C,就是类C++的,没有什么新东西,所以语法的学习,大概就是半天的时间足够了。唯一需要注意的是有几个不容易搞清楚的关键字的用法,public,protected,private,static,什么时候用,为什么要用,怎么用,这可能需要有人来指点一下

EJB testing with TomEE embedded EJBContainer api: java.lang.ClassFormatError exception

一笑奈何 提交于 2019-12-19 03:14:08
问题 I would test my EJB with TomEE embedded EJBContainer. This is my JUnit test case skeleton: package com.xxx.indexer.scheduler.service; import java.util.Properties; import javax.ejb.embeddable.EJBContainer; import javax.naming.NamingException; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.xxx.indexer.scheduler.AbstractTest; public class BookingAuditServiceImplTest extends AbstractTest { private static EJBContainer container

@EJB annotation vs JNDI lookup

有些话、适合烂在心里 提交于 2019-12-18 17:25:14
问题 Is there any situation where it's better to use JNDI than to inject a stateless session bean using the @EJB annotation? We're using JSF 1.2 with Sun Application Server 9.0_01. Our team is debating which approach is better when using SLSBs in a Managed Bean. I've read the following questions, but was wondering if there was a situation where lookup is preferred. EJB3 - obtaining bean via injection vs lookup - what are the differences, implications, gotchas? @EJB injection vs lookup -

How can I inject an EJB from an other application on the same GlassFish Server?

随声附和 提交于 2019-12-18 13:36:56
问题 I have two applications running on my local glassfish server. One to rent bicylces and one to buy train tickets. I now wanted to call a remote ejb from the train application to allow the rental of bicycles for the chosen time but I'm not really sure how to do it. I already tried a few different approaches. Both applications are in different packages and the train application has to know the bicycle remote interface but I don't know how to accomplish that. The remote interface (bicyle app):

“Local transaction already has 1 non-XA Resource: cannot add more resources” error

不羁的心 提交于 2019-12-18 13:35:42
问题 After reading previous questions about this error, it seems like all of them conclude that you need to enable XA on all of the data sources. But: What if I don't want a distributed transaction? What would I do if I want to start transactions on two different databases at the same time, but commit the transaction on one database and roll back the transaction on the other? I'm wondering how my code actually initiated a distributed transaction. It looks to me like I'm starting completely