facebook

MyEclipse crashes when trying to access @Resource injection

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #306949 Reply

    Mork
    Participant

    Here’s what appears to be a serious MyEclipse bug that I’ve been trying to work around for three weeks:

    Steps to reproduce:

    1. Use Tomcat 6.x standard installation (I’m using 6.0.24).

    Using MyEclipse, create a web service project.
    Add JAX-WS libraries to build path as noted in the tutorial

    2. Create this Web Service class:

    package servletws;

    import javax.annotation.Resource;
    import javax.jws.WebService;
    import javax.xml.ws.WebServiceContext;


    @WebService

    public class HelloServlet
    {
    @Resource
    WebServiceContext wsContext;

    public String hello(String msg)
    {
    return “Servlet WS: ” + wsContext.getUserPrincipal() + “: ” + msg;
    }
    }

    Then create new Web Service using “bottom-up” – using this class above.

    Check the checkbox to “create wsdl”.

    I modified my wsdl to run on part 8000.

    Then deploy the web service as an “exploded archive”.

    Note that the wsdl correctly displays in the browser.

    =========

    3. Create a client to access the new web service above using MyEclipse.

    4. Note that you get a NullPointerException on the line that attempts to access the context (wsContext.getUserPrincipal()).

    The @Resource line of code in the service, for some reason, is not being correctly injected (hence the NullPointerException).

    ———–

    I’ve verified this problem in three Tomcat installations, two users, and versions 7.5 and 8 of MyEclipse.

    ————

    I believe the problem may be that MyEclipse is deploying a JAR file with some type of conflict.

    Can you please fix this and let me know what I should do to work around this development “show-stopper” problem?

    Thanks

    Mork

    P.S. I can send you complete source and deployed projects if this would be helpful.

    #306980

    Brian Fernandes
    Moderator

    Mork,

    I have a couple of suggestions:
    1) Have you tried to access the generated WebService using our integrated SOAP web services explorer? This would be the first step before attempting to even generate a client. (Section 6.3 in the tutorial – http://www.myeclipseide.com/documentation/quickstarts/webservices_jaxws/)
    2) When generating a bottom up web service, could you try generating one by specifying a class without annotations which is just functional? A wrapper class with the right annotations should be generated for you. Check if that works – you can then begin to tweak the wrapper class that is generated.

    The problem you are facing does not seem to be an issue with libraries, deployment or the server, but a problem with the web service itself. Please let us know how this goes.

    #306986

    Mork
    Participant

    The web service works fine until I add the @Resource annotation and then try to access it in the client. That’s when the NullPointerException happens.

    (The WSDL works fine in all cases in the browser. This is a run-time issue of some type).

    I’ll zip up things and send them to you today.

    Thanks Brian.

    – M

    #307487

    mfkilgore
    Member

    Mork,

    Did you ever get an answer on this. I have the same problem with the resource being null.

    #307496

    Mork
    Participant

    I did get it working, but I never actually figured out if MyEclipse was the culprit.

    I was using code directly out of a Java Web Services (Up and Running) O’Reiley book, but I kept getting NullPointerExceptions where I tried to acesss the MessageContext.

    The MyEclipse folks did take a look, but concluded that it was my code that was the problem (the author’s code of the O’Reiley book). In actuality, based on their reply, I don’t think they spent much time (I’m sure they’re busy, but still….) considering the actual issue I raised.

    In any case, what I did to fix this NullPointerException problem was to create setter and getter methods for the injected @Resource variable. Then, I used the injected context inside the setter method. The MyEclipse folks suggested something similar, but their “fixed” code didn’t work.

    Why the code didn’t work from the O’Reily book and seemingly countless similar examples on the web remains a mystery. Too many variables (Tomcat, MyEclipse, code, JAX-WS library problem, etc.) to pin down the exact cause.

    I think I got wrapped around the axle when a “Simple” example just didn’t work as shown in my book and examples I found. I even corresponded with the author of the book and he didn’t see any issues either…

    Sigh….

    Hope this information is useful.

    Cheers!

    – M

    P.S. There are some other postings on the various forums about this issue (some by me).

    #307541

    mfkilgore
    Member

    Thanks for the information. I think my problem might be different as my service is REST vs your SOAP interface. Could be that tried what you said incorrectly but I am still not seeing the value set as expected. Glad you got it working!

    #307548

    Mork
    Participant

    Check out the Sun spec too to see if that helps.

    Also, the O’Reily book may help as it also covers REST.

    Best Regards,

    — M

    #307598

    Hi Mork,

    I have escalated this to the dev team member, they will get back to you on this.

    Thanks,
    Chakri.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: MyEclipse crashes when trying to access @Resource injection

You must be logged in to post in the forum log in