Mantis - Resin
Viewing Issue Advanced Details
4467 major always 03-30-11 07:10 04-04-11 18:04
andreaskaltenbach  
emil  
normal  
closed 4.0.16  
unable to reproduce  
none    
none  
0004467: Resin unable to compile typed interfaces for stateless session beans
Assume the following setup:

public interface Importer<T> {
  void doImport(T t);
}

@Stateless
public ImporterImpl implements Importer<String> {
  public void doImport(String t);
}

---

When setting up the EJBs, Resin fails with the following message:

java.lang.IllegalStateException: AnnotatedMethodImpl[public abstract void Importer.doImport(java.lang.Object)] does not have a matching base method in {1}

Internally, AnnotatedTypeUtil compares the two parameter lists but returns that doImport(T t) and doImport(String t) do not match. Reason is that a comparison of the java.lang.Class 'String' with a java.lang.reflect.TypeVariable is done (AnnotatedTypeUtil.isMatch(List<AnnotatedParameter<?>>, List<AnnotatedParameter<?>>)). Instead for comparing those types, the TypeVariable's bounds have to compared.

A workaround is to not use typed interfaces, but this a big limitiation in designing services.

Full stack trace:

at com.caucho.ejb.gen.SessionGenerator.introspectMethod(SessionGenerator.java:244)
                                   at com.caucho.ejb.gen.SessionGenerator.introspectType(SessionGenerator.java:226)
                                   at com.caucho.ejb.gen.SessionGenerator.introspect(SessionGenerator.java:206)
                                   at com.caucho.ejb.gen.StatelessGenerator.introspect(StatelessGenerator.java:177)
                                   at com.caucho.ejb.session.AbstractSessionManager.bind(AbstractSessionManager.java:251)
                                   at com.caucho.ejb.manager.EjbManager.bind(EjbManager.java:540)
                                   at com.caucho.ejb.manager.EjbManager.environmentBind(EjbManager.java:662)
                                   at com.caucho.loader.EnvironmentClassLoader.bind(EnvironmentClassLoader.java:864)
                                   at com.caucho.loader.EnvironmentClassLoader.start(EnvironmentClassLoader.java:883)
                                   at com.caucho.server.webapp.WebApp.start(WebApp.java:3109)
                                   at com.caucho.env.deploy.DeployController.startImpl(DeployController.java:630)
                                   at com.caucho.env.deploy.StartAutoRedeployAutoStrategy.startOnInit(StartAutoRedeployAutoStrategy.java:77)
                                   at com.caucho.env.deploy.DeployController.startOnInit(DeployController.java:493)
                                   at com.caucho.env.deploy.DeployContainer.start(DeployContainer.java:171)
                                   at com.caucho.server.webapp.WebAppContainer.start(WebAppContainer.java:713)
                                   at com.caucho.server.host.Host.start(Host.java:676)
                                   at com.caucho.env.deploy.DeployController.startImpl(DeployController.java:630)
                                   at com.caucho.env.deploy.StartAutoRedeployAutoStrategy.startOnInit(StartAutoRedeployAutoStrategy.java:77)
                                   at com.caucho.env.deploy.DeployController.startOnInit(DeployController.java:493)
                                   at com.caucho.env.deploy.DeployContainer.start(DeployContainer.java:171)
                                   at com.caucho.server.host.HostContainer.start(HostContainer.java:542)
                                   at com.caucho.server.cluster.Server.start(Server.java:1225)
                                   at com.caucho.server.cluster.ServletService.start(ServletService.java:72)
                                   at com.caucho.env.service.ResinSystem.startServices(ResinSystem.java:508)
                                   at com.caucho.env.service.ResinSystem.start(ResinSystem.java:476)
                                   at com.caucho.server.resin.Resin.start(Resin.java:892)
                                   at com.caucho.server.resin.Resin.initMain(Resin.java:1020)
                                   at com.caucho.server.resin.Resin.main(Resin.java:1297)
                                   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:597)
 quickfix_for_resin_issue_#4467.patch [^] (19,799 bytes) 03-31-11 06:29

Notes
(0005144)
andreaskaltenbach   
03-31-11 06:30   
Uploaded a quickfix:
-differentiate between generic types and ordinary types
-identify all matching method candidates and return the closest one (the one which has a more narrow type parameter than java.lang.Object).
(0005149)
ferg   
04-04-11 17:50   
ejb/40c4

This example works fine with 4.0.16. There must be some other difference in the test (for example different classloaders, .jar vs .ear etc.)

The proposed patch is incorrect.