On 09/10/2022 20:50, Garret Wilson wrote:
I have a Java 11 project embedding Tomcat:
```xml
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>9.0.50</version>
</dependency>
```
That is a fairly old version. You should upgrade to the latest version
first.
The Tomcat-specific code is in a subproject with only two classes. When
I compile using Maven 3.8.6 and Java 17 using `-Xlint:all`, I see the
following warning for that subproject:
> [WARNING] Cannot find annotation method 'value()' in type
> 'aQute.bnd.annotation.spi.ServiceConsumer':
> class file for aQute.bnd.annotation.spi.ServiceConsumer not found
That is only a warning. The annotation isn't used at run time. You can
safely ignore the warning.
As mentioned this only seems to happen with -`Xlint:all` turned on for
`javac`:
That is as expected.
<snip/>
Doing a bit of searching brings up similar (but not exact) things, such
as [Lombok Issue
#2145](https://github.com/projectlombok/lombok/issues/2145), which hints
that I may need to add some sort of extra dependency such as
`biz.aQute.bnd:bndlib` or `org.osgi:osgi.annotation`.
But I've tried this and and I still get the warning:
```xml
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bndlib</artifactId>
<version>2.4.0</version>
</dependency>
```
I also tried this; no difference:
```xml
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
<version>7.0.0</version>
</dependency>
```
If you want to fix the warning, those are not the correct dependencies.
If you want the exact dependencies used with 9.0.50 then you can find
them from the source code:
Github project:
https://github.com/apache/tomcat
9.0.50 tag:
https://github.com/apache/tomcat/tree/9.0.50
Default build properties:
https://github.com/apache/tomcat/blob/9.0.50/build.properties.default
You want
bnd (not bndlib) 5.3.0
OSGi annotations 1.1.0
If you use the latest version of bnd you won't need the OSGi annotation
dependency.
I also [asked on Stack Overflow](https://stackoverflow.com/q/74000505).
No answers so far.
I filed [Bug
66299](https://bz.apache.org/bugzilla/show_bug.cgi?id=66299] because I
imagine that the Tomcat artifact isn't including some necessary
dependency. That bug got closed because I'm supposed to ask here on this
list first; nevertheless, including a Tomcat artifact should not result
a warning regarding some other dependency I've never heard of and didn't
refer to, so in any case this is incorrect behavior, and needs to be fixed.
No, this is not incorrect behaviour and it does not need to be fixed.
Still I'd like to find out what's going on—maybe I can help you fix it.
There is nothing to fix.
Where is this error coming from, and what does it mean?
It means that the compiler has found a reference to a annotation that it
can't resolve. Normally, it would just ignore it but because Xlint:all
is configured then a warning is issued.
I don't have any
`@ServiceConsumer` annotation in my source code, and I couldn't find any
in the Tomcat classes I'm extending, either.
It is present in org.apache.juli.logging.LogFactory which is likely one
of the classes your source code indirectly depends on since nearly all
Tomcat classes reference it.
Shouldn't the
`org.apache.tomcat.embed:tomcat-embed-core` dependency contain
everything I need (either in the artifact or via a transitive
dependency) just to build a project that references the Tomcat classes?
That JAR does contain everythign you need. Nothing is stopping you
building against the Tomcat embedded JAR. Neither will you see any
runtime errors.
What is missing here?
Nothing.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org