[jboss-user] [JBoss Seam] - Re: Seam 1.1 beta1&2 (dis?)injecting issue

superflav do-not-reply at jboss.com
Mon Nov 13 19:58:39 EST 2006


I'm experiencing this same problem, even after synching with the latest CVS rev.  Here's a really simple set of classes that should help you recreate the problem:

TestService EJB interface...
package com.testcase.service;
  | 
  | import javax.ejb.Local;
  | 
  | @Local
  | public interface TestService {
  |     public Object getObject(Long objectId);
  |     
  | }

TestService EJB impl...
package com.testcase.service;
  | 
  | import javax.ejb.Stateless;
  | 
  | @Stateless
  | public class TestServiceBean implements TestService {
  |     
  |     public Object getObject (Long objectId) {
  |         return new Object();
  |     }
  | }

TestObject EJB Seam Component interface...
package com.testcase.faces;
  | 
  | import javax.ejb.Local;
  | 
  | @Local
  | public interface TestObject {
  |     public Object getObject();
  |     
  |     public void destroy();
  | }

package com.testcase.faces;
  | 
  | import static org.jboss.seam.ScopeType.EVENT;
  | 
  | import javax.ejb.EJB;
  | import javax.ejb.Remove;
  | import javax.ejb.Stateful;
  | 
  | import org.jboss.seam.annotations.Destroy;
  | import org.jboss.seam.annotations.Logger;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Scope;
  | import org.jboss.seam.annotations.Unwrap;
  | import org.jboss.seam.log.Log;
  | 
  | import com.testcase.service.TestService;
  | 
  | /**
  |  * Stateful Seam component named "TesObject", scoped to the EVENT (life of the
  |  * request) context.
  |  *
  |  */
  | @Stateful
  | @Scope(EVENT)
  | @Name("TestObject")
  | public class TestObjectBean implements TestObject {
  |     
  |     @Logger
  |     private Log log;
  |     
  |     @EJB
  |     private TestService _testService; 
  |     
  |     @Unwrap
  |     public Object getObject() {
  |         Object object = _testService.getObject(new Long(1));
  |         log.debug("got object");
  |         return object;
  |     }
  |     
  |     @Destroy @Remove
  |     public void destroy() {}
  | }

TestPage.xhtml...
<?xml version="1.0" encoding="utf-8"?>
  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  |                       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | <ui:composition xmlns="http://www.w3.org/1999/xhtml"
  |                 xmlns:ui="http://java.sun.com/jsf/facelets"
  |                 xmlns:h="http://java.sun.com/jsf/html"
  |                 xmlns:f="http://java.sun.com/jsf/core"
  |                 xmlns:c="http://java.sun.com/jstl/core"
  |                 template="/templates/DefaultPage.xhtml">
  |   <ui:define name="body">
  | 
  | #{TestObject.object}
  | 
  |   </ui:define>
  | </ui:composition>

Deploy that in a webapp, call up the TesPage.xhtml and watch for this in your server logs:

Caused by: java.lang.IllegalArgumentException: could not set field value: TestObject.log
  |         at org.jboss.seam.Component.setFieldValue(Component.java:1525)
  |         at org.jboss.seam.Component.injectLog(Component.java:1106)
  |         at org.jboss.seam.Component.initialize(Component.java:1057)
  |         at org.jboss.seam.intercept.RootInterceptor.postConstruct(RootInterceptor.java:125)
  |         at org.jboss.seam.intercept.SessionBeanInterceptor.postConstruct(SessionBeanInterceptor.java:213)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |         at java.lang.reflect.Method.invoke(Method.java:585)
  |         at org.jboss.ejb3.interceptor.LifecycleInvocationContextImpl.proceed(LifecycleInvocationContextImpl.java:131)
  |         at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorHandler.java:109)
  |         ... 151 more
  | Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: TestObjectBean.log on: com.testcase.service.TestServiceBean with value:
  | class org.jboss.seam.log.LogImpl
  |         at org.jboss.seam.util.Reflections.set(Reflections.java:149)
  |         at org.jboss.seam.Component.setFieldValue(Component.java:1521)
  |         ... 161 more
  | Caused by: java.lang.IllegalArgumentException
  |         at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
  |         at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:57)
  |         at java.lang.reflect.Field.set(Field.java:656)
  |         at org.jboss.seam.util.Reflections.set(Reflections.java:121)
  |         ... 162 more
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3985662#3985662

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3985662



More information about the jboss-user mailing list