-
1. Re: resteasy with seam 2.2 and JBoss 4.2
arturfriesen May 21, 2010 5:32 PM (in response to arturfriesen)Finally i got it running, at least the basic example i showed in my first post. Just to note down which combination worked for me,
i created a eclipse WAR-project via jboss-tools with the following settings:
- JBoss AS 4.2.3
- SEAM 2.2.0
- PostgreSQL 8.4.3
after creating the Project i had to add the following JARs to lib folder:
- jboss-seam-resteasy.jar
- jaxrs-api.jar
- resteasy-jaxrs.jar
- slf4j-api.jar
- slf4j-log4j12.jar
-
2. Re: resteasy with seam 2.2 and JBoss 4.2
arturfriesen May 22, 2010 9:06 PM (in response to arturfriesen)If you use the Jboss-Toos in Eclipse to create a SEAM-EAR Project, you have to put the librarys as following:
war-file/WEB-INF/lib:
jboss-seam-resteasy.jar
ear-file/lib:
jaxrs-api.jar resteasy-jaxrs.jar
-
3. Re: resteasy with seam 2.2 and JBoss 4.2
arturfriesen May 22, 2010 9:17 PM (in response to arturfriesen)Im trying to inject EntityManager into the RESTeasy Class,
but this is not working...is there some configuration needed to inject EntityManager??
-
4. Re: resteasy with seam 2.2 and JBoss 4.2
gaborj May 23, 2010 4:44 AM (in response to arturfriesen)Not sure how far you got, but you should set your class as Seam Component with @Name to inject it.
-
5. Re: resteasy with seam 2.2 and JBoss 4.2
arturfriesen May 23, 2010 2:28 PM (in response to arturfriesen)Meanwhile i switched to the JBossAS 5.1, but it didnt helped me out.
I notated the class with @Name and tried to inject the EntityManager:import javax.persistence.EntityManager; import javax.ws.rs.*; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; @Name("ping") @Path("/ping") public class HelloWorld { @In(create=true) EntityManager manager; @GET @Path("/{Number}") public String get(@PathParam("Number")String num) { return "ping succeeded !!! "+num; } }
If i look at the JBossAS Log, there is the following error after trying to navigae to the REST-URL:
Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: HelloWorld.manager on: rest2.HelloWorld with value: class org.jboss.seam.faces.FacesManager at org.jboss.seam.util.Reflections.set(Reflections.java:86) at org.jboss.seam.Component.setFieldValue(Component.java:1923) ... 69 more Caused by: java.lang.IllegalArgumentException: Can not set javax.persistence.EntityManager field rest2.HelloWorld.manager to org.jboss.seam.faces.FacesManager at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) at java.lang.reflect.Field.set(Field.java:657) at org.jboss.seam.util.Reflections.set(Reflections.java:71) ... 70 more
-
6. Re: resteasy with seam 2.2 and JBoss 4.2
arturfriesen May 23, 2010 2:41 PM (in response to arturfriesen)The Problem with the EntityManager injection has seemingly nothing todo with RESTeasy.
I also get this error if i try to onject the EntityManager into the home-class of a created entity.What could be the reason for such an Error?
Why there is no EntityManager in the context? -
7. Re: resteasy with seam 2.2 and JBoss 4.2
arturfriesen May 23, 2010 3:38 PM (in response to arturfriesen)finally i found the reason for that behavoir. The following log pointed me to that
15:31:27,776 INFO Component: entityManager, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.persistence.ManagedPersistenceContext
SEAM doesnt inject the EntityManager if you declare the @In with another instance-name than
entityManager
. In my case the following injection doesnt worked because of the instance-name@In EntityManager manager;
It has to be the following
@In EntityManager entityManager;