CDI IllegalArgumentException

57 views
Skip to first unread message

R Yahiaoui

unread,
Jul 5, 2018, 1:01:12 PM7/5/18
to Eclipse MicroProfile

 Hi, 

 I have the following code :

  Unmanaged unmanagedService = new Unmanaged<>(bm, _service_xx)               ;
  UnmanagedInstance serviceInstanceService = unmanagedService.newInstance() ;
  serviceInstanceService.produce().inject().postConstruct()                                       ;
  Object managedService = serviceInstanceService.get()                                           ;


 where "service_xx" is a class  annotated with @Counted and which is compiled at runtime.

 without "@Counted" averything works fine. 

 But with "@Counted" when I call "serviceInstanceService.produce().inject().postConstruct() ;" on the class " service_1" this works, 

 when I recall "serviceInstanceService.produce().inject().postConstruct() ;" on the "service_2", this throws the following exception :

(ServerService Thread Pool -- 13) null: java.lang.IllegalArgumentException: Can not set com.rac021.jax.api.streamers.IStreamer field com.rac021.jaxy.ghosts.services.vip_planes.Service.streamerOutputJson to org.jboss.weld.proxies.Service$Proxy$_$$_WeldSubclass


 Can someone tell me what's the problem

 Thanks

 R

R Yahiaoui

unread,
Jul 8, 2018, 8:57:36 PM7/8/18
to Eclipse MicroProfile
 
 Ideas about what's wrong ?

 Thanks

 R

Emily Jiang

unread,
Jul 9, 2018, 5:20:32 AM7/9/18
to Eclipse MicroProfile
Which application server are you using?
With the limited info, I guess the previous unmanaged bean of server_xx is not a proxy. Once you have annotated with `@Counted' (which is an intercept binding), the instance you get will be a weld proxy. The injection will happen on the weld proxy (a subclass). Hope this might give you some pointer! If not, please share your code and post your question on relevant app server or weld-dev mailing list.

Emily

R Yahiaoui

unread,
Jul 9, 2018, 7:35:08 AM7/9/18
to Eclipse MicroProfile

I'm using Thorntail ( wildfly swarm ) 


service_xx is a template file which is compiled at runtime ( after updating the patterns ) with the following code :


***************************************************************


@Counted(name = "{PACKAGE_NAME}" )


public class {SERVICE_NAME}

{


@Inject

 private IStreamer streamerOutputJson ;


@PostConstruct
public void init() { }


public {SERVICE_NAME} () { }


@GET
@Produces("json/plain")
public Response getResourceASJson( @HeaderParam("Keep") String filterdIndex )

{ ... }

}


***************************************************************


It seem that streamerOutputJson can't be injected ( When the annotation @Counted is used )

Michal Szynkiewicz

unread,
Jul 10, 2018, 4:03:41 AM7/10/18
to Eclipse MicroProfile
For the record, an issue has been created for the problem and the problem is being addressed there: https://issues.jboss.org/browse/THORN-2100

Emily Jiang

unread,
Jul 10, 2018, 9:59:28 AM7/10/18
to Eclipse MicroProfile
Thank you Michal for the update! Glad to know Thorntail is investigating this!

Thanks
Emily
Reply all
Reply to author
Forward
0 new messages