Guice injection and custom annotation leads to NPE

View: New views
4 Messages — Rating Filter:   Alert me  

Guice injection and custom annotation leads to NPE

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We use Guice injection to help setup our classes, and also help us handle our transaction handling with the database connection. We have a custom Annotation that I think may be screwing up the publishing of the Webservice.

If we have this one method in the Service:

@TransactionalSimple
UserPhotoSummary retrievePhotoSummary(long loginId, long propertyId, long listingId) {
     //Make call to the database
}

Then we get an NPE. If I remove that method and its annotation, everything runs fine (....except we cant make a call to the DB like we like to).

The NPE is this:

Caused by: java.lang.NullPointerException
        at com.sun.xml.ws.server.EndpointFactory.getWsdlLocation(EndpointFactory.java:399)
        at com.sun.xml.ws.transport.http.server.EndpointImpl.getPrimaryWsdl(EndpointImpl.java:284)
        at com.sun.xml.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:224)
        at com.sun.xml.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:154)
        at com.redfin.uploader.photoService.PhotoServicePublisher.configureAndPublishEndpoint(PhotoServicePublisher.java:154)
        ... 1 more

Here's our annotation we have:

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.PARAMETER})
@BindingAnnotation
@Documented
public @interface TransactionalSimple {}

Is there something wrong with this custom annotation we are trying to use? Do we need to declare something differnt about it?
[Message sent by forum member 'demichej' (demichej)]

http://forums.java.net/jive/thread.jspa?messageID=354998

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Guice injection and custom annotation leads to NPE

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think that it has to do with our Custom Annotation, because for some reason, our @WebService annotation on the class doesn't seem to be recognized. Here's the code in the EndpointFactory that is giving a null when we have our custom annotation method:

    public static @Nullable String getWsdlLocation(Class<?> implType) {
        String wsdl;
        WebService ws = implType.getAnnotation(WebService.class);
        if (ws != null) {
            wsdl = ws.wsdlLocation();
        } else {
            WebServiceProvider wsProvider = implType.getAnnotation(WebServiceProvider.class);
            assert wsProvider != null;
            wsdl = wsProvider.wsdlLocation();
        }
        if (wsdl.length() < 1) {
            wsdl = null;
        }
        return wsdl;
    }

No WebService is found in the annotation map, but if we remove the method with our annotation, then the WebService IS found. Any ideas?
[Message sent by forum member 'demichej' (demichej)]

http://forums.java.net/jive/thread.jspa?messageID=354999

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Guice injection and custom annotation leads to NPE

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

FYI, I found a workaround for my issue, but this appears to be a bug in JAXWS. I also tried using 2.1.5 as well as 2.1.4.

It is reproducible by making a simple @WebService class which contains a method annotated with a custom Annotation with the following definition:

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.PARAMETER})
@BindingAnnotation
@Documented
public @interface TransactionalSimple {}

If the web service class contains an annotated method with this custom annotation, the endpoint.publish(URL) method will NPE. If you remove the annotation from the method, the endpoint.publish(URL) method works fine.

How do i submit a bug?
[Message sent by forum member 'demichej' (demichej)]

http://forums.java.net/jive/thread.jspa?messageID=355124

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Guice injection and custom annotation leads to NPE

by Jitendra Kotamraju :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

metro@... wrote:

> FYI, I found a workaround for my issue, but this appears to be a bug in JAXWS. I also tried using 2.1.5 as well as 2.1.4.
>
> It is reproducible by making a simple @WebService class which contains a method annotated with a custom Annotation with the following definition:
>
> @Retention(RetentionPolicy.RUNTIME)
> @Target({ElementType.METHOD, ElementType.PARAMETER})
> @BindingAnnotation
> @Documented
> public @interface TransactionalSimple {}
>
> If the web service class contains an annotated method with this custom annotation, the endpoint.publish(URL) method will NPE. If you remove the annotation from the method, the endpoint.publish(URL) method works fine.
>
> How do i submit a bug?
> [Message sent by forum member 'demichej' (demichej)]
>  
May be Guice creates a dynamic proxy or something so that annotations
are not visible to JAX-WS runtime.
You can file an issue https://jax-ws.dev.java.net/servlets/ProjectIssues
Can you also attach a reproducible test case.

thanks,
Jitu
> http://forums.java.net/jive/thread.jspa?messageID=355124
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...