[jboss-user] [JBoss Seam] - JavaAssist fails to create proxy

Sammy8306 do-not-reply at jboss.com
Wed Aug 1 06:07:20 EDT 2007


My component:


  | package org.blog.weblayer.session;
  | 
  | import org.jboss.seam.ScopeType;
  | import org.jboss.seam.annotations.Scope;
  | import org.jboss.seam.annotations.AutoCreate;
  | import org.jboss.seam.annotations.Name;
  | 
  | @Name("Sessiontag_st") @AutoCreate @Scope(ScopeType.SESSION) public class Var0  implements java.io.Serializable, weblayer.SessionVar<org.blog.domainmodel.Tag>
  | {
  |   org.blog.domainmodel.Tag var = new org.blog.domainmodel.Tag();
  | 
  |   public void setVar(org.blog.domainmodel.Tag var)
  |   {
  |     this.var = var;
  |   }
  | 
  |   public org.blog.domainmodel.Tag getVar()
  |   {
  |     return var;
  |   }
  | }
  | 

The interface:


  | package weblayer;
  | 
  | public interface SessionVar<T> {
  | 
  |   public T getVar();
  | 
  |   public void setVar(T t);
  | 
  | }
  | 

The lookup in another component:


  | ((weblayer.SessionVar)Component.getInstance("Sessiontag_st")).setVar(t);
  | 

this line fails with: 


  | org.jboss.seam.InstantiationException
  | <snip>
  | Caused by: java.lang.RuntimeException: duplicate method: getVar
  |      [java]     at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:173)
  |      [java]     at org.jboss.seam.Component.createProxyFactory(Component.java:1979)
  |      [java]     at org.jboss.seam.Component.getProxyFactory(Component.java:1154)
  |      [java]     at org.jboss.seam.Component.wrap(Component.java:1145)
  |      [java]     at org.jboss.seam.Component.instantiateJavaBean(Component.java:1134)
  |      [java]     at org.jboss.seam.Component.instantiate(Component.java:1088)
  |      [java]     at org.jboss.seam.Component.newInstance(Component.java:1736)
  |      [java]     ... 76 more
  |      [java] Caused by: javassist.CannotCompileException: duplicate method: getVar
  |      [java]     at javassist.bytecode.ClassFile.testExistingMethod(ClassFile.java:544)
  |      [java]     at javassist.bytecode.ClassFile.addMethod(ClassFile.java:528)
  |      [java]     at javassist.util.proxy.ProxyFactory.override(ProxyFactory.java:373)
  |      [java]     at javassist.util.proxy.ProxyFactory.overrideMethods(ProxyFactory.java:349)
  |      [java]     at javassist.util.proxy.ProxyFactory.make(ProxyFactory.java:277)
  |      [java]     at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:164)
  |      [java]     ... 82 more
  | 

If I get rid of the interface on the session scoped component and cast to Var0 directly, everything works dandy... So, why can't my Seam component implement an interface?

(offtopic: originally I wanted to make Var0 parameterized, i.e. Var, assigning it different roles for each session var so that I do not need to write a specialization for each type I have, implementing a common generic interface. However, I really need the instantiation of the member field, which cannot be done by virtue of Java's type erasure scheme for generics)


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

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



More information about the jboss-user mailing list