Hello,

I'm new to this list, so sorry if this has been discussed earlier.

We are developing a large application on an comercial EJB server. To broaden
our
vision, I 'ported' our app to jboss. As we are only using J2EE standard
stuff,
this was fast and easy.

Great work! Congratulation to all!

Due to the fact that we are sitting behind a firewall, I first ran into a
problem.
Everytime a EJB is (hot) deployed, the system is accessing the EJB 1.1 spec
from
the original location (as specified in the EJB - xml file.

Attached is a patch which introduces an Entity Resolver to the SAX parser.
Just
put the DTD in your classpath and the access will be ommitted.

Glad to help, please comment.

Greetinx,

        Wolfgang Wermer

-------------------------------- snip -------------------------------
Index: XmlFileLoader.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/metadata/XmlFileLoader.java,v
retrieving revision 1.3
diff -u -r1.3 XmlFileLoader.java
--- XmlFileLoader.java  2000/08/18 03:21:06     1.3
+++ XmlFileLoader.java  2000/08/28 05:30:06
@@ -11,12 +11,18 @@
 import java.io.Reader;
 import java.io.InputStreamReader;

+import java.io.File;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.util.Hashtable;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;

 import org.xml.sax.Parser;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
+import org.xml.sax.EntityResolver;

 import org.jboss.ejb.DeploymentException;
 import org.jboss.logging.Logger;
@@ -29,8 +35,47 @@
  *   @version $Revision: 1.3 $
  */
 public class XmlFileLoader {
-       // Constants -----------------------------------------------------

+  /**
+   * Local entity resolver to handle EJB 1.1 DTD. With this a http
connection
+   * to sun is not needed during deployment.
+   * @author <a href="mailto:[EMAIL PROTECTED]">Wolfgang Werner</a>
+  **/
+  private class LocalResolver implements EntityResolver {
+
+    private Hashtable dtds = new Hashtable();
+
+               public LocalResolver() {
+                       registerDTD(
+                               "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 
+1.1//EN",
+        "ejb-jar.dtd");
+               }
+
+               public void registerDTD(String publicId, String dtdFileName) {
+      dtds.put(publicId, dtdFileName);
+    }
+
+    public InputSource resolveEntity (String publicId, String systemId)
+    {
+       String
+               dtd = (String)dtds.get(publicId);
+
+      if (dtd != null) {
+        try {
+                     InputStream
+                       dtdStream =
XmlFileLoader.class.getClassLoader().getResourceAsStream(dtd);
+          return new InputSource(dtdStream);
+        } catch( Exception ex ) {
+          // ignore
+        }
+      }
+
+      return null;
+    }
+  }
+
+       // Constants -----------------------------------------------------
+
        // Attributes ----------------------------------------------------
        ClassLoader classLoader;

@@ -122,6 +167,10 @@
                Parser parser = new com.sun.xml.parser.Parser();
                xdb.setParser(parser);

+               // Use a local entity resolver to get rid of the DTD loading via 
+internet
+               EntityResolver er = new LocalResolver();
+               parser.setEntityResolver(er);
+
                try {
                    parser.parse(new InputSource(in));
                        return xdb.getDocument();
-------------------------------- snap ----------------------------------


Reply via email to