You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stuart Stephen <st...@talkics.com> on 2003/12/05 12:04:37 UTC

Illegal Access Error [ URLConnection ]

Hi,

When I do URLConnection.guessContentTypeFromName(filename) I get an
IllegalAccessError thrown. Yet, I cannot catch this as the method only
throws an IOException.

Why does this throw an Exception in Tomcat? It doesn't throw it if the
method is called from the command prompt in a static class???

Is it a security exception thrown by tomcat?

Thanks,
Stuart Stephen



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Illegal Access Error [ URLConnection ]

Posted by Stuart Stephen <st...@talkics.com>.
Ahh, didn't think of that. That's the badger.

Good work!

Thanks.

-----Original Message-----
From: Jon Wingfield [mailto:jon.wingfield@mkodo.com]
Sent: 05 December 2003 13:21
To: Tomcat Users List
Subject: Re: Illegal Access Error [ URLConnection ]


Yep. An Error isn't an Exception; it's a Throwable.
Inheritance tree:

           Throwable
               |
         --------------
        |              |
      Error        Exception

HTH,

Jon

Stuart Stephen wrote:
> I tried putting a try and catch block around it to catch a the generic
> Exception. Yet that didn't work.
>
> Something is still a-miss?
>
> -----Original Message-----
> From: SH Solutions [mailto:info@sh-solutions.de]
> Sent: 05 December 2003 11:37
> To: 'Tomcat Users List'
> Subject: AW: Illegal Access Error [ URLConnection ]
>
>
> Hi
>
>
>>When I do URLConnection.guessContentTypeFromName(filename) I get an
>
> IllegalAccessError thrown. Yet, I cannot catch this as the method only
> throws an IOException.
>
> I dont know where this comes from since I dont have any idea what this
> method is all about.
> But I can tell you how to catch the Exception.
>
> try {
>   ..
> } catch ( IllegalAccessError iae ) {
> }
>
> As of you post I guess you thought that you couldn't catch a Exception
that
> is not declared to be thrown by the method in question. But this is only
> half the truth. You can throw everything that inherits from Throwable.
> Descendents of Exception are such classes, but there are more.
>
> You can catch about everything if you use this;
>
> } catch ( Throwable t ) {
>   t.printStackTrace(); // not required but a good start.
> ...
>
> Cu
>   Steffen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Illegal Access Error [ URLConnection ]

Posted by Jon Wingfield <jo...@mkodo.com>.
Yep. An Error isn't an Exception; it's a Throwable.
Inheritance tree:

           Throwable
               |
         --------------
        |              |
      Error        Exception

HTH,

Jon

Stuart Stephen wrote:
> I tried putting a try and catch block around it to catch a the generic
> Exception. Yet that didn't work.
> 
> Something is still a-miss?
> 
> -----Original Message-----
> From: SH Solutions [mailto:info@sh-solutions.de]
> Sent: 05 December 2003 11:37
> To: 'Tomcat Users List'
> Subject: AW: Illegal Access Error [ URLConnection ]
> 
> 
> Hi
> 
> 
>>When I do URLConnection.guessContentTypeFromName(filename) I get an
> 
> IllegalAccessError thrown. Yet, I cannot catch this as the method only
> throws an IOException.
> 
> I dont know where this comes from since I dont have any idea what this
> method is all about.
> But I can tell you how to catch the Exception.
> 
> try {
>   ..
> } catch ( IllegalAccessError iae ) {
> }
> 
> As of you post I guess you thought that you couldn't catch a Exception that
> is not declared to be thrown by the method in question. But this is only
> half the truth. You can throw everything that inherits from Throwable.
> Descendents of Exception are such classes, but there are more.
> 
> You can catch about everything if you use this;
> 
> } catch ( Throwable t ) {
>   t.printStackTrace(); // not required but a good start.
> ...
> 
> Cu
>   Steffen
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


AW: Illegal Access Error [ URLConnection ]

Posted by SH Solutions <in...@sh-solutions.de>.
Yet Throwable is more generic as Exception. Try it. 


-- 
SH Solutions, Steffen Heil
Web: http://www.sh-solutions.de
eMail: info@sh-solutions.de
MSNMS: mail@steffen-heil.de
-----Ursprüngliche Nachricht-----
Von: Stuart Stephen [mailto:stuart.stephen@talkics.com] 
Gesendet: Freitag, 5. Dezember 2003 12:39
An: Tomcat Users List
Betreff: RE: Illegal Access Error [ URLConnection ] 

I tried putting a try and catch block around it to catch a the generic
Exception. Yet that didn't work.

Something is still a-miss?

-----Original Message-----
From: SH Solutions [mailto:info@sh-solutions.de]
Sent: 05 December 2003 11:37
To: 'Tomcat Users List'
Subject: AW: Illegal Access Error [ URLConnection ]


Hi

> When I do URLConnection.guessContentTypeFromName(filename) I get an
IllegalAccessError thrown. Yet, I cannot catch this as the method only
throws an IOException.

I dont know where this comes from since I dont have any idea what this
method is all about.
But I can tell you how to catch the Exception.

try {
  ..
} catch ( IllegalAccessError iae ) {
}

As of you post I guess you thought that you couldn't catch a Exception that
is not declared to be thrown by the method in question. But this is only
half the truth. You can throw everything that inherits from Throwable.
Descendents of Exception are such classes, but there are more.

You can catch about everything if you use this;

} catch ( Throwable t ) {
  t.printStackTrace(); // not required but a good start.
...

Cu
  Steffen


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Illegal Access Error [ URLConnection ]

Posted by Stuart Stephen <st...@talkics.com>.
I tried putting a try and catch block around it to catch a the generic
Exception. Yet that didn't work.

Something is still a-miss?

-----Original Message-----
From: SH Solutions [mailto:info@sh-solutions.de]
Sent: 05 December 2003 11:37
To: 'Tomcat Users List'
Subject: AW: Illegal Access Error [ URLConnection ]


Hi

> When I do URLConnection.guessContentTypeFromName(filename) I get an
IllegalAccessError thrown. Yet, I cannot catch this as the method only
throws an IOException.

I dont know where this comes from since I dont have any idea what this
method is all about.
But I can tell you how to catch the Exception.

try {
  ..
} catch ( IllegalAccessError iae ) {
}

As of you post I guess you thought that you couldn't catch a Exception that
is not declared to be thrown by the method in question. But this is only
half the truth. You can throw everything that inherits from Throwable.
Descendents of Exception are such classes, but there are more.

You can catch about everything if you use this;

} catch ( Throwable t ) {
  t.printStackTrace(); // not required but a good start.
...

Cu
  Steffen


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


AW: Illegal Access Error [ URLConnection ]

Posted by SH Solutions <in...@sh-solutions.de>.
Hi

> When I do URLConnection.guessContentTypeFromName(filename) I get an
IllegalAccessError thrown. Yet, I cannot catch this as the method only
throws an IOException.

I dont know where this comes from since I dont have any idea what this
method is all about.
But I can tell you how to catch the Exception.

try {
  ..
} catch ( IllegalAccessError iae ) {
}

As of you post I guess you thought that you couldn't catch a Exception that
is not declared to be thrown by the method in question. But this is only
half the truth. You can throw everything that inherits from Throwable.
Descendents of Exception are such classes, but there are more.

You can catch about everything if you use this;

} catch ( Throwable t ) {
  t.printStackTrace(); // not required but a good start.
...

Cu
  Steffen


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Illegal Access Error [ URLConnection ]

Posted by Stuart Stephen <st...@talkics.com>.
This is my code by the way...

  /**
   * adds a file parameter to the request
   * @param name parameter name
   * @param filename the name of the file
   * @param is input stream to read the contents of the file from
   * @throws IOException
   */
  public void setParameter(String name, String filename, InputStream is)
throws IOException {
    boundary();
    writeName(name);
    write("; filename=\"");
    write(filename);
    write('"');
    newline();
    write("Content-Type: ");
    String type = null;
    type = connection.guessContentTypeFromName(filename);
    if (type == null) type = "application/octet-stream";
    writeln(type);
    newline();
    pipe(is, os);
    newline();
  }

-----Original Message-----
From: Stuart Stephen [mailto:stuart.stephen@talkics.com]
Sent: 05 December 2003 11:05
To: Tomcat Users List
Subject: Illegal Access Error [ URLConnection ]


Hi,

When I do URLConnection.guessContentTypeFromName(filename) I get an
IllegalAccessError thrown. Yet, I cannot catch this as the method only
throws an IOException.

Why does this throw an Exception in Tomcat? It doesn't throw it if the
method is called from the command prompt in a static class???

Is it a security exception thrown by tomcat?

Thanks,
Stuart Stephen



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org