Can Seam Persistence be used without needing JSF i.e. from a base HttpServlet class?
dazed Mar 14, 2012 4:40 AMI'm new to Seam and liking the look of the Persistence mechanism. For the view/presentation side I am using a library which is based around HttpServlet i.e. not JSF based.
I'm using JBoss AS 7 and Seam 3.1.0.Final
When I put these together with my Servlet library and get to the first method marked "@Begin" I get an exception because I don't have a ConversationScoped Context defined. I confess, I half expected something like this.
org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped
I tried a variation of the suggestion in <http://stackoverflow.com/questions/4828504/how-to-inject-conversationscoped-beans-in-a-servlet> but found that no ConversationContext was set (null pointer).
Again I half expected this not to work, as I clearly haven't set anything in the http headers for the "cid" part.
I've also tried following some of the setup for Seam Booking example it uses
<interceptors>
<class>org.jboss.seam.faces.context.conversation.ConversationBoundaryInterceptor</class>
</interceptors>
and hence starts to drag in faces stuff - I get this compiled but then get a Weld Deployment Exception
org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [ELContext] with qualifiers [@Default] at injection point [[parameter 1] of [c
onstructor] @Inject public org.jboss.solder.el.Expressions(ELContext, ExpressionFactory)]. Possible dependencies [[Producer Method [ELContext] with qualifiers [@Any @Default] decla
red as [[method] @Produces org.jboss.seam.solder.el.ELContextProducer.createELContext()], Producer Method [ELContext] with qualifiers [@Any @Default] declared as [[method] @Produce
s org.jboss.solder.el.ELContextProducer.createELContext()]]]
So my questions are:
1) Am I trying to do something that Seam Persistence is not designed for? I see lot's of references which all point to JSF. Is it intimately linked with JSF?
2) Is there parts of the Seam Library that I can use at App Startup, Session Startup and/or on each Request so that ConversationContext (and other required Contexts) are set?
I can post other stuff from my application, but I'm not looking to get anyone to debug my app - just a pointer to a good example of Seam Persistence without JSF and/or a good manual.
Thanks