Saturday, May 5, 2012

Error creating managed object for class

Well, while developing my enterprise application in NetBeans 7.1.2 with GlassFish 3.1.2 as the application server, the following most notable error appeared and made the project unable to deploy:

Error creating managed object for class: class org.jboss.weld.servlet.WeldListener

and a bunch of other errors and exceptions.


I tried to revert my changes since the last revision from the revision control and found myself in the same situation.

Manual clean followed by build also did nothing.

Solution:
My gut told me I just needed to clean the NetBeans trash and so I did:

  • I deleted all of my project locally;
  • Restarted NetBeans;
  • Checked out my project from the revision control again;
  • Run it, and it worked!
I don't know the cause of this, but if you can't find another way then just try to clean your NetBeans generated junk.

I was having this in the context of a RESTful web service (Jersey) plus EJBs which was working properly. A little investigation told me that it might be a bug in Jersey, check the links below for more information.

I also invite you to comment on a better solution for this and I'll update this post with it.

Update: I can now reproduce this issue, if I set my RESTful web service to be session scoped (@SessionScoped) it breaks but sometimes I can make it work by changing to request scoped (@RequestScoped) again. My source code is simply the following:

@SessionScoped
@Path("/mypath")
public class MyREST {
    
    @EJB
    private MyFacadeLocal myFacade;
    
    public MyREST() {
    }

    @GET
    @Produces("text/plain")
    public String respond() {        
        return "DONE";
    }
}

Useful links:

No comments:

Post a Comment

Feel free to share your thoughts!