IWAE0008E An error occurred reading jar file - java

We have a war file that uses java, spring etc. I have to deploy this war file in Websphere 9. I had setup datasource. I am getting the following error when I try to deploy the war file.
com.ibm.websphere.management.application.client.AppDeploymentException: org.eclipse.jst.j2ee.commonarchivecore.internal.exception.NestedJarException: IWAE0008E An error occurred reading WEB-INF/lib/spring-context-5.0.16.RELEASE.jar from /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/wstemp/92668751/upload/awdcs.war [Root exception is org.eclipse.jst.j2ee.commonarchivecore.internal.exception.NestedJarException: IWAE0008E An error occurred reading WEB-INF/lib/spring-context-5.0.16.RELEASE.jar from /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/wstemp/92668751/upload/awdcs.war]
Any thoughts on what is causing this issue and how to proceed further?

It may be a class-loading order issue. Try changing the order from parent_first to parent_last from the settings of the server. Check out How Does WebSphere Choose the Classloading Order in a Folder (WEB-INF/lib) and https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/crun_classload.html

Check if the jar dependency "spring-context-5.0.16.RELEASE.jar" is part of the war file "awdcs.war". You can unzip the WAR file and inspect.
Make sure the jar is included in the war when it is built or worst-case add the jar as part of the websphere runtime.

My case was with spring-core-4.2.4.RELEASE.jar, the solution for me was extract of WEB-INF/lib and put in classes/spring-core-4.2.4.RELEASE.jar. Was necesary delete of lib

Related

WAR file deployed to TomEE Plus not sending emails: loader constraint violation error

I deployed an EJB application (provided as a .war file) to TomEE Plus 7.1.0.
It runs alright, but it was noticed that emails were not being sent.
I investigated the log file at logs/tomee-stderr.[date].log and found this:
java.lang.LinkageError: loader constraint violation: loader (instance
of java/net/URLClassLoader) previously initiated loading for a
different type with name "javax/mail/Session"
followed by a very, very long (>500k lines) stack trace.
I found a related question (java.lang.LinkageError: loader constraint violation:previously initiated loading for a different type with name "javax/mail/Session") and it is said the solution consists in marking the dependency to javamail as a "provided" dependency, but my understanding is that this is supposed to be done in the Maven project file, to which I don't have access.
I can edit the contents of the ROOT directory at will (and I tried deleting two files, namely, mail.jar and mail-1.4.4.jar, from the WEB-INF/lib directory, but to no avail); I believe I can also edit the .war file with 7-zip; and finally I can modify any configuration in the server. But I cannot edit the application's source code and/or recompile it.
(As potentially relevant information, I do have read access to the source code, and it does not appear to use Maven - the existence of a .project file suggests it is an Eclipse project.)
A file named geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar is part of TomEE and is located in the lib folder.
Given my constraints (no maven, no compilation - existing WAR file must work), how can this error be solved?
[Edit 1]
I removed both mail.jar and mail-1.4.4.jar from the WAR file (with 7-zip) and re-deployed, resetted the log file but the error remains the same.
I tried deleting geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar from TomEE's lib folder, but TomEE fails to start.
It seems that there is still a jar file that contains the javax.mail.Session class? Please extract all the WEB-INF/lib to an folder and search for the content of all the jar files if it contains the string "javax/mail/Session"

Difference between deploying WAR and Build folder

Question 1: May I ask what is the difference between deploying a java webapp with it's WAR file vs just copy/pasting the build folder into tomcat webapp folder?
Question 2: Somehow I am told to deploy my project just by renaming my /build/web folder to /build/, then copy and paste this folder into tomcat/webapp folder. Tomcat did serve the web app and I could access it via url. But the problem is that I suspect my System variables were not set. I start up a servlet and put this code in this init(ServletConfig config) method:
System.setProperty("LogPath","D:/Test/logs");
And doing this in my log4j.properties
log4j.appender.file.FILE=${LogPath}/wrapper.log
wrapper.log is not found in the designated directory but a stdout.log is found in tomcat/logs folder.
I am sure the init() method was fired because I have a quartz scheduler there. I am suspecting that my System.setProperty was not set. Any hint?
Update: With all the same source code, I have no problem if I am deploying with a WAR file. The ${LogPath} in log4j.properties work as expected.
Let me answer you the first question.
WAR file is a zip archive with different name. When you deploy this file to the Tomcat server, it unpacks this file to its folder as you would do it by copy-paste. If you are just developing your own project in your own environment and you don't want to distribute it, you don't need to create a war file. But if you want to distribute this project, I recommend you to create a war file. One file is easier to be sent.
Read more on Wikipedia http://en.wikipedia.org/wiki/WAR_%28file_format%29

JOSSO gateway deployment on Weblogic 10

I'm trying to work out a proof of concept with SSO using JOSSO. However, i'm having issue installing JOSSO on my server, which is a Weblogic 10 instance.
I have managed to install JOSSO in my domain. However when i start the server, there's an error saying it failed to parse one of the configuration XML file on the server because the file is not found. I double check the directory and the XML file is actually there.
The exception:
SEVERE: IOException parsing XML document from class path resource
[josso-gateway-config.xml]; nested exception is
java.io.FileNotFoundException: class path resource
[josso-gateway-config.xml] cannot be opened because it does not exist
Also another issue i'm facing is, on my production server, the webapp directory is actually in a separate partition as the Weblogic home folder. I found that the JOSSO installation program will assume that both of them are located in the same directory. Is there any way i can customize this?
Thanks in advance.
Managed to get it solved. Posting it here in case can help someone.
Due to the setup of my weblogic environment, i have decided to explode the war file, and deploy it as an exploded directory. Steps i followed:
Use WinRAR and unrar the war file into a directory
Copy all the xml configuration files into the classes folder
Rename one of the stores configuration file into josso-gateway-stores.xml
Deploy the exploded directory

Viewing JSPs with Weblogic JSPServlet

We are currently migrating from OC4J to Weblogic. We have an ANT script which builds the EAR file. The ANT also compiles and packs all the .jsp files into a jar. But when I tried to run the application on Weblogic it always returned 404 when trying to access .jsps. So I tried to add a mapping in web.xml for weblogic.servlet.JSPServlet for the URL pattern *.jsp, but I still get 404 when I try to access .jsps.
What could be the problem?
Thanks.
Your EAR file structure needs to be correct.
If you are deplying to WLS, you can deploy either an EAR or WAR seperately, however if you choose EAR file, you must have the the JSP's within the WAR file. You should only need to specify servlet and resource mapping within the web and context xml files.
You must also make sure that you have your .jar files in the library. Otherwise you can run into problems.
Let me know if you need more info.

java.lang.IllegalArgumentException: Invalid or unreadable WAR file : error in opening zip file

I got this error in Catalina.2011-03-30.log when my display.war file executed on Tomcat. The error is shown below:
Mar 30, 2011 8:01:31 PM org.apache.catalina.startup.ContextConfig init
SEVERE: Exception fixing docBase for context [/Display]
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.jar.JarFile.<init>(JarFile.java:135)
at java.util.jar.JarFile.<init>(JarFile.java:72)
at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:72)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:48)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:70)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:104)
at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:71)
at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:148)
at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:886)
at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1021)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5602)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4378)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:662)
Mar 30, 2011 8:01:31 PM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Invalid or unreadable WAR file : error in opening zip file
at org.apache.naming.resources.WARDirContext.setDocBase(WARDirContext.java:135)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4249)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4418)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:662)
Thanks in advance.
Unfortunately, the cause and the solution is not that obvious as Buhake Sindi suggests. I've seen this problem several times before in several forums. I've even experienced it myself at least once. Google gives currently over 500 hits on the exact exception message. All remains unanswered. There are however hints that it works in IDE X, but not on IDE Y and that it works on Server X, but not on Server Y. Or that removing or adding something from/to the WAR works (a typical example can be found here). Nobody has however explained the real root cause in depth.
I think that it has something to do with a combination of the JDK/JRE version used and the file size of the WAR. Here are some things you can try:
Try to update/align the JDK/JRE version in your IDE and/or appserver environment.
Try to add something to the WAR, some random JAR or JSP file or whatever and then rebuild.
I've encountered the error randomly. I think the cause is quite simple.
It can happen when you create the WAR file and transfer it into the tomcat directory by a "slow" process. In my case it is a tranfer from a remote machine by scp. The tomcat can notice that the file has changed (modification date, etc.) before the transfer is over. It may then try to deploy the incomplete file. It will encounter a zip error.
The same can in theory happen if you copy the file from another directory; though the chances are smaller, since the copy is faster.
To avoid the error altogether, the file should be moved (not copied) from another location on the same disk. Such a move is (I think) atomic.
While I am developing, having the error occur every once in a while is not a big problem, though; when I encounter it I just restart the transfer.
If you are deploying on Linux then make sure it is readable by the user that the tomcat process is running as. Run "chmod +r" to the war file to add read rights to everyone.
Same problem here. war file can be opened by 7-zip.
Edit: I figured out why. "Invalid or unreadable WAR file : error in opening zip file" is definitely a confusing error message. The real reason is simply "Tomcat unable to deploy the war because there are some initializing errors". In my case, my War file is missing a few config files which throws out file not found exception. Different Tomcat version seems to report different errors. On 6.0.26, it correctly reports the error. But on 6.0.32, it reports the confusing "Invalid or unreadable WAR file".
I faced this issue, I didn't add anything or modify anything to my build. But I guess my issue raised because I was directly uploading my war file to remote tomcat7/webapps/ directory.
Solution your war file to intermediate directory like /home/yourusername or something then move to your webapps directory. Probably for me this issue raised because file was not fully uploaded yet and tomcat was trying to extract/deploy it.
Hope this will help someone.
i face same issue many times and finally i found the solution .. exact solution
anyway i was using Tomcat 8.0.9 locally for testing and when upload the war file to server i got the error message with unzipping the war .. so i checked the server Tomcat and it was 6 so i installed that version and checked the version of Java on the server and found it 5 so i also make sure that i use version 5 on my local machine.
the issue happen with how the war file packing so if you use same version and tomcat it will packed in correct way that server can understand ...
another solution .. update the server version to match the one you use locally.
they should be the same.
hope this will solve your issue.
Aby's specific problem seems to be resolved, but in case someone else stumbles onto this page with the same problem I had...
Make sure that your /opt/solr directory has the correct permissions set. I was following the SolrJetty tutorial before later moving to the Tomcat install. Because my solr user was created with this command:
useradd -d /opt/solr -s /sbin/false solr
the /opt/solr directory was created with permissions 700, so tomcat could not get to the WAR file. Change to 755 and it worked perfectly.
In my case it was file corruption during file transfer caused this issue. Hence it's always a best practice to validate the checksum of the file whenever we transfer it to a remote server.
Make sure your path to the WAR file is correct. I had a typo and this got that same error.
BalusC is right. I encountered this error when I ran my webapp on a Linux box that had the openjdk version of Java installed instead of a regular JDK. After installing a normal JDK and pointing tomcat's JRE_HOME variable to the normal JDK the problem disappeared.
I had the same problem (java.lang.IllegalArgumentException: Invalid or unreadable WAR file). For me, the cause was that I had catalina-6.0.43.jar included in my WAR file. To get rid of the error, I created a new WAR file that didn't include this jar, then Tomcat 7 was able to successfully start the application. Unfortunately, this solution only worked for Tomcat 7. I'm still getting the same error when I try to deploy the exact same WAR on Tomcat 8.
In my case I was using WinSCP to transfer the file. I tried many times with all the suggestions described here. All I did to make it work was restarting the WinSCP and the tomcat could read the file.
Thank you #BalusC. Had same issue. Tried many options. Thought this is because of lib I added to maven without prototype scope and as a result it went to war file as well, corrected, same result. I can open it as a zip and all "looks" good there.
Tried locally (different tomcat version: 7.0.67 versus 7.0.22 I have the issue with) works good. Then tried with 7.0.22 but on different VM (instance) - works good. I suspect there is something with tomcat or probably conflict with other was files (that is only difference with other VM, all including Java is same).
The issue is resolved for me using different tomcat instance.
In my case war file not downloaded properly from the repository as size is in few KB.
After corrected my download syntax started properly
The Cause is clearly shown:
java.lang.IllegalArgumentException: Invalid or unreadable WAR file : error in opening zip file
A WAR (Web ARchive) file is a zip file containing your classes, libraries and resources for your web application.
Rename your WAR file from a.war to a.zip. If you can't open the zip file using Winzip/7-Zip/WinRar, rebuild your WAR file again.
Hope this helps.

Categories