[Solved] REST Service: Unable to create new reference LazyLoadedFilterReference

After some hours of searching and testing, I found the solution and want to share it with you, so you may get the answer faster.

I have a REST API method:

    @POST
    @AnonymousAllowed    // check permissions separately (see below)
    @Path("import")
    @RequestType(value = List.class, genericTypes = {ManageBranchesRestProject.class})
    @Consumes({MediaType.APPLICATION_JSON})
    @Produces({MediaType.APPLICATION_JSON})
    public Response importIssueBranches(@DefaultValue("[]") final List<ManageBranchesRestIssue> lstIssues)
    {
        ....
        ....
    }

This lead to the following exception:

[INFO] [talledLocalContainer] 2017-05-23 15:30:18,045 http-nio-2990-exec-7 ERROR admin 930x306x1 3x3yoa 0:0:0:0:0:0:0:1 /rest/branches/1.0/branches/BIB/all [c.a.plugin.servlet.DefaultServletModuleManager] Unable to create new reference LazyLoadedFilterReference{descriptor=com.besi.jira.plugins.customfield-fixbranches:manage-branches-rest-filter (Branches REST API), filterConfig=com.atlassian.plugin.servlet.filter.PluginFilterConfig@5581d22e}
[INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference$InitializationException: com.sun.jersey.spi.inject.Errors$ErrorMessagesException
[INFO] [talledLocalContainer] 	at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)
[INFO] [talledLocalContainer] 	at com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.servlet.DefaultServletModuleManager.getInstance(DefaultServletModuleManager.java:447)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilter(DefaultServletModuleManager.java:440)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilters(DefaultServletModuleManager.java:300)
[INFO] [talledLocalContainer] 	at com.atlassian.plugins.rest.module.servlet.DefaultRestServletModuleManager.getFilters(DefaultRestServletModuleManager.java:121)

There was a typo (classical copy&paste mistake) in it: ManageBranchesRestProject.class should be named ManageBranchesRestIssue.class.

But because of this exception I had to search for a long time until I found the cause.

Maybe this helps.

2 Likes

Thanks for sharing both the problem and the solution.

If you add your solution as a separate reply to your post you could even mark it solved as explained here: Community Update #1: Accepted Solutions

There was a typo (classical copy&paste mistake) in it: ManageBranchesRestProject.class should be named ManageBranchesRestIssue.class.

But because of this exception I had to search for a long time until I found the cause.

Maybe this helps.

2 Likes

Sorry for the bump, but the same error brought me here and helped me figure out why, although the root cause was different.

I ran into this error as well, in a separate way - I had the path annotation defined the same in two files (copy paste error :slight_smile: )

In two separate files, I had @Path("/config") defined at the top of the class. This caused the same error as listed above.

10 Likes

Don’t be sorry! It’s helpful to know that this exception is generally just hiding the real underlying error message. In my case, the problem was that my filter’s constructor wasn’t public.

2 Likes

I had the same problem because of the dependency

<dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
</dependency>

using with annotation @AnonymousAllowed. Solution: I deleted @AnonymousAllowed and dependency for this and changed dependency of javax.ws.rs to

<dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0.1</version>
            <scope>provided</scope>
</dependency>

Hope, it would help someone because it took long time to find out.

3 Likes

I had the error too. My case was that the before mentioned dependency to javax.ws.rs was not included in the pom.

1 Like

If anybody got there error fixed with this solution, does anyone know why changing library to new version fixes it?