1

I'm trying to setup a project using Jetty 8 as the server (jetty-maven-plugin:8.1.11.v20130520), Weld for CDI (weld-servlet:2.0.1.Final), Hibernate for JPA (hibernate-entitymanager:4.2.2.Final, hibernate-jpa-2.0-api:1.0.1.Final) and Jersey for JAX-RS.

It seems that injections isn't working at all. I tested whether the EntityManager is being injected, and the value was null. The log doesn't show any errors or warnings while executing the server.

Am I missing something ? If needed, I will post the log file to gist.

Here is the gist of all relevant files: https://gist.github.com/StalkingKillah/e986474b6885d83c7f8d

1 Answers1

0

This is how I got it working for Jetty 9, and it should be basically the same for Jetty 8.

http://www.eclipse.org/jetty/documentation/current/framework-weld.html

It is easier to have the weld jar outside of the webapp as then you don't have to mess with tweaking the classes exposed to the webapp classloader like you are here (with the -org.eclipse.jetty bit for the ServletContext). I suspect there are more classes that would have to be added to that in order to make it work. You should get a note in the logging that says it is all enabled and active though.

jesse mcconnell
  • 7,102
  • 1
  • 22
  • 33
  • Could you post some sample configuration files? I seem to be overlooking something. Or better yet, an example for embedded jetty 9 with weld ? – StalkingKillah Jul 01 '13 at 14:20
  • a bit tricky embedded, you are dealing with deploying a proper war file through the deployment manager? for the jetty-maven-plugin you probably just need to add weld as a dependency to the jetty-maven-plugin itself (see maven docs on adding dependencies to plugin definitions) – jesse mcconnell Jul 01 '13 at 14:59
  • For development purposes I use the maven-jetty-plugin, but for production I want to use the embedded version. Any pointers on setting up the embedded version with war deployment or exploded war ? – StalkingKillah Jul 01 '13 at 16:32
  • well, all about configuring the classpath at that point, and it is easier in that respect to do it like mentioned in the documentation link above, only having your weld jar in amongst your jetty jars in the classloader (however you are structuring that). weld is easier to configure when it is not in your jar since it requires interacting with classes that are otherwise not exposed through the isolated webapp classloader – jesse mcconnell Jul 01 '13 at 19:48
  • I fixed the error part. Weld initializes now, but injection and interception are not working. Do I have to configure anything else ? – StalkingKillah Jul 04 '13 at 23:59