Internal Server Error without an Exception

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Internal Server Error without an Exception

Johanneke Lamberink
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Internal Server Error without an Exception

xrgarcia3
Couple of questions.  How are you running this (ide, command line, etc)? Are you running this inside a servlet container (tomcat, jetty, etc) or as a java application? The output by default will get printed to console unless you have configured logging.

On Mon, Sep 21, 2015 at 7:08 AM, jtlamberink <[hidden email]> wrote:
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Internal Server Error without an Exception

Jerome Louvel-3
In case nothing shows in the Servlet container or console as pointed out by Ray, there is also the Resource#doCatch(Throwable) method that you might want to override to try to intercept this exception for debugging purpose.

Jerome

On Mon, Sep 21, 2015 at 11:24 AM, Ray Garcia <[hidden email]> wrote:
Couple of questions.  How are you running this (ide, command line, etc)? Are you running this inside a servlet container (tomcat, jetty, etc) or as a java application? The output by default will get printed to console unless you have configured logging.

On Mon, Sep 21, 2015 at 7:08 AM, jtlamberink <[hidden email]> wrote:
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].


To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Internal Server Error without an Exception

Johanneke Lamberink
Logging the throwable in the Resource#doCatch(Throwable) does not log anything. Debugging the application I can see that it never gets there (unless I throw an Exception myself for testing purposes).

I have a Spring web application with a REST api as a servlet:
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>com.onior.odm.rest.ODMRestletServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I've attached my ODMRestletServlet class, and the SettingsResource that results in a HTTP 500 when called. For comparison I also included the ConfigurationResource which results in a HTTP 200 when called.

We have logging configured for the application, I've included that as well. The default log level is INFO, so I changed it to TRACE for org.restlet packages.

--
Johanneke Lamberink

2015-09-22 19:38 GMT+02:00 Jerome Louvel <[hidden email]>:
In case nothing shows in the Servlet container or console as pointed out by Ray, there is also the Resource#doCatch(Throwable) method that you might want to override to try to intercept this exception for debugging purpose.

Jerome

On Mon, Sep 21, 2015 at 11:24 AM, Ray Garcia <[hidden email]> wrote:
Couple of questions.  How are you running this (ide, command line, etc)? Are you running this inside a servlet container (tomcat, jetty, etc) or as a java application? The output by default will get printed to console unless you have configured logging.

On Mon, Sep 21, 2015 at 7:08 AM, jtlamberink <[hidden email]> wrote:
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].



To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].

ODMRestletServlet.java (1K) Download Attachment
SettingsResource.java (1K) Download Attachment
ConfigurationResource.java (1K) Download Attachment
odm.log (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Internal Server Error without an Exception

Johanneke Lamberink
Included is the response I receive when calling the SettingsResource.

Btw, we are using Restlet 2.2.0 from Maven.


--
Johanneke Lamberink

2015-09-23 15:19 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Logging the throwable in the Resource#doCatch(Throwable) does not log anything. Debugging the application I can see that it never gets there (unless I throw an Exception myself for testing purposes).

I have a Spring web application with a REST api as a servlet:
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>com.onior.odm.rest.ODMRestletServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I've attached my ODMRestletServlet class, and the SettingsResource that results in a HTTP 500 when called. For comparison I also included the ConfigurationResource which results in a HTTP 200 when called.

We have logging configured for the application, I've included that as well. The default log level is INFO, so I changed it to TRACE for org.restlet packages.

--
Johanneke Lamberink

2015-09-22 19:38 GMT+02:00 Jerome Louvel <[hidden email]>:
In case nothing shows in the Servlet container or console as pointed out by Ray, there is also the Resource#doCatch(Throwable) method that you might want to override to try to intercept this exception for debugging purpose.

Jerome

On Mon, Sep 21, 2015 at 11:24 AM, Ray Garcia <[hidden email]> wrote:
Couple of questions.  How are you running this (ide, command line, etc)? Are you running this inside a servlet container (tomcat, jetty, etc) or as a java application? The output by default will get printed to console unless you have configured logging.

On Mon, Sep 21, 2015 at 7:08 AM, jtlamberink <[hidden email]> wrote:
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].




To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].

response.png (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Internal Server Error without an Exception

Johanneke Lamberink
I still don't know what was going wrong, but fiddling around with the object that is returned resolved my issue.

Thanks for the suggestions :)


--
Johanneke Lamberink

2015-09-23 15:23 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Included is the response I receive when calling the SettingsResource.

Btw, we are using Restlet 2.2.0 from Maven.


--
Johanneke Lamberink

2015-09-23 15:19 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Logging the throwable in the Resource#doCatch(Throwable) does not log anything. Debugging the application I can see that it never gets there (unless I throw an Exception myself for testing purposes).

I have a Spring web application with a REST api as a servlet:
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>com.onior.odm.rest.ODMRestletServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I've attached my ODMRestletServlet class, and the SettingsResource that results in a HTTP 500 when called. For comparison I also included the ConfigurationResource which results in a HTTP 200 when called.

We have logging configured for the application, I've included that as well. The default log level is INFO, so I changed it to TRACE for org.restlet packages.

--
Johanneke Lamberink

2015-09-22 19:38 GMT+02:00 Jerome Louvel <[hidden email]>:
In case nothing shows in the Servlet container or console as pointed out by Ray, there is also the Resource#doCatch(Throwable) method that you might want to override to try to intercept this exception for debugging purpose.

Jerome

On Mon, Sep 21, 2015 at 11:24 AM, Ray Garcia <[hidden email]> wrote:
Couple of questions.  How are you running this (ide, command line, etc)? Are you running this inside a servlet container (tomcat, jetty, etc) or as a java application? The output by default will get printed to console unless you have configured logging.

On Mon, Sep 21, 2015 at 7:08 AM, jtlamberink <[hidden email]> wrote:
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].





To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Internal Server Error without an Exception

Johanneke Lamberink
The reason I received a HTTP 500 error was because the converter for UserSettingList was a Spring bean, but the application was not able to instantiate the bean.
Why this did not result in an exception, I don't know.


--
Johanneke Lamberink

2015-09-24 11:19 GMT+02:00 Johanneke Lamberink <[hidden email]>:
I still don't know what was going wrong, but fiddling around with the object that is returned resolved my issue.

Thanks for the suggestions :)


--
Johanneke Lamberink

2015-09-23 15:23 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Included is the response I receive when calling the SettingsResource.

Btw, we are using Restlet 2.2.0 from Maven.


--
Johanneke Lamberink

2015-09-23 15:19 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Logging the throwable in the Resource#doCatch(Throwable) does not log anything. Debugging the application I can see that it never gets there (unless I throw an Exception myself for testing purposes).

I have a Spring web application with a REST api as a servlet:
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>com.onior.odm.rest.ODMRestletServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I've attached my ODMRestletServlet class, and the SettingsResource that results in a HTTP 500 when called. For comparison I also included the ConfigurationResource which results in a HTTP 200 when called.

We have logging configured for the application, I've included that as well. The default log level is INFO, so I changed it to TRACE for org.restlet packages.

--
Johanneke Lamberink

2015-09-22 19:38 GMT+02:00 Jerome Louvel <[hidden email]>:
In case nothing shows in the Servlet container or console as pointed out by Ray, there is also the Resource#doCatch(Throwable) method that you might want to override to try to intercept this exception for debugging purpose.

Jerome

On Mon, Sep 21, 2015 at 11:24 AM, Ray Garcia <[hidden email]> wrote:
Couple of questions.  How are you running this (ide, command line, etc)? Are you running this inside a servlet container (tomcat, jetty, etc) or as a java application? The output by default will get printed to console unless you have configured logging.

On Mon, Sep 21, 2015 at 7:08 AM, jtlamberink <[hidden email]> wrote:
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].






To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Internal Server Error without an Exception

Johanneke Lamberink
I found the place the error was thrown. It was in the ConverterService.toRepresentation(Object object) method.
@Override
public Representation toRepresentation( final Object object ) {
return new OutputRepresentation( MediaType.APPLICATION_JSON ) {
@Override
public void write( OutputStream outputStream ) throws IOException {
objectWriter.writeValue( outputStream, object );
}
};
}
When the OutputRepresentation.write method throws an error, this is apparently ignored by most of the framework, resulting in a HTTP 500 error, without an error message.



--
Johanneke Lamberink

2015-09-24 15:36 GMT+02:00 Johanneke Lamberink <[hidden email]>:
The reason I received a HTTP 500 error was because the converter for UserSettingList was a Spring bean, but the application was not able to instantiate the bean.
Why this did not result in an exception, I don't know.


--
Johanneke Lamberink

2015-09-24 11:19 GMT+02:00 Johanneke Lamberink <[hidden email]>:
I still don't know what was going wrong, but fiddling around with the object that is returned resolved my issue.

Thanks for the suggestions :)


--
Johanneke Lamberink

2015-09-23 15:23 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Included is the response I receive when calling the SettingsResource.

Btw, we are using Restlet 2.2.0 from Maven.


--
Johanneke Lamberink

2015-09-23 15:19 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Logging the throwable in the Resource#doCatch(Throwable) does not log anything. Debugging the application I can see that it never gets there (unless I throw an Exception myself for testing purposes).

I have a Spring web application with a REST api as a servlet:
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>com.onior.odm.rest.ODMRestletServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I've attached my ODMRestletServlet class, and the SettingsResource that results in a HTTP 500 when called. For comparison I also included the ConfigurationResource which results in a HTTP 200 when called.

We have logging configured for the application, I've included that as well. The default log level is INFO, so I changed it to TRACE for org.restlet packages.

--
Johanneke Lamberink

2015-09-22 19:38 GMT+02:00 Jerome Louvel <[hidden email]>:
In case nothing shows in the Servlet container or console as pointed out by Ray, there is also the Resource#doCatch(Throwable) method that you might want to override to try to intercept this exception for debugging purpose.

Jerome

On Mon, Sep 21, 2015 at 11:24 AM, Ray Garcia <[hidden email]> wrote:
Couple of questions.  How are you running this (ide, command line, etc)? Are you running this inside a servlet container (tomcat, jetty, etc) or as a java application? The output by default will get printed to console unless you have configured logging.

On Mon, Sep 21, 2015 at 7:08 AM, jtlamberink <[hidden email]> wrote:
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].







To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Internal Server Error without an Exception

Jerome Louvel-3
Johanneke,
Glad you foud it! AFAIR, this sort of exceptions are now properly logged since V2.3.
Could you try upgrading your version of RF?
Jerome

On Thu, Sep 24, 2015 at 10:41 AM, Johanneke Lamberink <[hidden email]> wrote:
I found the place the error was thrown. It was in the ConverterService.toRepresentation(Object object) method.
@Override
public Representation toRepresentation( final Object object ) {
return new OutputRepresentation( MediaType.APPLICATION_JSON ) {
@Override
public void write( OutputStream outputStream ) throws IOException {
objectWriter.writeValue( outputStream, object );
}
};
}
When the OutputRepresentation.write method throws an error, this is apparently ignored by most of the framework, resulting in a HTTP 500 error, without an error message.



--
Johanneke Lamberink

2015-09-24 15:36 GMT+02:00 Johanneke Lamberink <[hidden email]>:
The reason I received a HTTP 500 error was because the converter for UserSettingList was a Spring bean, but the application was not able to instantiate the bean.
Why this did not result in an exception, I don't know.


--
Johanneke Lamberink

2015-09-24 11:19 GMT+02:00 Johanneke Lamberink <[hidden email]>:
I still don't know what was going wrong, but fiddling around with the object that is returned resolved my issue.

Thanks for the suggestions :)


--
Johanneke Lamberink

2015-09-23 15:23 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Included is the response I receive when calling the SettingsResource.

Btw, we are using Restlet 2.2.0 from Maven.


--
Johanneke Lamberink

2015-09-23 15:19 GMT+02:00 Johanneke Lamberink <[hidden email]>:
Logging the throwable in the Resource#doCatch(Throwable) does not log anything. Debugging the application I can see that it never gets there (unless I throw an Exception myself for testing purposes).

I have a Spring web application with a REST api as a servlet:
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>com.onior.odm.rest.ODMRestletServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I've attached my ODMRestletServlet class, and the SettingsResource that results in a HTTP 500 when called. For comparison I also included the ConfigurationResource which results in a HTTP 200 when called.

We have logging configured for the application, I've included that as well. The default log level is INFO, so I changed it to TRACE for org.restlet packages.

--
Johanneke Lamberink

2015-09-22 19:38 GMT+02:00 Jerome Louvel <[hidden email]>:
In case nothing shows in the Servlet container or console as pointed out by Ray, there is also the Resource#doCatch(Throwable) method that you might want to override to try to intercept this exception for debugging purpose.

Jerome

On Mon, Sep 21, 2015 at 11:24 AM, Ray Garcia <[hidden email]> wrote:
Couple of questions.  How are you running this (ide, command line, etc)? Are you running this inside a servlet container (tomcat, jetty, etc) or as a java application? The output by default will get printed to console unless you have configured logging.

On Mon, Sep 21, 2015 at 7:08 AM, jtlamberink <[hidden email]> wrote:
Hi all,

My application is returning a HTTP 500 response, without any additional info on the exception being thrown. In my Resource class I have put a try/catch around everything, catching all Exceptions and logging them. Nothing is being logged, and when debugging I don't end up in the catch.

@Get
public Representation represent() {
logger.debug( "Getting user settings" );
Representation representation = null;
try {
representation = converterService.toRepresentation( new UserSettingList( SecurityUtils.getCurrentUser().getSettings() ) );
} catch (Exception e) {
logger.error(e); // never called
}
return representation; // returns a valid Representation object
}

As you can see, my own code will not throw an Exception. My question is, how can I solve this problem? Without any information on the cause of the HTTP 500 status, I have no clue where to begin to look...

Kind regards,

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].








To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].