ejb-3.0

How to access the file system from an EJB 3?

只谈情不闲聊 提交于 2019-11-28 21:14:08
I would like to know how can I access the file system from an EJB 3 bean? I searched the Internet on the subject and haven't found a good answer. Some suggest using the java.io/java.nio even though the specification prohibits this usage. Most application servers seem to allow the access to this API anyway. Another idea would be to use an JCA connector to access the file system or a LDAP directory. What I want to do this to avoid the use of BLOB in the database when a simple file would be a much better solution in terms of performance and used resources. How would you solve this problem? The

Can @Resource be used to inject primitives in EJB3.0?

北城余情 提交于 2019-11-28 17:20:17
Using Glassfish, I can setup a string jndi entry: JNDI name: "com/xyzcompany/echo/EchoServiceBean/viewName" Factory Class: org.glassfish.resources.custom.factory.PrimitivesAndStringFactory Properties: value="Testing123" I can then inject this container configured string into my EJB: @Resource(lookup = "com/xyzcompany/echo/EchoServiceBean/viewName") String viewName; The lookup= appears to internally do an InitialContext.lookup(...). However, this uses ejb3.1, but unfortunately my prod environment is only ejb3.0. I guess i'm trying to figure out is there a way to use @Resource(name=) or

EJB3 Transaction Propagation

无人久伴 提交于 2019-11-28 17:15:52
I have a stateless bean something like: @Stateless public class MyStatelessBean implements MyStatelessLocal, MyStatelessRemote { @PersistenceContext(unitName="myPC") private EntityManager mgr; @TransationAttribute(TransactionAttributeType.SUPPORTED) public void processObjects(List<Object> objs) { // this method just processes the data; no need for a transaction for(Object obj : objs) { this.process(obj); } } @TransationAttribute(TransactionAttributeType.REQUIRES_NEW) public void process(Object obj) { // do some work with obj that must be in the scope of a transaction this.mgr.merge(obj); // ..

Best current framework for unit testing EJB3 / JPA [closed]

孤街醉人 提交于 2019-11-28 16:54:09
Starting a new project using EJB 3 / JPA, mainly stateless session beans and batch jobs. I've used JUnit in the past on standard Java webapps and it seemed to work pretty well. In EJB2 unit testing was a pain and required a running container such as JBoss to make the calls into. Now that we're going to be working in EJB3 / JPA I'd like to know what companies are using to write and run these tests. Are Junit and JMock still considered relevant or are there other newer frameworks that have come around that we should investigate? ewernli IMHO, yes they are still relevant. With EJB3, you can test

Where can I find good unit testing resources for EJB and J2EE? [closed]

瘦欲@ 提交于 2019-11-28 16:45:36
Which online resources , tutorials or books can you recommended to get started with unit testing J2EE / EJB3 applications? So far I have found ejb3unit , Jakarta Cactus (retired 2011/08) and the Maven Cargo plugin . It would be helpful if there are complete working examples, ready to run. Target containers are the open source products GlassFish , JBoss and Apache OpenEJB . EJB Unit Testing with Eclipse and OpenEJB Article on Testing EJB Glassfish EJB 3.0 Unit testing JUnitEE Tutorial Effective Unit Testing EJB 3.0 with OpenEJB JUnitEE IBM Tutorial The next version NetBeans 6.8 includes a nice

Why do we need separate Remote and Local interfaces for EJB 3.0 session beans

我是研究僧i 提交于 2019-11-28 16:42:03
问题 I was wondering why do we need separate Remote and Local intefaces for EJB 3.0 Session beans. I guess most of the time they would both be defining the same contract. Why cant I have a common interface and in my Bean I should just be able to say that I want this bean to be accessed remotely and/or locally. thanks Vikas 回答1: This is what the EJB spec says: The choice between the local and the remote programming model is a design decision that the Bean Provider makes when developing the

EJB 3.1 or Spring 3.. When to choose which one?

醉酒当歌 提交于 2019-11-28 16:28:12
问题 EJB achieved many improvements in 3.x versions, Spring is also commonly used and version 3 is a good alternative. There are many articles on web, but no exact comparison about ejb3x versus spring3x.. Do you have any ideas about them, in real world examples which one is better at which conditions? For example, we want to separate db and server, which means our application will be on a server, our database will be in another server.. EJB remoting vs Cluster4Spring etc ? Doing everyting

Howto secure webservices on GlassFish 2?

冷暖自知 提交于 2019-11-28 11:49:50
We have some staleless EJBs (EJB3) deployed on a GlassFish 2 server that expose some of their methods as webservices via the @Webmethod annotation. Now we want to secure these webservice methods so that only authenticated clients can call it. What would be a good way to achieve this? Like the good reverend said. Example below uses a file realm for authentication. @Stateless @WebService(name = "MyAppServices") @RolesAllowed({"user"}) public class ItemEJB { ... } You will also need sun-ejb-jar.xml e.g. <sun-ejb-jar> <security-role-mapping> <!-- as defined in @RolesAllowed --> <role-name>user<

Doubt regarding JPA namedquery

穿精又带淫゛_ 提交于 2019-11-28 11:45:21
问题 I am trying to execute a namedquery @NamedQuery(name="getEmployeeDetails",query="select e.username,e.email,e.image,e.firstname,e.lastname from Employee e where e.empid=?1") Now when I execute this query in a EJB 3.0 Session Bean what is the object I should return.I tried returning Listits returning a Vector which creates a classcast exception.The employee table contains fields like password and other confidential details which I don't want to fetch.So I am not using select e from Employee e .

EJB 3 injection into spring beans

故事扮演 提交于 2019-11-28 11:34:20
I've made a mavenized web application with spring, spring security... Now, I want to add ejb module for database access, I was looking on the internet but I didn't find something clear because it's my first time with EJB. I want to use something like @EJB in my controller like" @Stateless(name = "CustomerServiceImpl") public class CustomerServiceImpl implements CustomerService @EJB private MyEjb myEjb; and how can I configure it in spring context if there is a tutorial or any other help. It will be great and thank you Vishal Akkalkote To inject your ejb 3 bean in spring bean you can follow