You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/05/18 04:42:44 UTC

svn commit: r539225 - /incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java

Author: dblevins
Date: Thu May 17 19:42:43 2007
New Revision: 539225

URL: http://svn.apache.org/viewvc?view=rev&rev=539225
Log:
In case a descriptor cannot be unmarshalled, write it to the temp directory for debugging purposes.

Modified:
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?view=diff&rev=539225&r1=539224&r2=539225
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java Thu May 17 19:42:43 2007
@@ -26,19 +26,18 @@
 import org.apache.openejb.jee.oejb3.JaxbOpenejbJar3;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
 import org.xml.sax.SAXException;
-import org.xml.sax.HandlerBase;
-import org.xml.sax.AttributeList;
 import org.xml.sax.Attributes;
 import org.xml.sax.helpers.DefaultHandler;
 
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.parsers.SAXParser;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.net.URL;
 import java.util.List;
 
@@ -186,11 +185,29 @@
                     } catch (Exception dontCare) {
                     }
 
+                    String filePath = "<error: could not be written>";
+                    try {
+                        File tempFile = File.createTempFile("openejb-jar-", ".xml");
+                        try {
+                            FileOutputStream out = new FileOutputStream(tempFile);
+                            InputStream in = source.get();
+                            int b = in.read();
+                            while (b != -1){
+                                out.write(b);
+                                b = in.read();
+                            }
+                            out.close();
+                        } catch (IOException e) {
+                        }
+                        filePath = tempFile.getAbsolutePath();
+                    } catch (IOException e) {
+                    }
+
                     Exception e = realIssue[0];
                     if (e instanceof SAXException) {
-                        throw new OpenEJBException("Cannot parse the openejb-jar.xml.", e);
+                        throw new OpenEJBException("Cannot parse the openejb-jar.xml. Xml content written to: "+filePath, e);
                     } else if (e instanceof JAXBException) {
-                        throw new OpenEJBException("Cannot unmarshall the openejb-jar.xml.", e);
+                        throw new OpenEJBException("Cannot unmarshall the openejb-jar.xml. Xml content written to: "+filePath, e);
                     } else if (e instanceof IOException) {
                         throw new OpenEJBException("Cannot read the openejb-jar.xml.", e);
                     } else {