dev@glassfish.java.net

Embedded v3 working now, but...

From: Vivek Pandey <Vivek.Pandey_at_Sun.COM>
Date: Thu, 04 Sep 2008 18:27:03 -0700

Finally I got the embedded API working and now the embedded test cases
pass and also can run my grails application using the embedded APIs :-)
But before it is any useful in general there are bugs that need to be
fixed in v3:

1. https://glassfish.dev.java.net/issues/show_bug.cgi?id=5872. There is
NPE here, as a workaround I set a fake installRoot system property to
get it working.

2. There is a bug in
com.sun.enterprise.deployment.deploy.shared.JarArchive.getName(), where
I get StringIndexOutOfBound exception. The owner of this module please
review it and if ok apply this patch. This is blocking me. I wonder how
it ever worked for things like: file:/ws/embedded/api/xxxxxx, the code
below will just fail. Here is the patch:

---
deployment/common/src/main/java/com/sun/enterprise/deployment/deploy/shared/JarArchive.java
(revision 22354)
+++
deployment/common/src/main/java/com/sun/enterprise/deployment/deploy/shared/JarArchive.java
(working copy)
@@ -76,7 +76,7 @@
     public String getName() {
          String path = Util.getURIName(getURI());
          int lastDot = path.lastIndexOf('.');
- int endOfName = (lastDot != 1) ? lastDot : path.length();
+ int endOfName = (lastDot != -1) ? lastDot : path.length();
          String name = path.substring(0, endOfName);
          return name;
     }


3. With the bug in 2 fixed, found out that
com.sun.enterprise.deployment.node.SaxParserHandler.resolveEntity()
fails, as it tries to locate DTDs a installRoot/lib/dtds. Instead of
this it should be asking the respective container to resolve it. I see
WebEntityResolver, but for some reason WebEntityResolver.resolveEntity()
is not called in this code path. There is existing code in v3 embedded
API where it provides its own EntityResolver and sets it like this:

 parser.replace(WebEntityResolver.class, EntityResolverImpl.class);

Above parser is InhabitantsParser.

But it does not work, infact neither WebEntityResolver.resolveEntity()
nor EmbeddedEntityResolver.resolveEntity() is ever called.

To proceed, I put a temp fix in SaxParserHandler.resolveEntity() to
fetch it using systemId if local dtds are not found.

This needs to be fixed.

4. In embedded API implementation, httpListener is created in memory and
the id is the same as port on which we try to start the server. So if
'new AppServer(9999)' is called then the id for http-listner config
element is 9999. Now it does not work. The reason being is that the id
of http-listener is the value in byContract Map of Habitat, but the
value is hardcoded to be 'http-listner-1' and is not taken from the
http-listner config element. This looks like a clear bug to me. In the
meantime, to make it work, I have hard coded 'http-listner-1' as id in
the embedded API.

5. web-all-10.0-build-SNAPSHOT.jar needs to be released on maven repo on
a regular basis to run the embedded tests regularly. This calls for
separate distribution maven job.

Above 5 issues need to be addressed pretty soon for the embedded APIs to
be working and also for grails (run-app-gf) and glassfish gem.

Thanks to Jan for fixing couple of bugs yesterday in web-glue that made
me proceed. FYI, I have checked in my changes to embedded workspace.

-vivek.