java-ee

Java EE 6 + JPA - Exception: Message Driven Bean cant be managed bean.

I create an Enterprise Application CustomerApp that also generated two projects CustomerApp-ejb and CustomerApp-war. In the CustomerApp-ejb, I create a SessionBean call CustomerSessionBean.java as below. package com.customerapp.ejb; import javax.ejb.Stateless; import javax.ejb.LocalBean; import javax.persistence.EntityManager; import j...

isUserInRole source code or HttpServletRequest

Hi! Where can I find the source code for isUserInRole? All I find are only interfaces or calling to super.isUserInRole ...

How to inject beans from external libs with CDI?

How can I use JSR-299 CDI to inject (not annotated) beans from external libraries? Examples: Interface X and its implementations come from a third party lib. How can I decide which implementation to use? class A { @Inject private X x; } What if I had several classes using the X interface but different implementations? cl...

How to add on email monitoring and sending from Java web-server app

Tools like BaseCamp, FogBugz & Jira have features where you can send an email to the server on a special address, and it will monitor this address and respond to mails received... e.g Jira let's you create a new bug-report by email, BaseCamp will append an email to a discussion thread, even figuring out the right thread based on the emai...

How to implement authentication mechanism in Java EE 6

I'm trying to learn Java EE 6 and i'm just wondering how to implement authentication mechanism in Java EE 6. Here is the Java EE 6 authentiction example: public void login() { if (account.authenticate(name, password) == null) { message = "Invalid user name or password!"; } else { message = " Login successfu...

Why would a Java Web application contain a series of classes with a main() method?

I am in the process of trying to untangle the (of course uncommented) code of a contractor that preceded (and I don't have access to currently) me at my current gig and I came across three pieces of code that I found odd and was hoping someone might clue me into why this might have been done, since I can't come up with any valid reason f...

Is there any IDE integration for JBoss AS 6?

We have switched to JBoss 6 to make it possible to use a wider range of Java EE technologies. We chose JBoss because of its small memory footprint compared to other application servers, so we have no other choice. Do you know any developer tools that can be integrated with JBoss AS 6? Thanks in advance Jonathan Frank ...

Atomikos vs JOTM vs Bitronix vs ????

I am new to JTA and it's underlying transaction managers. Can anyone explain the pros/cons of each of these? Feel free to add others I didn't list in title. Also, don't the major applications servers (WebSphere, JBoss, Glassfish) have their own JTA compliant transaction manager? In those environments, would you still use these third p...

Can't instantiate javax.servlet.ServletException

Hello, experts! I am trying to create instance of class javax.servlet.ServletException with following code public class MyTroubleViewer { public static void main(String[] args) { javax.servlet.ServletException servletException = new javax.servlet.ServletException("Hello"); System.out.println(servletException.getMessage()); } } ...

How to configure DB connection in a Servlet based JPA application

By default DB connections of JPA applications are configured in the META-INF/persistence.xml, when the application is not deployed to a full Java EE application server. In my opinion it is not very elegant to place such environment specific configuration into a file that is inside a .war file. How could a DB connection of a Servlet based...

How can something like BOSH be implemented using Java Servlets

BOSH (Bidirectional-streams Over Synchronous HTTP) is a sneaky way of implementing 2-way client-server communication in situations where true server-push is not allowed, most obviously to let a server push data to a browser client without having to use client polling. It works by the client sending a request to the server, and the serve...

JSF data transfer between UI and business layer

Hi, We are using JSF in UI, Spring in business layer, Hibernate in persistence layer. Now my question is how to pass data from the JSF UI to spring business layer. Can I directly use my business object in my backing bean or should I transfer data between the layer through DTO? Can one explain me with clear explanation if possible with p...

Websites using JEE

Hi guys, I have a simple question, but I can't find out the answer. I'm wondering if we can see that a website is built using the JEE technology, or servlets/JSP. I think it could be possible to look for specials pages from the server (404, wrong parameters, ...) in some cases, but what about the everyday use ? In fact, I look for a co...

How to connect remote EJB module from application client

Hi guys, I have a EJB module in remote Glassfish server and application client in my computer. I want to connect from the application client to the remote EJB. Here is the my EJB interface: @Remote public interface BookEJBRemote { public String getTitle(); } Here is the my ejb: @Stateless public class BookEJB implements BookEJ...

CDI/JSF and JAX-RS?

I would like to use RESTful services in a CDI/JSF2 application. I am not very familiar with JAX-RS however I have read that its lifecycle does not play well with CDI/JSF2. Is it possible to incorporate JAX-RS with CDI/JSF2 in a JEE6 stack? If not are there alternatives? thanks ...

Anyone know exactly which JMS messages will be redelivered in CLIENT_ACKNOWLEDGE mode if the client crashes?

The spec says "Acknowledging a consumed message automatically acknowledges the receipt of all messages that have been delivered by its session" - but what I need to know is what it means by 'delivered'. For example, if I call consumer.receive() 6 times, and then call .acknowledge on the 3rd message - is it (a) just the first 3 messages...

Call method in EJB on JBoss startup

Hello, I'm looking for an entry point in an EJB deployed on JBoss. Servlets have the load-on-startup tag to use in its web.xml. I'm searching for similar init() functionality for an EJB. ...

JNDI - how it works

If I understand correctly the default JNDI service runs on my local AS, right? So if I create an EJB and in jboss.xml (running JBoss) I name it "sth" than it is registered in my AS. Correct? In big projects EJBs might be distributed through many servers - on one server EJBs doing sth and on another sth else. When calling JNDI loopup() I...

New to JEE; architecture suggestions for a service/daemon?

I am brand new to the JEE world. As an exercise to try and familiarize myself with JEE, I'm trying to create a tiered web-app, but I'm getting a little stuck on what the best way is to spin up a service in the background that does work. Parameters of the service: It must open and hold a socket connection and receive information from t...

How to inject a non-serializable class (like java.util.ResourceBundle) with Weld

I want to create a Producer that makes it possible to inject a java.util.ResourceBundle into any class in order to get localized Strings easily. My ResourceBundle-Producer looks like this: public class ResourceBundleProducer { @Inject public Locale locale; @Inject public FacesContext facesContext; @Produces p...