Mantis - Resin
Viewing Issue Advanced Details
2344 minor always 01-17-08 08:50 01-27-08 10:00
ferg  
ferg  
normal  
closed 3.1.4  
fixed  
none    
none 3.1.5  
0002344: WebBeans @Interceptor integration
(rep by wesley)
I wrote an interceptor for some webbeans component.

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?


Notes
(0002667)
ferg   
01-23-08 10:25   
ejb/10a0
(0002685)
ferg   
01-27-08 10:00   
Documented at http://caucho.com/resin/doc/resin-ioc.xtp [^]