Alejandro Dominguez

+ Follow
since Jun 01, 2007
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alejandro Dominguez

Nevermind, I upgraded to JBoss 5 (RC1) and it works perfectly

Nice to see a popular request being taken care of!
13 years ago
Hello to all,
I have been trying to access a persistence unit from a servlet in JBoss 4.2.2, but I always get a "not bound" exception.

My directories are as follows:
-.jar (persitence.xml)
-.war (web.xml, jboss-app.xml)

In my web.xml I have:

and in my servlet (inside the .war file) I have:

However, by looking at JMX Console I don't see the persistence/context being created, and when I try to lookup the manager, I get "persistence not bound".

Am I missing something here?

13 years ago
Hi to all,
I'm working on my first project using EJB 3.0 and I'm facing some difficulties.
Long story short, I basically want to share an object across several (stateless and mdb) bean instances; the object is costly to build and for this reason I would like to just build it once and keep a single instance in memory (probably in the JNDI). The object is kind of like a tree, where read and updates can be performed.

What I would like is some sort of mechanism similar to READ_COMMITED for databases (reads at any time as long as there are no writes going on) to manage the concurrency access to the object.
I understand EJB's specs state that developers should not manage the synchronization of objects, especially resources. So, what's my best option in order to solve my problem?
I'm using JBoss 4.2.2, so I'm taking a look at JBoss Cache, but I'm definitely open to any other suggestion.

I see; the logical next question is then: can I inject a PersistenContext into a @Entity?
I tried doing so, but it is always null...

Hi to all,
I'm trying to map my beans to a *very* weird and complicated database schema and the annotations are just not enough some times; is it possible to define custom queries for accessing the properties (at this point I'm interested in read only behavior).

I'd like something like

{ ...

public Set getSomething() {}

If I'm not mistaken, Hibernate 2.1 allowed a similar definition in the xml.

I'd really like to avoid having to add the query code inside my entity...

[ January 21, 2008: Message edited by: Alejandro Dominguez ]
I'm Using JBoss 4.2.2 GA, so maybe that's the problem... oh well, I'll stick to jndi lookup meanwhile.

Hi to all,

my ear file contains the ejb.jar and webapp.war files; in my webapp I have a servlet into which I'd like to inject an EJB reference.

From the servlet, the following code works perfectly:

However, trying to achieve the same by injection, results in a NullPointerException as soon as I try to run one of the bean's methods

Am I missing something here?

Hi to all,
so, I have read, end enjoyed!, O'Reilly Enterprise JavaBeans 3.0 (Bill Burke); I was wondering if anybody has suggestions regarding additional books that are worthy to read. I would like something that actually adds some insight, not an almost identical copy.

I know that "EJB3 in Action", "Pro EJB 3: Java Persistence API" and "Beginning EJB 3 Application Development: From Novice to Professional" should be pretty good.

Any suggestions?

Sorry for bringing back a dead horse, but I'm facing the same exact problem; I'm using JBoss 4.2.2GA on Mac OS 10.4.

Does anybody know of a workaround? I would like to have my EJBs deployed separately from my webapps so as to have a shared common "core".

I see that JBoss states:

I get ClassCastException

There are some places where it reports this when it really means ClassNotFoundException, e.g. the CORBA PortableRemoteObject.narrow()

Assuming it is the same class name, this problem relates to classes getting loaded from different classloaders. At compile time your class has only one identity, its name. If you "deploy" a class many times in different jars, it has multiple identities. They are not the same. See below for more information on the solutions to this problem.

This can also be caused by you only redeploying part of your application. e.g. a webapp uses an EJB and you only redeploy the EJB. The webapp will still have the old versions of the classes.

... but for many users I don't think redeploying everything is really an option...

Any ideas?

[ January 13, 2008: Message edited by: Alejandro Dominguez ]
Hi to all!
At my work place we have a proxy server and on each machine we have a proxy client. With everything enabled, I can send emails and connect to sockets on Internet without any problems.
However, we are now switching to opening the sockets on a VPN; I have found that for this to properly work, I must disable the local proxy client, otherwise the default gateway will try to resolve the IP specified in the VPN connection. Disabling the proxy client will prohibit me from sending email with java mail.
I tried adding -DproxySet=true -DproxyHost=myProxyHost -DproxyPort=myProxyPort, with no effect. I read that I can also use socksProxyHost and socksProxyPort properties, but this will affect all TCP connection and also my sockets connections too...

Is there any work around to this mess? Basically I want the socket to be opened using the VPN but the mail to be sent using the default gateway; can this be achieved on the same JVM?

Best regards
Hi to all!
I'm interested in finding a jsf component that manages file upload and that shows a progress bar. Does anybody know if such a component exists?

I know that myfaces has a component, but it is kind of limited and no progress bar is offered.

I also tried this example, but I was not able to make it work..

Any ideas?


15 years ago

In adition to what Theodore said I can add the following:
I know a couple of people who have been programming in Java from 1 to 3-4 years and then decided to take the SCJP and started studying from it. Well, all of them learnt things they didn't immagine! Another rancher said something like "in our jobs, 50% is probably copy/paste", to which I strongly agree. The idea behind the SCJP, from my point of view, is to make sure you know the BASICS of the language (it doesn't even come close to covering it 100%), so that people have a common grand from which continue studying.
Hard? Absolutly not. A challenge? Certainly so. With 2-3 hrs per day most people will pass it with at least 70% in under 2 months.

To keep it short, how could you ever start studying EJB and the JPA without knowing the difference between a Set, HashSet and TreeSet?

Sure, there are some tricky questions like the one you mentioned, but look at them as having some fun!

BTW, my wife is MCAD and now wants to upgrade to MCPD. Guess what? The upgrade exam is huge! The step-step by step strategy touches .Net 2.0 basics, MCTS and finally MCPD.


Just my 0.02.
upon further investigation I found a work around to my situation; accordind to my domain rules any un-authenticated invoker will receive a "guest" identity (with JBoss it's in the conf/login-config.xml file).
Thus, it was just a matter of creating an Interceptor that, with an injected SessionContext, validated that the principal's name is not equal to "guest".

See below my implementation

Bean class

public class SecurityBean implements SecurityRemote {

public void testSecurity() {


public class SecurityInterceptor {
@Resource SessionContext sessionContext;

public Object securityCheck(InvocationContext ctx) throws Exception {

if (sessionContext.getCallerPrincipal().getName().equalsIgnoreCase("guest")) {
throw new SecurityException("No authenticated user provided");
return ctx.proceed();

Anyway, just wanted to share in case somebody finds himself/herself in this kind of situation.

Hi ranchers,
I was trying out some features of the EJB Interceptors and came to a strange behavior:

Statefull session bean defines class interceptor.
Upon calling a method, first is fired the class interceptor, and then the method itself (this is normal).
Console output:

Once I added @PostConstruct to the session bean and to the ClassInterceptor I got the following (normal) behavior:

Now for the weird part: I add a @PostConstruct method in the MethodInterceptor, which is assigned to a *totally* different method from the one being called in the session bean, and I get the following (non-normal?) behavior:

No interceptors are defined in ejb-jar.xml

My Bean code:

ClassInterceptor (MethodInterceptor is identical, just a different .java)

The client:

My question is: why is @PostConstruct on the MethodInterceptor called? It's associated with a method that is not even called at all (demostrated by it's @AroundInvoke method non being called).

Any ideas?



Edited: forgot to add: using JBoss 4.0.5
[ June 06, 2007: Message edited by: Alejandro Dominguez ]
<explanation type="short">
Yes, it's perfectly identical

<explanation type="long">

Yeah, according to Sun, the SAI version is identical in every aspect, 'cept for the mentioned pin/logo/badge, to the commercial version.
I can log and see my Certification history as well as send it to someone else.

Following are the emails I received from Sun; their Certification support team has been quick and clear answering my questions. Too bad I don't share Sun's policy in regard to SAI.

The Sun Academic Initiative tests provide the same Sun certification at a discounted price. Due to the discounted price, you do not receive the lapel pin, logo use, or wallet card. If these are needed you will have to take the exam at the commercial price.

In order to obtain use of the logo, you must take and pass the commercial version of the test. We cannot provide logo use to SAI certification students. We regret any inconvenience you may experience as a result of this issue.

Your actual SCJP certification is the same as the commercial certification and fulfills all of the prerequisite requirements for any of the Developer certifications. The only difference is that with the Sun Academic Initiative (SAI) program, you do not receive logo use, the wallet card, or the lapel pin. Since Developer certifications are not offered through the SAI program, you would receive all of the supplements of the commercial certification´┐Żlogo use, wallet card, and lapel pin.

So, at least I can take the Developers certification (SCJD, SCBCD, etc...)

Now, if one goes to there's no mention of the actual differences. I think more transparency would be truly good.

Anyway, back to study for SCBCD, then I'll get the missing items... barring some other, unknown, policy...




Edited: finally found the link that specifies the differences: Too bad it took an exam, a post and 3 emails getting to know the differences... oh well
[ June 06, 2007: Message edited by: Alejandro Dominguez ]