Cannot find application-client.xml

Hello.

I have an application that runs ok on webstart 1.5. My application contains inside client jar a META-INF/application-client.xml.

Despite of this, with webstart 1.6 I get the following error :

javax.naming.NamingException: META-INF/application-client.xml not found (see J2EE spec, application-client chapter for requirements and format of the file)

at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getRequiredClasspathResource(ApplicationClientInitialContextFactory.java:239)

at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getArchive(ApplicationClientInitialContextFactory.java:161)

at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getInitialContext(ApplicationClientInitialContextFactory.java:111)

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

at javax.naming.InitialContext.init(InitialContext.java:223)

at javax.naming.InitialContext.<init>(InitialContext.java:197)

....................

Must I do something different in 1.6?

Mike

[1171 byte] By [mikedpa] at [2007-11-27 8:15:41]
# 1

Not that this is any help to you but I have the same problem. I've gotten it to work when using the RMIInitialContext factory instead. This context relies upon the entry in the ejb-jar.xml rather than application-client.xml to lookup the ejb. However Oracles own documentation states to use ApplicationClientInitialContextFactory when connecting from a thick standalone client. We have a case open with Oracle right now regarding this issue. Send me an email and I can give you the case number.

Here is my stacktrace:

javax.naming.NamingException: META-INF/application-client.xml resource not found (see J2EE spec, application-client chapter for requirements and format of the file)

at com.evermind.server.ApplicationClientInitialContextFactory.getInitialContext(ApplicationClientInitialContextFactory.java:90)

at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)

at javax.naming.InitialContext.init(Unknown Source)

at javax.naming.InitialContext.<init>(Unknown Source)

at com.tek.mfg.tekDist.clientUI.EJBTest.getInitialContext(EJBTest.java:31)

at com.tek.mfg.tekDist.clientUI.EJBTest.callEJB(EJBTest.java:38)

at com.tek.mfg.tekDist.clientUI.EJBTest.main(EJBTest.java:18)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.sun.javaws.Launcher.executeApplication(Unknown Source)

at com.sun.javaws.Launcher.executeMainClass(Unknown Source)

at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)

at com.sun.javaws.Launcher.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

-Marc

mwangenheima at 2007-7-12 20:00:30 > top of Java-index,Desktop,Deploying...
# 2
Thank you for your response.I use oc4j 10.1.3.2. From my stacktrace it looks to be a classpath problem.Is there a link to the issue you opened?Mike
mikedpa at 2007-7-12 20:00:30 > top of Java-index,Desktop,Deploying...
# 3

So after about a good days worth of research I found the issues. First of all let me say that your issue is somewhat unrelated to mine.

I am using an older version of the oc4jclient.jar driver and it's implementation differs quite a bit from the 10.1.3.20 version.

Your issue is actually a problem with Java Web Start 6 and not Oracle. There appears to be a bug in the java.net.URLConnection class in web start 6.

The oc4jclient.jar has a handle to the application-client.xml file embedded in some jar.

The way Oracle tries to load this file is by using a mechanism such as this:

byte data[] = new byte[contentLength];

int readThisTurn;

for(int readSoFar = 0; readSoFar < contentLength; readSoFar += readThisTurn)

{

readThisTurn = in.read(data, readSoFar, contentLength - readSoFar);

if(readThisTurn < 0)

throw new IOException();

}

The contentLength is determined by the following:

int contentLength = url.openConnection().getContentLength();

This is where the problem truly is. When you execute this line in a Java 6 JVM via command line the size returned is the size of the application-client.xml file.

However when this line executes via Java Web Start 6 the size returned is the size of the container! Meaning the size of the entire jar file that is holding the application-client.xml file!

This causes Oracles code to read the entire application-client.xml file then loop in the for loop and return -1 on the attempt to read more data.

Remember when executing in web start the loop will be defined as the size of the jar file not the application-client.xml file.

Upon the attempt to read more data from application-client.xml the code returns with a -1 and throws an IOException.

This causes the caller of this method the throw a NamingException because

the byte[] is null.

So to get around this problem you have three choices.

a) use RMIInitialContextFactory which doesn't need to load application-client.xml

b) complain to Sun that getContentLength() in java.net.URLConnection

returns the size of the container and not the size of the file inside the container

c) download the source for URLConnection and fix it yourself

I hope this explanation makes sense and helps you to overcome this issue.

-Marc

mwangenheima at 2007-7-12 20:00:30 > top of Java-index,Desktop,Deploying...
# 4

Well I guess I should have checked this before my post above.

Seems somebody already reported this as a bug to Sun see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6514488

Unfortunately the bug was closed on 2007-05-14 as Not Reproducible.

Another user asked for this bug to be reopened on 6-18-07.

mwangenheima at 2007-7-12 20:00:30 > top of Java-index,Desktop,Deploying...
# 5
"The way Oracle tries to load this file ..." : Can you tell me what is the oracle class which does this? Mike
mikedpa at 2007-7-12 20:00:30 > top of Java-index,Desktop,Deploying...
# 6
com.evermind.io.IOUtils
mwangenheima at 2007-7-12 20:00:30 > top of Java-index,Desktop,Deploying...