[GLASSFISH-16352] Using composite components put in external JAR in an EAR throws "Input stream has been finalized..." on undeploy Created: 14/Apr/11  Updated: 13/Nov/12  Resolved: 13/Nov/12

Status: Closed
Project: glassfish
Component/s: jsf
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: tjahnsen Assignee: Ed Burns
Resolution: Duplicate Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 64-bit, GlassFish 3.0.1 and GlassFish 3.1, NetBeans 6.9.1


Attachments: Zip Archive ZExtCCTestProj.zip    
Issue Links:
Related
is related to JAVASERVERFACES-2595 Using composite components put in ext... Closed
Status Whiteboard:

Assign


 Description   

I have an Enterprise Application (EAR) project with an accompanying web application (WAR) that uses a normal JAR library that contains JSF composite components. The components works correctly, but when I undeploy or redeploy the application, or shut down GlassFish, the com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream throws a Throwable with the message "Input stream has been finalized or forced closed without being explicitly closed".

My estimate is that the composite component xhtml-file inside the JAR library isn't closed properly. You must open the page once for the error to occur - if you just deploy and then undeploy, the errors doesn't happen.

Attached is a project suite where I have been able to reproduce the error. They are NetBeans projects with an EAR, a WAR and a JAR. The JAR library has the composite component inside "META-INF/resources/comp/cc", while the WAR project uses the composite component both directly in a main page and in an included component. Both uses cause the error.

Extras:

  • It only causes with the EAR. If you deploy and show the plain WAR project, it doesn't throw the error.
  • It happens in both GlassFish 3.0.1 and GlassFish 3.1.
  • The composite component must be used in a rendered web page before it happens.
  • It happens when I deploy through NetBeans, the autodeploy folder and through the Admin GUI.
  • It throws two errors per use of the composite component. If you use it twice, it throws four errors in total.

I suspect the error is related to a problem experienced in NetBeans, where I cannot clean or rebuild a project because the JAR library containing composite components is locked in the dist/gfdeploy folder. This can be caused by GlassFish not closing connections to xhtml-files inside it.

There are two errors per use of the composite component, slightly different. The stack traces are as follows:

[#|2011-04-14T09:02:22.298+0200|WARNING|glassfish3.0.1|javax.enterprise.system.core.classloading.com.sun.enterprise.loader|_ThreadID=34;_ThreadName=Thread-1;|Input stream has been finalized or forced closed without being explicitly closed; stream instantiation reported in following stack trace
java.lang.Throwable
at com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream.<init>(ASURLClassLoader.java:1153)
at com.sun.enterprise.loader.ASURLClassLoader$InternalJarURLConnection.getInputStream(ASURLClassLoader.java:1246)
at java.net.URL.openStream(URL.java:1010)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1195)
at com.sun.enterprise.loader.ASURLClassLoader.getResourceAsStream(ASURLClassLoader.java:799)
at org.glassfish.web.loader.WebappClassLoader.getResourceAsStream(WebappClassLoader.java:1243)
at com.sun.faces.application.resource.ClasspathResourceHelper.getNonCompressedInputStream(ClasspathResourceHelper.java:99)
at com.sun.faces.application.resource.ResourceHelper.getInputStream(ResourceHelper.java:221)
at com.sun.faces.application.resource.ResourceImpl.getInputStream(ResourceImpl.java:166)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagLibrary.containsTagHandler(CompositeComponentTagLibrary.java:107)
at com.sun.faces.facelets.tag.CompositeTagLibrary.containsTagHandler(CompositeTagLibrary.java:160)
at com.sun.faces.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:276)
at com.sun.faces.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:225)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:788)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:385)
at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:361)
at com.sun.faces.facelets.compiler.Compiler.compile(Compiler.java:117)
at com.sun.faces.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:331)
at com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:215)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:359)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:339)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:191)
at com.sun.faces.facelets.tag.ui.IncludeHandler.apply(IncludeHandler.java:102)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:75)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:145)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:716)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:662)

#]

[#|2011-04-14T09:02:22.299+0200|WARNING|glassfish3.0.1|javax.enterprise.system.core.classloading.com.sun.enterprise.loader|_ThreadID=34;_ThreadName=Thread-1;|Input stream has been finalized or forced closed without being explicitly closed; stream instantiation reported in following stack trace
java.lang.Throwable
at com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream.<init>(ASURLClassLoader.java:1153)
at com.sun.enterprise.loader.ASURLClassLoader$InternalJarURLConnection.getInputStream(ASURLClassLoader.java:1246)
at java.net.URL.openStream(URL.java:1010)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1195)
at com.sun.enterprise.loader.ASURLClassLoader.getResourceAsStream(ASURLClassLoader.java:799)
at org.glassfish.web.loader.WebappClassLoader.getResourceAsStream(WebappClassLoader.java:1243)
at com.sun.faces.application.resource.ClasspathResourceHelper.getNonCompressedInputStream(ClasspathResourceHelper.java:99)
at com.sun.faces.application.resource.ResourceHelper.getInputStream(ResourceHelper.java:221)
at com.sun.faces.application.resource.ResourceImpl.getInputStream(ResourceImpl.java:166)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagLibrary.containsTagHandler(CompositeComponentTagLibrary.java:107)
at com.sun.faces.facelets.tag.CompositeTagLibrary.createTagHandler(CompositeTagLibrary.java:176)
at com.sun.faces.facelets.compiler.TagUnit.createFaceletHandler(TagUnit.java:113)
at com.sun.faces.facelets.compiler.TextUnit.createFaceletHandler(TextUnit.java:110)
at com.sun.faces.facelets.compiler.CompilationUnit.getNextFaceletHandler(CompilationUnit.java:108)
at com.sun.faces.facelets.compiler.TagUnit.getNextHandler(TagUnit.java:117)
at javax.faces.view.facelets.TagHandler.<init>(TagHandler.java:92)
at com.sun.faces.facelets.tag.TagHandlerImpl.<init>(TagHandlerImpl.java:54)
at com.sun.faces.facelets.tag.ui.CompositionHandler.<init>(CompositionHandler.java:93)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.faces.facelets.tag.AbstractTagLibrary$HandlerFactory.createHandler(AbstractTagLibrary.java:181)
at com.sun.faces.facelets.tag.AbstractTagLibrary.createTagHandler(AbstractTagLibrary.java:672)
at com.sun.faces.facelets.tag.CompositeTagLibrary.createTagHandler(CompositeTagLibrary.java:177)
at com.sun.faces.facelets.compiler.TagUnit.createFaceletHandler(TagUnit.java:113)
at com.sun.faces.facelets.compiler.CompilationUnit.getNextFaceletHandler(CompilationUnit.java:108)
at com.sun.faces.facelets.compiler.NamespaceUnit.createFaceletHandler(NamespaceUnit.java:75)
at com.sun.faces.facelets.compiler.CompilationManager.createFaceletHandler(CompilationManager.java:354)
at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:399)
at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:361)
at com.sun.faces.facelets.compiler.Compiler.compile(Compiler.java:117)
at com.sun.faces.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:331)
at com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:215)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:359)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:339)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:191)
at com.sun.faces.facelets.tag.ui.IncludeHandler.apply(IncludeHandler.java:102)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:75)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:145)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:716)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:662)

#]


 Comments   
Comment by kumara [ 14/Apr/11 ]

-> jsf for investigation

Comment by sheetalv [ 18/Apr/11 ]

The code that's spitting out the exception is in the report() method which gets called by the finalize() method as follows :

protected void finalize() throws Throwable {
if (!closed && this.in != null){
try

{ in.close(); }

catch (IOException ignored)

{ //Cannot do anything here. }

//Well, give them a stack trace!
report();
}
super.finalize();
}

Looks like during undeploy/redeploy, GC calls the finalize() method leading to the report() method being called and hence the subsequent WARNING. I don't think this is at all serious. Just that the message is being logged as a WARNING. Will contact Tim Quinn for more details.

Comment by Tim Quinn [ 18/Apr/11 ]

Sheetal is exactly right. The message is a warning because streams left open are a bad thing and should be prevented. It does not normally cause any problem on non-Windows systems (except for holding onto file handles longer than necessary), but on Windows systems JAR files which are left open cannot be deleted which can cause problems during redeployment of the application.

The stack trace shows where the stream was opened from so people who know that part of the system can investigate. From a quick look I'd guess facelets is the culprit in this case.

Comment by juan.fcorugedo [ 13/Jun/11 ]

The problem is the Mojarra implementation, that opens some InputStreams but never close it:

http://java.net/jira/browse/JAVASERVERFACES-2113

Comment by Manfred Riem [ 13/Nov/12 ]

Closing as duplicate, see the associated issue for resolution.

Generated at Sat Jul 04 16:09:36 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.