users@glassfish.java.net

Re: "Cannot write to an JAR archive open for reading" Exception?

From: <glassfish_at_javadesktop.org>
Date: Wed, 28 Mar 2007 10:16:00 PST

Hi,

ok, I found the reason. I post the thing below, since I already wrote it, maybe you'll find it useful.
The reason was the WAR file, or rather appriopriate entry in application.xml.
I entered <web-uri>/MyWebPart.war</web-uri> Note the / . Without the / it deployed ok.
I cannot remember why I put this "/" there in the first place, I think I read somewhere that I
should do so. Now I know I shouldn't, and on JBoss I also did [b]not[/b] put "/".
Thanks
Edek

With log level finest of deployer (I won't paste the whole log, just some lines before error).
Here is what it does:
[ parses the application.xml ]
[ gets libs from /lib ]
[ parses one of ejb-jar.xml ]
[ analyzes beans and annotations on them ]
[ ... the same for other EJB .jars ]
[ opens the WAR (i'll become more detailed here )]
[ does not read any web.xml, just dumps webBundle and classLoader (see dump):]
Web Bundle descriptor


<== No attribute ==>
 Module Type = war
 Module spec version = 2.5
 Roles[] = []
 context root
 sessionTimeout 30
 mimeMappings [[[[mime-mappings-go-here]]]]
 welcomeFiles [index.html, index.htm, index.jsp]
 errorPageDescriptors []
 appListenerDescriptors []
 contextParameters [Env-Prop: com.sun.faces.injectionProvider_at_Non-Injectable Resource_at_java.lang.String_at_com.sun.faces.vend
or.GlassFishInjectionProvider@@, Env-Prop: com.sun.faces.validateXml_at_Non-Injectable Resource_at_java.lang.String_at_true@@, Env
-Prop: com.sun.faces.forceLoadConfiguration_at_Non-Injectable Resource_at_java.lang.String_at_true@@]
 ejbReferences
 jmsDestReferences
 messageDestReferences
 resourceReferences
 serviceReferences
 isDistributable false
 securityRoles null
 securityConstraints []
 contextRoot
 loginConfiguration null
 webComponentDescriptors
<== No attribute ==>WebComponentDescriptor

 initializationParameters [Env-Prop: debug_at_Non-Injectable Resource_at_java.lang.String_at_0@@, Env-Prop: listings_at_Non-Injectabl
e Resource_at_java.lang.String_at_true@@]
 urlPatterns [/]
 canonicalName default
 loadOnStartUp 1
 securityRoleReferences []
 servlet className org.apache.catalina.servlets.DefaultServlet
<== No attribute ==>WebComponentDescriptor

 initializationParameters [Env-Prop: xpoweredBy_at_Non-Injectable Resource_at_java.lang.String_at_true@@]
 urlPatterns [*.jspx, *.jsp]
 canonicalName jsp
 loadOnStartUp 3
 securityRoleReferences []
 servlet className org.apache.jasper.servlet.JspServlet
 environmentEntries |#]


[ parses sun-ejb-jar.xml (only one EJB has this kind of file) ]
[ parses sun-application.xml ]
[ sets uniqueIds (?) ]
[ throws beans into ejbBundleValidator ]
[ "START of EJBC" then a few lines below "END of EJBC"]
[ unique IDs again + getPersistenceManagers + see for yourself :
e=Thread-198;ClassName=com.sun.enterprise.deployment.Application;MethodName=setUniqueId;_RequestID=5fa0d33e-662e-44c9-a4a
e-337b0858185d;|[Application]desc id: 77011493761712138|#]

[#|2007-03-28T19:15:38.704+0200|FINE|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=38;_ThreadNam
e=Thread-198;ClassName=com.sun.enterprise.deployment.EjbBundleDescriptor;MethodName=getPersistenceManagers;_RequestID=5fa
0d33e-662e-44c9-a4ae-337b0858185d;|***IASEjbBundleDescriptor.getPersistenceManagers done -#- |#]

[#|2007-03-28T19:15:38.713+0200|FINE|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=38;_ThreadNam
e=Thread-198;ClassName=com.sun.enterprise.deployment.EjbBundleDescriptor;MethodName=getPersistenceManagers;_RequestID=5fa
0d33e-662e-44c9-a4ae-337b0858185d;|***IASEjbBundleDescriptor.getPersistenceManagers done -#- |#]

[#|2007-03-28T19:15:38.722+0200|FINE|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=38;_ThreadNam
e=Thread-198;ClassName=com.sun.enterprise.deployment.EjbBundleDescriptor;MethodName=getPersistenceManagers;_RequestID=5fa
0d33e-662e-44c9-a4ae-337b0858185d;|***IASEjbBundleDescriptor.getPersistenceManagers done -#- |#]

[#|2007-03-28T19:15:38.732+0200|FINE|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=38;_ThreadNam
e=Thread-198;ClassName=com.sun.enterprise.deployment.EjbBundleDescriptor;MethodName=getPersistenceManagers;_RequestID=5fa
0d33e-662e-44c9-a4ae-337b0858185d;|***IASEjbBundleDescriptor.getPersistenceManagers done -#- |#]

[#|2007-03-28T19:15:38.790+0200|FINE|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=38;_ThreadNam
e=Thread-198;ClassName=com.sun.enterprise.deployment.backend.AppDeployer;MethodName=doRequestFinish;_RequestID=5fa0d33e-6
62e-44c9-a4ae-337b0858185d;|Deployment Error
com.sun.enterprise.deployment.backend.IASDeploymentException: Fatal Error from EJB Compiler -- Failed to save deployment
descriptor for: xxxx
cause: Cannot write to an JAR archive open for reading
        at com.sun.enterprise.instance.BaseManager.saveAppDescriptor(BaseManager.java:696)
        at com.sun.enterprise.deployment.backend.EJBCompiler.preDeployApp(EJBCompiler.java:346)
        at com.sun.enterprise.deployment.backend.EJBCompiler.compile(EJBCompiler.java:222)
        at com.sun.enterprise.deployment.backend.AppDeployer.runEJBC(AppDeployer.java:359)
        at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:214)
[Message sent by forum member 'edek234' (edek234)]

http://forums.java.net/jive/thread.jspa?messageID=210335