• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@PersistenceContext Injection in SessionBeans

 
Daniel Jabonete
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guyz,

I would like to kindly ask the rules in injecting @PersistenceContext for the EntityManager in a SessionBeans.

I’ve injected the following in my SessionBean, please see below:

In order to hold of the EntityManager but, when I deployed it in my Glassfish it throws the following connection error in the logs:

So I removed the injection above, then deployed again, it throws no error.

Appreciate your help pertaining to these issues. Thanks very much!

Cheers!
 
Remko Strating
Ranch Hand
Posts: 893
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds that the dependency injection is not the problem, but the way you're trying to connect to the database. Check your parameters for connecting to the database.
 
Deepika Joshi
Ranch Hand
Posts: 268
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check persistese.XML, db connection tag.
 
Daniel Jabonete
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guyz,

I' am not sure which database connection you are referring at, or which configurations and where...

But as I dig deeper to this problem, I've found out that the problem was on the Glassfish Resources> JDBC> JDBC Resources> jdbc/__default which point to the "DerbyPool".

I've created Resources> JDBC> Connection Pools> MySqlDs and then point the "jdbc/__default" to "MySqlDs", and voila I'd successfully deployed my EJB with EntityManager injected in my Stateless SessionBean(s).

Now, what are the differences when using "DerbyPool" aside from creating my own (live) connection. and DerbyPool seems not running by default. What about when porting to other Application Server...?

Anyone share some lights pertaining to this topic. Thanks very much!

Cheers!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic