Alessandro Ilardo

Ranch Hand
+ Follow
since Dec 23, 2005
Merit badge: grant badges
For More
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 Alessandro Ilardo

Hello there, I am experimenting with EJB3 on JBoss, developing a stateless bean. Basically once the module has been deployed I need to perform some actions related to load application settings (XML). To do this I've annotated a method as @PostConstruct, which as far as I know from the API instructs the container to invoke it once the bean has been deployed and before get in service. (correct?) Now, I am confused, because from the log on that method looks like is not simply invoked once, but right before each exposed method is called. I only need to call that method once the bean has been deployed, not every time it receives a call. What would be the best approach? And moreover should it be this the expected behave from the container.

Thanks in advance

Alessandro Ilardo
Move the owner doesn't make any difference, I think that in a biderectional relationship I have to manage the relation by myself.
Something like this, before to persist new entities.

Role existRole = (Role)em.find(Role.class, id);

//it shouldn't be necessary, but...

And at this point I'd add the Transaction required annotation as well

Not sure it works, but apparently let Hibernate to manager bidirectional relationship doesn't work as expected.
Thanks in advance
Hibernate 3

I have two entities User and Role which holds a bidirectional relationship.
Basically I want to create as many roles as I want, without the need to add any user to it, but every time a new user entity has to become persistent it must belong at least to a role.


// many-to-many bidirectional
@ManyToMany(fetch = FetchType.EAGER, mappedBy = "users")
@Column(nullable = false)
private List<Role> roles = new ArrayList<Role>();


private List<User> users = new ArrayList<User>();

I can create new role and users, but the problem is on the USR_ROLE_FK table which is empty, so not consistent relationship between entities.
On the client side, before to pass the new user entity to persist, I first retrieve the detached role entity, then add it to the new user and finally passed to the ejb.
Personally I think I am missing something about the cascading property, but after several attempts and fails I am stuck.

I need your help, at least some resources with practical examples.
Thanks in advance
Hello there,
I am developing an ejb3 statless on JBoss, using Hibernate as persistence engine.
I now came across the Configuration and SessionFactory objects, that seem to be quite used but that personally I've never explicitly implemented (perhaps due the simplicity of my queries).
Well today I've faced an issue which requires the Criteria object and as far as I now I need those class to proceed.
Until today I've just injected the persistence context using an annotation and setting the persistence.xml file, as I don't need to add any programmatic configurations, I was wondering if I must explicitly implement them anyway in order to use the Criteria object or I can obtain them from the context.

Thanks in advance for any help.
Hello there,
I have an ejb method which if on DB doesn't find the entry requested should throws a javax.persistence.NoResultException.
On the other hand I have standalone client application that acts as tester for the ejb method.

On the logic application of this client I'd need to catch the NoResultException, but instead looks like I get a java.lang.reflect.InvocationTargetException. Although this exception could be acceptable, is too generic for my purposes.
If from that I call the getMessage() I actually have javax.ejb.EJBException: javax.persistence.NoResultException: No entity found for query.

How can distinguish InvocationTargetException thrown by a NoResultException?

Thanks in advance

14 years ago
The article actually says how to override those methods, not why we should.
14 years ago
I am testing an ejb with a client which uses the Junit framework.
On the ejb I have two public methods

public User getUser(final String email, final String domain)
public User getUser(final Long id)

the client code is something like this

called by a junit test

The test doesn't complete correctly and I get this exception
834 [main] FATAL - java.lang.IllegalArgumentException: wrong number of arguments
835 [main] FATAL - [testGetUser] wrong number of arguments

Could you please give me some help about it?
Thanks in advance
14 years ago
Hello, I am not really confident with Junit and I am using the latest version 4.6, which includes the Hamcrest matchers.
Basically I don't see any error on an assertion where I am sure the result should be not good. Along the code I also included some debug which confirms that the code doesn't successful complete. I need some help, as I am learning to use this library together with Hamcrest.
Thanks in advance


Output console

0 [main] DEBUG - [getMockUser][id=1][username=alessandro]
155 [main] DEBUG - [ServiceLocator] file succesfully loaded.
155 [main] INFO - [ServiceLocator] EJB properties found.
182 [main] INFO - [ServiceLocator] JNDI Context set.
183 [main] DEBUG - [testEJBClass] Start test.
195 [main] DEBUG - [testUserExistMethod] Start test.
195 [main] DEBUG - [setEjbObj] Looking up the EJB interface from context...
195 [main] DEBUG - [setEjbObj] JNDI IdentityManagerBean/remote
523 [main] INFO - [setEjbObj] EJB found!
523 [main] DEBUG - [invokeRemoteMethod] Got EJB object.
524 [main] DEBUG - [setEjbClass] EJB class loading...
524 [main] DEBUG - [setEjbClass] EJB class succesfully loaded:
524 [main] INFO - [getRemoteMethod] EJB method succesfully found.
524 [main] DEBUG - [invokeRemoteMethod] Got EJB method.
582 [main] DEBUG - Using ThreadLocal: false
687 [main] DEBUG org.jboss.remoting.transport.socket.MicroSocketClientInvoker - SocketClientInvoker[8ceeea, socket://] constructed
688 [main] DEBUG org.jboss.remoting.MicroRemoteClientInvoker - SocketClientInvoker[8ceeea, socket://] connecting
688 [main] DEBUG org.jboss.remoting.MicroRemoteClientInvoker - SocketClientInvoker[8ceeea, socket://] connected
746 [main] DEBUG org.jboss.remoting.transport.socket.ClientSocketWrapper - reset timeout: 0
777 [main] DEBUG org.jboss.remoting.InvokerRegistry - removed SocketClientInvoker[8ceeea, socket://] from registry
777 [main] DEBUG org.jboss.remoting.transport.socket.MicroSocketClientInvoker - SocketClientInvoker[8ceeea, socket://] disconnecting ...
779 [main] DEBUG org.jboss.remoting.transport.socket.SocketWrapper - ClientSocketWrapper[Socket[addr=/,port=3873,localport=52582].f0b7f8] closing
779 [main] DEBUG - [invokeRemoteMethod] EJB method invoked.
779 [main] DEBUG - [testUserExistMethod] Object returned from remote EJB interface.
779 [main] DEBUG - [testUserExistMethod] Object is not null.
779 [main] DEBUG - [testUserExistMethod] Object class name: java.lang.Boolean"[testUserExistMethod] Test passed.");
Is not logged, broken code!
14 years ago
Hi there, I'm new in SOA and I hope that someone can help me to found out how a consumer can exchange request trough an ESB in unaware format.

Usually we need the consumer to create artifacts from a wsdl, so it knows where the remote service is and what requires. In my case I would like to establish an unaware communication between consumer and provider trough the ESB. So my consumer knows where the BUS is, but doesn't know anything else about the remote service (format, parameters, ecc.)

So far I succesfully pubblished the remote wsdl on the UDDI registry (JBoss ESB), now what are the next steps?
15 years ago
Hi there,
I decided to go with JBoss Tools to develop applications using Seam framework.
On "Run as" command the files some files are not imported into the build directory.
I only have the class folder (and included files), no web content is copied into "build".
JBoss Tools 3 | Eclipse 3.4
Of course

But the error doesn't say that cannot find that property, instead it says that the property is not a String.
15 years ago
Hello there,
I'm trying to display a kind of preview for a text. But on JBoss 4.2.2 I take the following error.

javax.servlet.jsp.JspException: ServletException in '/WEB-INF/jsp/home.jsp': Unable to compile class for JSP:

An error occurred at line: 54 in the jsp file: /WEB-INF/jsp/home.jsp
The method setItems(String) in the type ForTokensTag is not applicable for the arguments (Object)
51: <% // FocusOn - description%>
54: <c:forTokens var="token" items="${entry.description}" delims=" " end="200">
55: <c:out value="${token}"/>
56: </c:forTokens>
57: ...

at org.apache.struts.taglib.logic.ForwardTag.doForward(

The property's bean which I'm trying to access is a String type.

The code above is nested to this tag belowe

This comes out from the entity called during the iteration

What's the problem then??
Thanks in advance
[ August 11, 2008: Message edited by: Alessandro Ilardo ]
15 years ago
I've just started with BPEL, I currently use NetBeans which has some nice tutorials for projects to be deployed on Glass Fish.
I would like to deploy it on JBoss without start with JBpel IDE.

Ho do you deploy a BPEL project on different platforms?

Thanks in advance
15 years ago