0

I know that we can provide multiple packages in the providers separated via semi-colon.

<servlet>
    ...
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>com.package1;com.package2</param-value>
    </init-param>
    ...
</servlet>

Now lets say I want to include multiple packages having the pattern as below:

com.p1.p2.provider
com.p1.p3.provider
com.p1.p4.p5.provider

So how can I do this without writing all of the packages in the value field? I have tried below code snippets which did not work for me. Is there any other way?

<servlet>
    ...
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>com.**.provider</param-value>
    </init-param>
    ...
</servlet>

and

<servlet>
    ...
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>com.*.provider</param-value>
    </init-param>
    ...
</servlet>

Thanks in advance.

user145078
  • 241
  • 2
  • 3
  • 8
  • The scanning traverses the packages listed _recursively_. So you can just use `com.p1` – Paul Samsotha Jul 14 '17 at 15:11
  • I have already tried that, but on doing this the URL throws 415 Not supported error. And when I provide the full package path, everything works – user145078 Jul 17 '17 at 04:13
  • 415 is unrelated to package scanning. You have another unrelated problem. – Paul Samsotha Jul 17 '17 at 04:40
  • Actually I am trying to modify a really old product and add a new service which should use Jersey. It already has a lot of packages and classes. I was hoping to have a package pattern and then provide this pattern in the web.xml so that I don't face these kind of unrelated problems – user145078 Jul 17 '17 at 05:18
  • Is there a way to do this? Providing package patterns in the web.xml? – user145078 Jul 17 '17 at 05:23
  • Not that I know of. Usually the recursive scan is enough. If you have a "root package" and put all your classes in that package or a subpackage, then just adding the root package should be enough. That's how I always do it. – Paul Samsotha Jul 17 '17 at 06:17
  • I was fearing this. Recursive scan should have been enough ideally but this is not working for the problem statement I have. Thank you for the help. – user145078 Jul 17 '17 at 06:40

0 Answers0