java-ee

How can I manage to use 2 persistense units and make my app to recognize which to use?

I hava a JavaEE/ EJB3 application in which I'll need to connect diferent databases. It's on JBOSS 5.10GA. After I tried to deploy it I got the following error: 09:04:57,921 ERROR [AbstractKernelController] Error installing to Real: name=vfszip:/opt/jboss-5.1.0.GA/server/idiomas/deploy/idiomas.ear/ state=PreReal mode=Manual requiredStat...

@Asynchronous private method in EJB

I have an asynchronous method in my EJB singleton that's called from another method in the same class. I already know that I can't call the asynchronous method directly, I have to obtain an EJB proxy. The problem is, I don't want the asynchronous method to be visible outside the class; but when I make it private, it's not executed asynch...

Multithreading in a stateless session bean?

The EJB 3.0 specification does not allow a business method of a stateless session bean to create new threads. Why is that? What is wrong with creating additional worker threads that only do raw computations and never call into the app server? Say, my session bean implements a service that lets users to upload images, and the business me...

Java EE Architecture - Are DAO's still recommended when using an ORM like JPA 2?

If I'm using an ORM like JPA2 - where I have my entities that are mapped to my database, should I still be using a DAO? It seems like a lot more overhead. For example, I would need to maintain three extra packages: One that specifies my domain objects (which pretty much map my Entity objects): public class Employee { private Stri...

Why does Glassfish appear to require much more memory in Linux than in Windows?

I've been tinkering with GlassFish 2.1.1 lately, on both an Unbuntu Linux box as well as a Windows XP one. Looking at the "java" processes representing asadmin, JavaDB server, and the GlassFish app server domain itself on Windows (using the Task Manager), they add up to just over 100 MB of memory. However, looking at the same proce...

Add Security Role References programmatically (without using declarative EJB Deployment Descriptor)

I'm developing a Java EE 6 application using Glassfish 3.1, B06. To secure my app, i'm using a JDBCRealm and programmatic security. This works fine to check username and password. But when it comes to declaring security roles, i have a problem: To use Security Roles in Java EE 6, i have to declare those roles both in the EJB deployment ...

Transfer objects only once via EJB / JPA(Hibernate)

Hello! I am using the Java Enterprise Edition with JPA(Hibernate) for a Server-Client application (via EJB). The program stores a lot of data in a database that needs to be transfered to the client. Because I want to transfer as less data as possible I do not want to transfer objects twice. I want to demonstrate my problem with a small...

problem with a Spring applicaiton finding class org.springframework.web.servlet.DispatcherServlet (IDE is Eclipse)

I am trying to create a Spring Web application, and I am having trouble calling a servlet from the Spring library. I have the servlet defined in the XML file but at run time it can't find it, I probably am having an issue with the class path somehow. Here is the message I am getting at runtime Servlet org.springframework.web.ser...

How to unit testing EJBs when using JPA2?

How would you go about unit testing an EJB that uses JPA? For example, if I have an Order entity and and OrderEJB that is supposed to calculate the total of an order (as defined below) how would I go about unit testing the EJB without touching the database? Also, how would you define values for your entities, so you can assert the expect...

CDI call interceptor annotated method within same instance

here is my DAO implementation, i will load the whole table and cached in memory for a certain period of time @ApplicationScoped public class DataAccessFacade { @Inject private EntityManager em; @CacheOutput public Map<String, String> loadAllTranslation() { List<Translation> list = em.createQuery("select t from Trans...

Why not use Session Beans instead of Message Driven Beans ?

I'm wondering, why not use Session Beans instead of Message Driven Beans ? If you can call remote methods from EJBs, so why bother sending/receiving messages with Message Driven Beans (which is more difficult to develop than session beans) ? In which scenarios Message Driven Beans become useful ? ...

Using CDI (Weld) in Tomcat with simple POJO classes

Hi there After 2 days of debugging and trying I have no other idea than asking you for a solution. I want to use CDI (on JEE6) in a Tomcat WebApp with only simple plain old java objects (yet). As far as I know it is simply possible to inject POJO java classes into other POJO Java classes?! Here are my example classes class ToBeInjec...

LoginModule getting invoked twice in jboss (before accessing secured EJB3 method)

Its been quite a while I'm stuck with this.I've wriiten my own login module XtrLdapLoginModule which implements the javax.security.auth.spi.LoginModule to authenticate users against three credentials viz. username, password and account. I couldn't use the LdapExtLoginModule cause it wouldn't help me authenticate against a particular acco...

Resolution should not happen via injection container error.

I have an EJB3 project to be deployed on JBoss 5.1.0 GA. I have Stateless EJBs being injected into other Stateless beans and Servlets. I'm using the @EJB annotation without any parameters to inject the EJB beans, (i have a test project just to simulate the injection, which works). When i try deploying i get the error below. "Caused ...

Is it possible to update the app without restarting the server in JSF?

I'm working with Eclipse 3.5, Tomcat 6, JSF 1.2 and IceFaces 1.8. Whenever I update any file in my app, I have to restart the server to see the latest changes. How to update my app without restarting the server? The server option "Automatically publish when resource changes" is already selected. Update: If I change the main file, the c...

Architecture of a Java EE web application

Hello! I want to realize the following scenario: The frontend is based on HTML5 / CSS3 / JavaScript (with a JavaScript framework like ExtJS or jQuery). I have full HTML pages with forms, buttons, text fields, which have submit buttons which should send the data to the webserver. On the other hand I also have a website in this web applic...

Axis2/Axiom handling SOAP MTOM/non-MTOM attachments

After looking around and trying different suggested solutions, I’m writing this. The 2 most common solutions suggested to extract binary data from a MTOM/non-MTOM SOAP message are: Retrieve the OMText node, and use the dataHandler instance present within it Find the OMElement node which contains the ‘href’ attribute. Get the...

Should the WEB-INF/lib directory be versioned by a version control system?

Should the WEB-INF/lib directory and it's contents be versioned by a VCS? ...

Is there a way to determine that a Connection is managed?

I have some legacy JDBC code that is used within an EJB, in this code a call to setAutocommit() is made (which is not allowed for managed transactions, for understandable reasons). I would like to skip this method call if the code is used within a managed transaction, but let the call remain if used in an un-managed context. Is there a...

Web Application Framework - HTML5 with mobile devices JavaScript support

Hello all! I searched for Java based web application frameworks the last few days. I have to build a Java EE backend and a HTML5/CSS3/JavaScript frontend which can be accessed with multi-touch capable devices. So I will need modern JavaScript frameworks like Sencha Touch. My backend should be built upon with Java EE, Hibernate and MySQ...