users@jersey.java.net

[Jersey] InjectLink in unit test cases causes 500 Server Error

From: naresh <baliga_naresh_at_yahoo.com>
Date: Tue, 24 Mar 2015 13:05:32 -0700 (MST)

Hello,

I'm using Jersey 2.17 and use Spring for IoC. I have simple declarative
hyperlinking in my representation as below:
@InjectLink(value = "abc/{id}")
private Uri myUrL;


/This works fine in the web application when deployed on WebLogic.
/
I'm attempting to update (I'm upgrading from Jersey 1.5 to 2.17) my unit
test cases.

Following is the unit test container setup:

    ....
     @Override
      protected TestContainerFactory getTestContainerFactory () throws
TestContainerException
      {
         return new GrizzlyTestContainerFactory();
      }

      @Override
      protected Application configure ()
      {
         return resourceConfig;
      }

      @Override
      protected DeploymentContext configureDeployment ()
      {
         resourceConfig = new ResourceConfig();

         resourceConfig.register( RequestContextFilter.class );

         resourceConfig.register( JacksonFeature.class );
         resourceConfig.register( JacksonObjectMapperContextResolver.class
);

         resourceConfig.register( DeclarativeLinkingFeature.class );
         resourceConfig.register( EntityFilteringFeature.class );


         resourceConfig.property( "contextConfig", new
ClassPathXmlApplicationContext( "test-applicationContext.xml" ) );
         resourceConfig.packages( "com.mywebapp.rest" );

         return DeploymentContext.builder( resourceConfig ).contextPath(
"/mywebapp" ).build();
      }
      ....


I'm not seeing any stack traces, just the following 500 Request Failed from
Grizzly:
Mar 24, 2015 12:49:32 PM
org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory$GrizzlyTestContainer
<init>
INFO: Creating GrizzlyTestContainer configured at the base URI
http://localhost:9998/
Mar 24, 2015 12:49:33 PM org.glassfish.grizzly.http.server.NetworkListener
start
INFO: Started listener bound to [localhost:9998]
Mar 24, 2015 12:49:33 PM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
Mar 24, 2015 12:49:33 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 1 * Sending client request on thread main
1 > GET http://localhost:9998/mywebapp/somepath
1 > Accept: application/json

Mar 24, 2015 12:49:34 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 2 * Client response received on thread main
2 < 500
2 < Connection: close
2 < Content-Length: 1033
2 < Content-Type: text/html;charset=ISO-8859-1
2 < Date: Tue, 24 Mar 2015 19:49:34 GMT
<html><head><title>Grizzly 2.3.16</title> </head><body><div
class="header">Request failed.</div><div class="body">Request
failed.</div><div class="footer">Grizzly 2.3.16</div></body></html>


This problem goes away when I comment out the @InjectLink in my
representation.

Any help or pointers will be appreciated.



--
View this message in context: http://jersey.576304.n2.nabble.com/InjectLink-in-unit-test-cases-causes-500-Server-Error-tp7583216.html
Sent from the Jersey mailing list archive at Nabble.com.