• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java EE 5:persistence, web and ejb alltogether  RSS feed

 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to everybody,
I've created an ear with the following structure:


I'm using JBoss 4.2.0.

The file 'persistence.jar' contains a persistence unit and, if deployed as standalone, it works.
The file 'ejb.jar' contains a stateless session bean that accesses to the persistence unit.

If I deploy my ear, JBoss complains when trying to deploy the session bean, dumping that it cannot resolve a dependency from the persistence unit.
It seems like the deployer can't see the 'persistence.jar' element: in fact, in the logs there is no trace about the deployment of my persistence unit.

Thanks a lot in advances!
 
krishnamoorthy kitcha
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can you give the Exception log or Exception details ?
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response!

Sorry, I'm not at my home station.
But consider that I do not receive a stack trace error: simply, JBoss informs me that the ejb deployment is incomplete because it cannot find the persistence unit referenced.

Thanks!
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I partially solved my problem: I had not specified my persistence.jar file as an ejb module in application.xml.

Now, the deployment works correctly, but I can't find the correct name for the session bean: I mean, my servlet can't find the remote interface (NamingNotFoundException).

I have never really understood the jndi naming for external resources: when I have an ejb, I have to:
1. Set an ejb-ref in web.xml
2. Add an application-server specific xml file that maps the jndi name with the name of the ejb

Is it correct?
What should I do if my application server is JBoss?

Thanks a lot in advances...
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Today, for the first time, my ejb+persistence+servlet...Worked!

However, I don't yet understand the meaning for ejb-ref in web.xml. In my application, I simply didn't put anything in web.xml and it worked.

Can anybody explain me the meaning for ejb-ref for web.xml?

Thanks in advances
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ejb-ref is useful if you need to reference an EJB from your servlet.
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks for your response.

Ok, I thought it, too, but today my servlet has been able to access to my stateless session bean without using any ejb-ref.

Consider that I'm using java enterprise edition 5 and I'm using the @Remote and @Stateless annotations...

Thanks a lot!
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that's because you use the global JNDI to lookup your EJB. Thus, you don't need to use ejb-ref at all.
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks for the response.
Well, I think it is, but when I tried to set an ejb-ref, the application server complained because it expected at least an 'home' element.
Aren't annotation enough for the application server?
Consider that my web.xml is 2.5 version.

Thanks in advances!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!