On Jan 16, 2008, at 11:38 AM, wesley wrote:

> I wrote an interceptor for some webbeans component.

Thanks.  That's some extra debugging code.  I've filed a bug at  
http://bugs.caucho.com/view.php?id=2344

The webbeans interceptor implementation is going to change this week,  
since we're going to integrate the webbeans interception with the ejb  
interception.  So webbeans will be able to use ejb interceptors and  
ejb interceptors can use webbeans annotations, and all our tests will  
cover the same code.  It's going to be very cool.

-- Scott


>
> code:
> ==============The InterceptorBindingType============
> @InterceptorBindingType
> @Target({ElementType.METHOD, ElementType.TYPE})
> @Retention(RetentionPolicy.RUNTIME)
> public @interface BlockCachable {
> }
> ============The Interceptor=============
> @BlockCachable
> @Interceptor
> public class BlockModelCacheInterceptor {
>  private static final Log log =
> LogFactory.getLog(BlockModelCacheInterceptor.class);
>  public BlockModelCacheInterceptor() {
>  }
>  @AroundInvoke
>  @SuppressWarnings(value = "unchecked")
>  public Object invoke(final InvocationContext invocation) throws  
> Throwable {
>   log.info("intercepted");
>   return invocation.getTarget();
>  }
> }
> =======The component should be intercepted========
> @Component
> public class MyBean{
>  @BlockCachable
>  public void execute() {
>   // do something
>  }
> }
> ============================================
> Note: all interceptors were registed in web-beans.xml.
>
> When starting Resin, resin produce exceptions.
> Stacktrace:
> java.lang.RuntimeException: java.io.FileNotFoundException:
> \tmp\caucho\qa\temp.class (The system cannot find the path specified)
>         at
> com.caucho.webbeans.bytecode.InterceptorGenerator.generateProxy 
> (InterceptorGenerator.java:185)
>         at
> com.caucho.webbeans.bytecode.InterceptorGenerator.gen 
> (InterceptorGenerator.java:80)
>         at
> com.caucho.webbeans.component.ClassComponent.bind 
> (ClassComponent.java:354)
>         at com.caucho.webbeans.cfg.WbWebBeans.bind(WbWebBeans.java: 
> 276)
>         at
> com.caucho.webbeans.manager.WebBeansContainer.bind 
> (WebBeansContainer.java:702)
>         at
> com.caucho.webbeans.manager.WebBeansContainer.environmentStart 
> (WebBeansContainer.java:732)
>         at
> com.caucho.loader.EnvironmentClassLoader.start 
> (EnvironmentClassLoader.java:567)
>         at com.caucho.server.webapp.WebApp.start(WebApp.java:1798)
>         at
> com.caucho.server.deploy.DeployController.startImpl 
> (DeployController.java:667)
>         at
> com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit 
> (StartAutoRedeployAutoStrategy.java:72)
>         at
> com.caucho.server.deploy.DeployController.startOnInit 
> (DeployController.java:549)
>         at
> com.caucho.server.deploy.DeployContainer.start(DeployContainer.java: 
> 160)
>         at
> com.caucho.server.webapp.WebAppContainer.start(WebAppContainer.java: 
> 675)
>         at com.caucho.server.host.Host.start(Host.java:437)
>         at
> com.caucho.server.deploy.DeployController.startImpl 
> (DeployController.java:667)
>         at
> com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit 
> (StartAutoRedeployAutoStrategy.java:72)
>         at
> com.caucho.server.deploy.DeployController.startOnInit 
> (DeployController.java:549)
>         at
> com.caucho.server.deploy.DeployContainer.start(DeployContainer.java: 
> 160)
>         at
> com.caucho.server.host.HostContainer.start(HostContainer.java:479)
>         at com.caucho.server.cluster.Server.start(Server.java:1171)
>         at com.caucho.server.cluster.Cluster.startServer 
> (Cluster.java:708)
>         at
> com.caucho.server.cluster.ClusterServer.startServer 
> (ClusterServer.java:529)
>         at com.caucho.server.resin.Resin.start(Resin.java:694)
>         at com.caucho.server.resin.Resin.initMain(Resin.java:1124)
>         at com.caucho.server.resin.Resin.main(Resin.java:1326)
>         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)
>         at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> Caused by: java.io.FileNotFoundException: \tmp\caucho\qa\temp.class  
> (The
> system cannot find the path specified)
>         at java.io.FileOutputStream.open(Native Method)
>         at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
>         at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
>         at com.caucho.vfs.FilePath.openWriteImpl(FilePath.java:470)
>         at com.caucho.vfs.Path.openWrite(Path.java:1076)
>         at
> com.caucho.webbeans.bytecode.InterceptorGenerator.generateProxy 
> (InterceptorGenerator.java:175)
>         ... 29 more
> java.lang.RuntimeException: java.io.FileNotFoundException:
> \tmp\caucho\qa\temp.class (The system cannot find the path specified)
>         at
> com.caucho.webbeans.bytecode.InterceptorGenerator.generateProxy 
> (InterceptorGenerator.java:185)
>         at
> com.caucho.webbeans.bytecode.InterceptorGenerator.gen 
> (InterceptorGenerator.java:80)
>         at
> com.caucho.webbeans.component.ClassComponent.bind 
> (ClassComponent.java:354)
>         at com.caucho.webbeans.cfg.WbWebBeans.bind(WbWebBeans.java: 
> 276)
>         at
> com.caucho.webbeans.manager.WebBeansContainer.bind 
> (WebBeansContainer.java:702)
>         at
> com.caucho.webbeans.manager.WebBeansContainer.environmentStart 
> (WebBeansContainer.java:732)
>         at
> com.caucho.loader.EnvironmentClassLoader.start 
> (EnvironmentClassLoader.java:567)
>         at com.caucho.server.webapp.WebApp.start(WebApp.java:1798)
>         at
> com.caucho.server.deploy.DeployController.startImpl 
> (DeployController.java:667)
>         at
> com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit 
> (StartAutoRedeployAutoStrategy.java:72)
>         at
> com.caucho.server.deploy.DeployController.startOnInit 
> (DeployController.java:549)
>         at
> com.caucho.server.deploy.DeployContainer.start(DeployContainer.java: 
> 160)
>         at
> com.caucho.server.webapp.WebAppContainer.start(WebAppContainer.java: 
> 675)
>         at com.caucho.server.host.Host.start(Host.java:437)
>         at
> com.caucho.server.deploy.DeployController.startImpl 
> (DeployController.java:667)
>         at
> com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit 
> (StartAutoRedeployAutoStrategy.java:72)
>         at
> com.caucho.server.deploy.DeployController.startOnInit 
> (DeployController.java:549)
>         at
> com.caucho.server.deploy.DeployContainer.start(DeployContainer.java: 
> 160)
>         at
> com.caucho.server.host.HostContainer.start(HostContainer.java:479)
>         at com.caucho.server.cluster.Server.start(Server.java:1171)
>         at com.caucho.server.cluster.Cluster.startServer 
> (Cluster.java:708)
>         at
> com.caucho.server.cluster.ClusterServer.startServer 
> (ClusterServer.java:529)
>         at com.caucho.server.resin.Resin.start(Resin.java:694)
>         at com.caucho.server.resin.Resin.initMain(Resin.java:1124)
>         at com.caucho.server.resin.Resin.main(Resin.java:1326)
>         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)
>         at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> Caused by: java.io.FileNotFoundException: \tmp\caucho\qa\temp.class  
> (The
> system cannot find the path specified)
>         at java.io.FileOutputStream.open(Native Method)
>         at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
>         at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
>         at com.caucho.vfs.FilePath.openWriteImpl(FilePath.java:470)
>         at com.caucho.vfs.Path.openWrite(Path.java:1076)
>         at
> com.caucho.webbeans.bytecode.InterceptorGenerator.generateProxy 
> (InterceptorGenerator.java:175)
>         ... 29 more
> java.io.FileNotFoundException: \tmp\caucho\qa\temp.class (The  
> system cannot
> find the path specified)
>         at java.io.FileOutputStream.open(Native Method)
>         at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
>         at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
>         at com.caucho.vfs.FilePath.openWriteImpl(FilePath.java:470)
>         at com.caucho.vfs.Path.openWrite(Path.java:1076)
>         at
> com.caucho.webbeans.bytecode.InterceptorGenerator.generateProxy 
> (InterceptorGenerator.java:175)
>         at
> com.caucho.webbeans.bytecode.InterceptorGenerator.gen 
> (InterceptorGenerator.java:80)
>         at
> com.caucho.webbeans.component.ClassComponent.bind 
> (ClassComponent.java:354)
>         at com.caucho.webbeans.cfg.WbWebBeans.bind(WbWebBeans.java: 
> 276)
>         at
> com.caucho.webbeans.manager.WebBeansContainer.bind 
> (WebBeansContainer.java:702)
>         at
> com.caucho.webbeans.manager.WebBeansContainer.environmentStart 
> (WebBeansContainer.java:732)
>         at
> com.caucho.loader.EnvironmentClassLoader.start 
> (EnvironmentClassLoader.java:567)
>         at com.caucho.server.webapp.WebApp.start(WebApp.java:1798)
>         at
> com.caucho.server.deploy.DeployController.startImpl 
> (DeployController.java:667)
>         at
> com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit 
> (StartAutoRedeployAutoStrategy.java:72)
>         at
> com.caucho.server.deploy.DeployController.startOnInit 
> (DeployController.java:549)
>         at
> com.caucho.server.deploy.DeployContainer.start(DeployContainer.java: 
> 160)
>         at
> com.caucho.server.webapp.WebAppContainer.start(WebAppContainer.java: 
> 675)
>         at com.caucho.server.host.Host.start(Host.java:437)
>         at
> com.caucho.server.deploy.DeployController.startImpl 
> (DeployController.java:667)
>         at
> com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit 
> (StartAutoRedeployAutoStrategy.java:72)
>         at
> com.caucho.server.deploy.DeployController.startOnInit 
> (DeployController.java:549)
>         at
> com.caucho.server.deploy.DeployContainer.start(DeployContainer.java: 
> 160)
>         at
> com.caucho.server.host.HostContainer.start(HostContainer.java:479)
>         at com.caucho.server.cluster.Server.start(Server.java:1171)
>         at com.caucho.server.cluster.Cluster.startServer 
> (Cluster.java:708)
>         at
> com.caucho.server.cluster.ClusterServer.startServer 
> (ClusterServer.java:529)
>         at com.caucho.server.resin.Resin.start(Resin.java:694)
>         at com.caucho.server.resin.Resin.initMain(Resin.java:1124)
>         at com.caucho.server.resin.Resin.main(Resin.java:1326)
>         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)
>         at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
>
> ================================================================
> I've examined the source code of
> com.caucho.webbeans.bytecode.InterceptorGenerator, and found
> strange code below:
>
> 174:      if (true) {
> 175:        out = Vfs.lookup("file:/tmp/caucho/qa/ 
> temp.class").openWrite();
> 176:        out.write(buffer, 0, buffer.length);
> 177:        out.close();
> 178:      }
>
> It seems InterceptorGenerator will definitely execute line 175 and  
> produce
> an exception, if any interceptors need to
> be initialized.
>
> I modified above lines as below
>
> 174:      if (false) {
> 175:        out = Vfs.lookup("file:/tmp/caucho/qa/ 
> temp.class").openWrite();
> 176:        out.write(buffer, 0, buffer.length);
> 177:        out.close();
> 178:      }
>
> and everything goes fine.
>
> Should this be a bug or something need extra config to go?
>
> -Wesley
>
>
>
> _______________________________________________
> resin-interest mailing list
> resin-interest@caucho.com
> http://maillist.caucho.com/mailman/listinfo/resin-interest



_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to