You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by alain hubert <al...@gmail.com> on 2021/09/08 18:26:30 UTC

building Tomcat with a third-party library

Hello,

my colleagues just gave me a challenge before I can retire but the problem
is I haven't done anything else than Email/Excel for years, being an
old-school manager. Please be indulgent.

It took hours before I could find the Tomcat source, unzip it, and much
more to understand the magics with ANT which needs Java to run (I was
ashamed to learn that but the Tomcat documentation is well written, thanks).

Here I am blocked, I need to implement a very simple Authenticator relying
on a proprietary Java library.
When adding the import lines for importing this proprietary package, it's
not possible to compile anymore. I get the following errors. From what I
understand, building Tomcat with an additional library would need to add it
somewhere but I was not able to find this in the documentation. Does anyone
have an idea ?

thanks for reading
A.Hubert.

compile:
    [javac] Compiling 1 source file to
/home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/output/classes
    [javac]
/home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:19:
error: package com.exane.authentification does not exist
    [javac] import static com.exane.authentification.Authent.*;
    [javac]                            ^
    [javac]
/home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:20:
error: package com.exane.authentification does not exist
    [javac] import static com.exane.authentification.Verif.*;
    [javac]                            ^
    [javac]
/home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:22:
error: package com.exane.authentification does not exist
    [javac] import com.exane.authentification.*;
    [javac] ^
    [javac] 3 errors

BUILD FAILED
/home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/build.xml:973:
Compile failed; see the compiler error output for details.

Re: building Tomcat with a third-party library

Posted by alain hubert <al...@gmail.com>.
I have tested both methods, and both are working. Thanks a lot for your
help.

Le jeu. 9 sept. 2021 à 10:21, Martin Grigorov <mg...@apache.org> a
écrit :

> On Wed, Sep 8, 2021 at 11:34 PM Christopher Schultz <
> chris@christopherschultz.net> wrote:
>
> > Alain,
> >
> > On 9/8/21 14:26, alain hubert wrote:
> > > Hello,
> > >
> > > my colleagues just gave me a challenge before I can retire but the
> > problem
> > > is I haven't done anything else than Email/Excel for years, being an
> > > old-school manager. Please be indulgent.
> > >
> > > It took hours before I could find the Tomcat source, unzip it, and much
> > > more to understand the magics with ANT which needs Java to run (I was
> > > ashamed to learn that but the Tomcat documentation is well written,
> > thanks).
> > >
> > > Here I am blocked, I need to implement a very simple Authenticator
> > relying
> > > on a proprietary Java library.
> > > When adding the import lines for importing this proprietary package,
> it's
> > > not possible to compile anymore.
> >
> > How important is it to build Tomcat *with* your custom library? What if,
> > instead, you compiled your library separately and used Tomcat as a
> > (previously-built) dependency?
> >
>
> As Chris suggested you could use Tomcat's jars as dependencies to build
> your own library.
> See https://search.maven.org/artifact/org.apache.tomcat/tomcat-catalina
> Then put your-library.jar either in yourApp.war#lib or in
> $CATALINA_BASE/lib and configure your Authenticator in
> yourApp.war#META-INF/context.xml or
> $CATALINA_HOME/conf/context.xml/server.xml
> See https://tomcat.apache.org/tomcat-9.0-doc/security-howto.html and
> https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Authentication
>
>
>
> >
> > > I get the following errors. From what I understand, building Tomcat
> > > with an additional library would need to add it somewhere but I was
> > > not able to find this in the documentation. Does anyone have an
> > > idea? >
> > > thanks for reading
> > > A.Hubert.
> > >
> > > compile:
> > >      [javac] Compiling 1 source file to
> > > /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/output/classes
> > >      [javac]
> > >
> >
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:19:
> > > error: package com.exane.authentification does not exist
> > >      [javac] import static com.exane.authentification.Authent.*;
> > >      [javac]                            ^
> > >      [javac]
> > >
> >
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:20:
> > > error: package com.exane.authentification does not exist
> > >      [javac] import static com.exane.authentification.Verif.*;
> > >      [javac]                            ^
> > >      [javac]
> > >
> >
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:22:
> > > error: package com.exane.authentification does not exist
> > >      [javac] import com.exane.authentification.*;
> > >      [javac] ^
> > >      [javac] 3 errors
> > >
> > > BUILD FAILED
> > > /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/build.xml:973:
> > > Compile failed; see the compiler error output for details.
> >
> > Where are the source files for com.exane.* to be found?
> >
>
> If you decide to modify Tomcat's sources directly then you should add your
> library to the build classpath.
> See
>
> https://github.com/apache/tomcat/blob/386912a93f130078f52e7094be3a730cda742121/build.xml#L214-L221
> The sources of com.exane.* are not really needed. You need the classes,
> i.e. the jar.
>
> Martin
>
>
> >
> > -chris
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: dev-help@tomcat.apache.org
> >
> >
>

Re: building Tomcat with a third-party library

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Sep 8, 2021 at 11:34 PM Christopher Schultz <
chris@christopherschultz.net> wrote:

> Alain,
>
> On 9/8/21 14:26, alain hubert wrote:
> > Hello,
> >
> > my colleagues just gave me a challenge before I can retire but the
> problem
> > is I haven't done anything else than Email/Excel for years, being an
> > old-school manager. Please be indulgent.
> >
> > It took hours before I could find the Tomcat source, unzip it, and much
> > more to understand the magics with ANT which needs Java to run (I was
> > ashamed to learn that but the Tomcat documentation is well written,
> thanks).
> >
> > Here I am blocked, I need to implement a very simple Authenticator
> relying
> > on a proprietary Java library.
> > When adding the import lines for importing this proprietary package, it's
> > not possible to compile anymore.
>
> How important is it to build Tomcat *with* your custom library? What if,
> instead, you compiled your library separately and used Tomcat as a
> (previously-built) dependency?
>

As Chris suggested you could use Tomcat's jars as dependencies to build
your own library.
See https://search.maven.org/artifact/org.apache.tomcat/tomcat-catalina
Then put your-library.jar either in yourApp.war#lib or in
$CATALINA_BASE/lib and configure your Authenticator in
yourApp.war#META-INF/context.xml or
$CATALINA_HOME/conf/context.xml/server.xml
See https://tomcat.apache.org/tomcat-9.0-doc/security-howto.html and
https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Authentication



>
> > I get the following errors. From what I understand, building Tomcat
> > with an additional library would need to add it somewhere but I was
> > not able to find this in the documentation. Does anyone have an
> > idea? >
> > thanks for reading
> > A.Hubert.
> >
> > compile:
> >      [javac] Compiling 1 source file to
> > /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/output/classes
> >      [javac]
> >
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:19:
> > error: package com.exane.authentification does not exist
> >      [javac] import static com.exane.authentification.Authent.*;
> >      [javac]                            ^
> >      [javac]
> >
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:20:
> > error: package com.exane.authentification does not exist
> >      [javac] import static com.exane.authentification.Verif.*;
> >      [javac]                            ^
> >      [javac]
> >
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:22:
> > error: package com.exane.authentification does not exist
> >      [javac] import com.exane.authentification.*;
> >      [javac] ^
> >      [javac] 3 errors
> >
> > BUILD FAILED
> > /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/build.xml:973:
> > Compile failed; see the compiler error output for details.
>
> Where are the source files for com.exane.* to be found?
>

If you decide to modify Tomcat's sources directly then you should add your
library to the build classpath.
See
https://github.com/apache/tomcat/blob/386912a93f130078f52e7094be3a730cda742121/build.xml#L214-L221
The sources of com.exane.* are not really needed. You need the classes,
i.e. the jar.

Martin


>
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: building Tomcat with a third-party library

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Alain,

On 9/8/21 14:26, alain hubert wrote:
> Hello,
> 
> my colleagues just gave me a challenge before I can retire but the problem
> is I haven't done anything else than Email/Excel for years, being an
> old-school manager. Please be indulgent.
> 
> It took hours before I could find the Tomcat source, unzip it, and much
> more to understand the magics with ANT which needs Java to run (I was
> ashamed to learn that but the Tomcat documentation is well written, thanks).
> 
> Here I am blocked, I need to implement a very simple Authenticator relying
> on a proprietary Java library.
> When adding the import lines for importing this proprietary package, it's
> not possible to compile anymore.

How important is it to build Tomcat *with* your custom library? What if, 
instead, you compiled your library separately and used Tomcat as a 
(previously-built) dependency?

> I get the following errors. From what I understand, building Tomcat 
> with an additional library would need to add it somewhere but I was 
> not able to find this in the documentation. Does anyone have an
> idea? >
> thanks for reading
> A.Hubert.
> 
> compile:
>      [javac] Compiling 1 source file to
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/output/classes
>      [javac]
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:19:
> error: package com.exane.authentification does not exist
>      [javac] import static com.exane.authentification.Authent.*;
>      [javac]                            ^
>      [javac]
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:20:
> error: package com.exane.authentification does not exist
>      [javac] import static com.exane.authentification.Verif.*;
>      [javac]                            ^
>      [javac]
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/java/org/apache/catalina/authenticator/BasicAuthenticatorToto.java:22:
> error: package com.exane.authentification does not exist
>      [javac] import com.exane.authentification.*;
>      [javac] ^
>      [javac] 3 errors
> 
> BUILD FAILED
> /home/ahubert/tests/tomcat-src/apache-tomcat-9.0.52-src/build.xml:973:
> Compile failed; see the compiler error output for details.

Where are the source files for com.exane.* to be found?

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org