0

I'm relying on @ConversationScoped EntityManagers in one of my applications.

However, I now need to access said EntityManagers from outside a conversation (Timer EJB). I read a tutorial on how to write an Interceptor which opens a new conversation if none exists - 42 lines tutorial

Now when I try and set-up the example, I get the Exception, that there is no target for the @Bound @Inject BoundConversationContext.

To be honest, I don't know what the problem could be or in which direction I look further.

I'm currently using:
GlassFish 3
Java EE 6

chzbrgla
  • 5,007
  • 6
  • 36
  • 55

1 Answers1

0

Timers aren't guaranteed to run within an HttpSession, so there's no conversation. You'd be better off in your timer bean to simply use @PersistenceContext.

LightGuard
  • 5,068
  • 15
  • 18
  • I know that there is no Conversation. That's why I want to programativacally begin a new Conversation (wrap the method call into an @Interceptor), do the EntityManager call, end the conversation again. The tutorial link from my OP does exactly that - however, won't work for my setup :( – chzbrgla Jun 11 '13 at 16:11
  • That's A LOT of work to create a workaround for something that is working the way it's specified, imo. Timers do not work within the confines of an HTTP Request, so RequestScoped, ConversationScoped, and SessionScoped will not work without hacking something like the aforementioned intercepter. You're honestly better off simply use @PersistenceContext and merge() in entity if needed then use it normally. – LightGuard Jun 11 '13 at 19:44