Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

URLConnection and java.net.UnknownServiceException

10 views
Skip to first unread message

Carey Boldenow

unread,
Jan 17, 2003, 7:53:52 AM1/17/03
to

I have deployed a web app in WL6.10SP3 and I am unable to write
to a file via an URLConnection. The following is the code snippet
that is causing the problem. By the way if I run the same code in
Jrun or Tomcat,it works just fine.

urlLogConnection = logURL.openConnection();

urlLogConnection.setDoOutput(true);

urlLogConnection.setDoInput(true);

urlLogConnection.setUseCaches(false);

log = new PrintWriter(new OutputStreamWriter(urlLogConnection.getOutputStream()),true);

At this point I get the following exception;

java.net.UnknownServiceException: protocol doesn't support output
at java.net.URLConnection.getOutputStream(URLConnection.java:650)
at com.javaexchange.dbConnectionBroker.DbConnectionBroker.<init>(DbConne
ctionBroker.java:108)
at com.cytera.frameworks.database.ConnPoolJuggler.init(ConnPoolJuggler.j
ava:529)
at ServerConfigurator.init(ServerConfigurator.java:128)
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
pl.java:713)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStub
Impl.java:656)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubI
mpl.java:601)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppS
ervletContext.java:2272)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebApp

Any help is greatly appreciated.

Regards,
Carey Boldenow

Carey Boldenow

unread,
Jan 17, 2003, 4:03:18 PM1/17/03
to

Here is an update to my problem, I am now able to get an
OutputStream to the file without WL complaining. Basically, I
had to construct the URL using a URLStreamHandler, see below;

URL u1 = getServletContext().getResource(config.getInitParameter("log-file-path")+
"ConnectionPool.log");

logURL = new URL(u1,"",new sun.net.www.protocol.http.Handler());

Not sure if this was the right thing to do, but at least the
exception went away. However, nothing gets written to the file,
and further more, if I try and get an InputStream to the file to
read its contents, the server throws a 501 error, which basically says that the
server does not support the
functionality required to fulfill the request. I am deploying
the app through a .war file and the following is the string representation of
the URL created.

URL:zip:C:/bea/wlserver6.1/config/mydomain/applications/.wlnotdel
ete/wl_comp9811.war!/WEB-INF/classes/logs/ConnectionPool.log

Is it possible to write to a file that is located in a war file?

Thanks for any help offered.

Dimitri I. Rakitine

unread,
Jan 18, 2003, 11:38:09 PM1/18/03
to
You definitely do not want to write to a file which is inside a .war archive.
Why do you want to do that ???

Carey Boldenow <c.bol...@cyterasystems.com> wrote:

--
Dimitri

Dimitri I. Rakitine

unread,
Jan 18, 2003, 11:36:33 PM1/18/03
to
This is strange how it worked before - AFAIK, file protocol implementation
is read only.

Carey Boldenow <c.bol...@cyterasystems.com> wrote:

> urlLogConnection = logURL.openConnection();

> urlLogConnection.setDoOutput(true);

> urlLogConnection.setDoInput(true);

> urlLogConnection.setUseCaches(false);

> Regards,
> Carey Boldenow

--
Dimitri

Carey Boldenow

unread,
Jan 19, 2003, 2:24:18 PM1/19/03
to

You can write to a file through a URLConnection, and by invoking
the setDoOutput(true), the server should allow me to do that
through that connection. As stated, Jrun and Tomcat allow it,
why not WebLogic? Is there something funky as to how to Weblogic
implements the underlying HTTPUrlConnection?

Regards,
Carey

Carey Boldenow

unread,
Jan 19, 2003, 2:18:42 PM1/19/03
to

The reason why I want to write to file in a .war file is quite simple. Me web application
is being deployed entirely through the .war file. I would rather not explode out
just one small piece of the application just so I can write out to a log file.
But if that is my only option, then I guess I have no alternative.

Regards,
Carey
"Dimitri I. Rakitine" <dim...@dima.dhs.org> wrote:

Dimitri I. Rakitine

unread,
Jan 20, 2003, 11:35:15 PM1/20/03
to
Why don't you write your logs to some other location ?

Carey Boldenow <c.bol...@cyterasystems.com> wrote:

--
Dimitri

0 new messages