Re: Tomcat 9 jar containing @webservlet annotation not loaded if inside tomcat/lib

2021-02-18 Thread aghart...@gmail.com

Hi,

FYI, tomcat 9.0.43 have this problem too.

Best Regards,

Agharta


Il 18/02/21 12:51, aghart...@gmail.com ha scritto:

Hi Mark,

Good questions, my mistake, sorry.

So:

jar file name is testannotation.jar

package is "aaa." (very simple)

Standard vanilla tomcat (.zip) downloaded from ASF site, no package 
manager. Unzipped to my home directory.


org.apache.tomcat.util.scan.StandardJarScanner.level = FINE (enabled 
inside tomcat/conf/logging.properties)


Result:

catalina.2021-02-18.log:18-Feb-2021 12:45:03.703 BUONO [main] 
org.apache.tomcat.util.scan.StandardJarScanner.processURLs Scanning 
JAR [file:/home/agharta/apache-tomcat-9.0.41/lib/testannotation.jar] 
from classpath
catalina.2021-02-18.log:18-Feb-2021 12:45:06.178 BUONO 
[http-nio-8082-exec-1] 
org.apache.tomcat.util.scan.StandardJarScanner.processURLs Scanning 
JAR [file:/home/agharta/apache-tomcat-9.0.41/lib/testannotation.jar] 
from classpath


...no other messages involving testannotation.jar or TestServlet.


Many thanks,

Agharta




Il 18/02/21 12:24, Mark Thomas ha scritto:

On 18/02/2021 10:46, aghart...@gmail.com wrote:

Hi all,

A question, I can't solve that

Tested with Tomcat 9.0.41, java 8 x64, linux (Fedora 32).


I have a standard tomcat web.xml (3.0 or 3.1, no matter).

I have created an external simple servlet with @WebServlet annotation,
and packaged it to a jar file:

Name of the JAR file?

Package the Servlet has been placed in?

Standard Tomcat downloaded from the ASF or one provided by your package
manager?

Have you tried enabling debug logging for
org.apache.tomcat.util.scan.StandardJarScanner ?

Mark




@WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"},
loadOnStartup = 1)
public class TestServlet extends HttpServlet {

 private static final Logger log =
Logger.getLogger(TestServlet.class.getName());

 private static final long serialVersionUID = 1L;

 @Override
 public void init() throws ServletException {
 log.setLevel(Level.ALL);
 log.log(Level.WARNING, "TESTSERVLET INIT");
 super.init();
 }

 @Override
 public void destroy() {
 }

 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
 processRequest(req, resp);
 }

 protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
 throws ServletException, IOException {
 response.setContentType("text/html;charset=UTF-8");
 PrintWriter out = response.getWriter();

 try {
     out.println("");
 out.println("");
 out.println("");
 out.println("Servlet TestServlet");
 out.println("");
 out.println("");
 out.println("Servlet TestServlet at " +
request.getContextPath() + "");

 out.println("");
 out.println("");
 } finally {
 out.close();
 }
 }

}


So, if I copy the .jar file inside WEB-INF/lib folder of destination 
war

project the log message will appears and the servlet is reachable.

But, if I copy the .jar file inside tomcat/lib folder the annotation
won't be processed.


FYI, in tomcat 7 both cases (inside WEB-INF/lib and tomcat/lib) 
works well.



I searched on breaking changes between tomcat 7 and 8/8.5/9 but nope.
Seems related to jarscanner.but no luck!


Because my servlet is in common to all projects I want to put it inside
tomcat/lib folder and share it to all my projects


Somebody can help me?


Many thanks,

Agharta








-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 9 jar containing @webservlet annotation not loaded if inside tomcat/lib

2021-02-18 Thread aghart...@gmail.com

Hi Mark,

Good questions, my mistake, sorry.

So:

jar file name is testannotation.jar

package is "aaa." (very simple)

Standard vanilla tomcat (.zip) downloaded from ASF site, no package 
manager. Unzipped to my home directory.


org.apache.tomcat.util.scan.StandardJarScanner.level = FINE (enabled 
inside tomcat/conf/logging.properties)


Result:

catalina.2021-02-18.log:18-Feb-2021 12:45:03.703 BUONO [main] 
org.apache.tomcat.util.scan.StandardJarScanner.processURLs Scanning JAR 
[file:/home/agharta/apache-tomcat-9.0.41/lib/testannotation.jar] from 
classpath
catalina.2021-02-18.log:18-Feb-2021 12:45:06.178 BUONO 
[http-nio-8082-exec-1] 
org.apache.tomcat.util.scan.StandardJarScanner.processURLs Scanning JAR 
[file:/home/agharta/apache-tomcat-9.0.41/lib/testannotation.jar] from 
classpath


...no other messages involving testannotation.jar or TestServlet.


Many thanks,

Agharta




Il 18/02/21 12:24, Mark Thomas ha scritto:

On 18/02/2021 10:46, aghart...@gmail.com wrote:

Hi all,

A question, I can't solve that

Tested with Tomcat 9.0.41, java 8 x64, linux (Fedora 32).


I have a standard tomcat web.xml (3.0 or 3.1, no matter).

I have created an external simple servlet with @WebServlet annotation,
and packaged it to a jar file:

Name of the JAR file?

Package the Servlet has been placed in?

Standard Tomcat downloaded from the ASF or one provided by your package
manager?

Have you tried enabling debug logging for
org.apache.tomcat.util.scan.StandardJarScanner ?

Mark




@WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"},
loadOnStartup = 1)
public class TestServlet extends HttpServlet {

     private static final Logger log =
Logger.getLogger(TestServlet.class.getName());

     private static final long serialVersionUID = 1L;

     @Override
     public void init() throws ServletException {
     log.setLevel(Level.ALL);
     log.log(Level.WARNING, "TESTSERVLET INIT");
     super.init();
     }

     @Override
     public void destroy() {
     }

     @Override
     protected void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
     processRequest(req, resp);
     }

     protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
     throws ServletException, IOException {
     response.setContentType("text/html;charset=UTF-8");
     PrintWriter out = response.getWriter();

     try {
     out.println("");
     out.println("");
     out.println("");
     out.println("Servlet TestServlet");
     out.println("");
     out.println("");
     out.println("Servlet TestServlet at " +
request.getContextPath() + "");

     out.println("");
     out.println("");
     } finally {
     out.close();
     }
     }

}


So, if I copy the .jar file inside WEB-INF/lib folder of destination war
project the log message will appears and the servlet is reachable.

But, if I copy the .jar file inside tomcat/lib folder the annotation
won't be processed.


FYI, in tomcat 7 both cases (inside WEB-INF/lib and tomcat/lib) works well.


I searched on breaking changes between tomcat 7 and 8/8.5/9 but nope.
Seems related to jarscanner.but no luck!


Because my servlet is in common to all projects I want to put it inside
tomcat/lib folder and share it to all my projects


Somebody can help me?


Many thanks,

Agharta








-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Tomcat 9 jar containing @webservlet annotation not loaded if inside tomcat/lib

2021-02-18 Thread aghart...@gmail.com

Hi all,

A question, I can't solve that

Tested with Tomcat 9.0.41, java 8 x64, linux (Fedora 32).


I have a standard tomcat web.xml (3.0 or 3.1, no matter).

I have created an external simple servlet with @WebServlet annotation, 
and packaged it to a jar file:



@WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"}, loadOnStartup 
= 1)
public class TestServlet extends HttpServlet {

    private static final Logger log = 
Logger.getLogger(TestServlet.class.getName());

    private static final long serialVersionUID = 1L;

    @Override
    public void init() throws ServletException {
    log.setLevel(Level.ALL);
    log.log(Level.WARNING, "TESTSERVLET INIT");
    super.init();
    }

    @Override
    public void destroy() {
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
throws ServletException, IOException {
    processRequest(req, resp);
    }

    protected void processRequest(HttpServletRequest request, 
HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();

    try {
    out.println("");
    out.println("");
    out.println("");
    out.println("Servlet TestServlet");
    out.println("");
    out.println("");
    out.println("Servlet TestServlet at " + request.getContextPath() + 
"");

    out.println("");
    out.println("");
    } finally {
    out.close();
    }
    }

}


So, if I copy the .jar file inside WEB-INF/lib folder of destination war 
project the log message will appears and the servlet is reachable.


But, if I copy the .jar file inside tomcat/lib folder the annotation 
won't be processed.



FYI, in tomcat 7 both cases (inside WEB-INF/lib and tomcat/lib) works well.


I searched on breaking changes between tomcat 7 and 8/8.5/9 but nope. 
Seems related to jarscanner.but no luck!



Because my servlet is in common to all projects I want to put it inside 
tomcat/lib folder and share it to all my projects



Somebody can help me?


Many thanks,

Agharta







Re: Tomcat 9 jar containing @webservlet annotation not loaded if inside tomcat/lib

2021-02-19 Thread aghart...@gmail.com

Hi Mark,

I'm sorry to bother you, do you need more information about that? (see 
email below, my mistake about reply recipient)


Many Thanks,

Agharta




Il 18/02/21 13:09, aghart...@gmail.com ha scritto:

Hi,

FYI, tomcat 9.0.43 have this problem too.

Best Regards,

Agharta


Il 18/02/21 12:51, aghart...@gmail.com ha scritto:

Hi Mark,

Good questions, my mistake, sorry.

So:

jar file name is testannotation.jar

package is "aaa." (very simple)

Standard vanilla tomcat (.zip) downloaded from ASF site, no package 
manager. Unzipped to my home directory.


org.apache.tomcat.util.scan.StandardJarScanner.level = FINE (enabled 
inside tomcat/conf/logging.properties)


Result:

catalina.2021-02-18.log:18-Feb-2021 12:45:03.703 BUONO [main] 
org.apache.tomcat.util.scan.StandardJarScanner.processURLs Scanning 
JAR [file:/home/agharta/apache-tomcat-9.0.41/lib/testannotation.jar] 
from classpath
catalina.2021-02-18.log:18-Feb-2021 12:45:06.178 BUONO 
[http-nio-8082-exec-1] 
org.apache.tomcat.util.scan.StandardJarScanner.processURLs Scanning 
JAR [file:/home/agharta/apache-tomcat-9.0.41/lib/testannotation.jar] 
from classpath


...no other messages involving testannotation.jar or TestServlet.


Many thanks,

Agharta




Il 18/02/21 12:24, Mark Thomas ha scritto:

On 18/02/2021 10:46, aghart...@gmail.com wrote:

Hi all,

A question, I can't solve that

Tested with Tomcat 9.0.41, java 8 x64, linux (Fedora 32).


I have a standard tomcat web.xml (3.0 or 3.1, no matter).

I have created an external simple servlet with @WebServlet annotation,
and packaged it to a jar file:

Name of the JAR file?

Package the Servlet has been placed in?

Standard Tomcat downloaded from the ASF or one provided by your package
manager?

Have you tried enabling debug logging for
org.apache.tomcat.util.scan.StandardJarScanner ?

Mark




@WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"},
loadOnStartup = 1)
public class TestServlet extends HttpServlet {

 private static final Logger log =
Logger.getLogger(TestServlet.class.getName());

 private static final long serialVersionUID = 1L;

 @Override
 public void init() throws ServletException {
 log.setLevel(Level.ALL);
 log.log(Level.WARNING, "TESTSERVLET INIT");
 super.init();
 }

 @Override
 public void destroy() {
 }

 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
 processRequest(req, resp);
 }

 protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
 throws ServletException, IOException {
 response.setContentType("text/html;charset=UTF-8");
 PrintWriter out = response.getWriter();

 try {
     out.println("");
 out.println("");
 out.println("");
 out.println("Servlet TestServlet");
 out.println("");
 out.println("");
 out.println("Servlet TestServlet at " +
request.getContextPath() + "");

 out.println("");
 out.println("");
 } finally {
 out.close();
 }
 }

}


So, if I copy the .jar file inside WEB-INF/lib folder of 
destination war

project the log message will appears and the servlet is reachable.

But, if I copy the .jar file inside tomcat/lib folder the annotation
won't be processed.


FYI, in tomcat 7 both cases (inside WEB-INF/lib and tomcat/lib) 
works well.



I searched on breaking changes between tomcat 7 and 8/8.5/9 but nope.
Seems related to jarscanner.but no luck!


Because my servlet is in common to all projects I want to put it 
inside

tomcat/lib folder and share it to all my projects


Somebody can help me?


Many thanks,

Agharta








-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 9 jar containing @webservlet annotation not loaded if inside tomcat/lib

2021-02-22 Thread aghart...@gmail.com

Hi Mark,

Ok, all clear, thanks.
Since the servlet is used by several projects, I force it to be loaded 
via web.xml


Thanks again,

Agharta


Il 22/02/21 12:02, Mark Thomas ha scritto:

On 19/02/2021 09:45, aghart...@gmail.com wrote:

Hi Mark,

I'm sorry to bother you, do you need more information about that? (see
email below, my mistake about reply recipient)

Please see section 8.1 of the Servlet specification.


In a web application, classes using annotations will have their
annotations processed only if they are located in the WEB-INF/classes
directory, or if they are packaged in a jar file located in WEB-INF/lib
within the application.


The same requirement was present in Servlet 3.0 / Tomcat 7 but not enforced.

Mark




Many Thanks,

Agharta




Il 18/02/21 13:09, aghart...@gmail.com ha scritto:

Hi,

FYI, tomcat 9.0.43 have this problem too.

Best Regards,

Agharta


Il 18/02/21 12:51, aghart...@gmail.com ha scritto:

Hi Mark,

Good questions, my mistake, sorry.

So:

jar file name is testannotation.jar

package is "aaa." (very simple)

Standard vanilla tomcat (.zip) downloaded from ASF site, no package
manager. Unzipped to my home directory.

org.apache.tomcat.util.scan.StandardJarScanner.level = FINE (enabled
inside tomcat/conf/logging.properties)

Result:

catalina.2021-02-18.log:18-Feb-2021 12:45:03.703 BUONO [main]
org.apache.tomcat.util.scan.StandardJarScanner.processURLs Scanning
JAR [file:/home/agharta/apache-tomcat-9.0.41/lib/testannotation.jar]
from classpath
catalina.2021-02-18.log:18-Feb-2021 12:45:06.178 BUONO
[http-nio-8082-exec-1]
org.apache.tomcat.util.scan.StandardJarScanner.processURLs Scanning
JAR [file:/home/agharta/apache-tomcat-9.0.41/lib/testannotation.jar]
from classpath

...no other messages involving testannotation.jar or TestServlet.


Many thanks,

Agharta




Il 18/02/21 12:24, Mark Thomas ha scritto:

On 18/02/2021 10:46, aghart...@gmail.com wrote:

Hi all,

A question, I can't solve that

Tested with Tomcat 9.0.41, java 8 x64, linux (Fedora 32).


I have a standard tomcat web.xml (3.0 or 3.1, no matter).

I have created an external simple servlet with @WebServlet annotation,
and packaged it to a jar file:

Name of the JAR file?

Package the Servlet has been placed in?

Standard Tomcat downloaded from the ASF or one provided by your package
manager?

Have you tried enabling debug logging for
org.apache.tomcat.util.scan.StandardJarScanner ?

Mark



@WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"},
loadOnStartup = 1)
public class TestServlet extends HttpServlet {

  private static final Logger log =
Logger.getLogger(TestServlet.class.getName());

  private static final long serialVersionUID = 1L;

  @Override
  public void init() throws ServletException {
  log.setLevel(Level.ALL);
  log.log(Level.WARNING, "TESTSERVLET INIT");
  super.init();
  }

  @Override
  public void destroy() {
  }

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
  processRequest(req, resp);
  }

  protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
  throws ServletException, IOException {
  response.setContentType("text/html;charset=UTF-8");
  PrintWriter out = response.getWriter();

  try {
      out.println("");
  out.println("");
  out.println("");
  out.println("Servlet TestServlet");
  out.println("");
  out.println("");
  out.println("Servlet TestServlet at " +
request.getContextPath() + "");

  out.println("");
  out.println("");
  } finally {
  out.close();
  }
  }

}


So, if I copy the .jar file inside WEB-INF/lib folder of
destination war
project the log message will appears and the servlet is reachable.

But, if I copy the .jar file inside tomcat/lib folder the annotation
won't be processed.


FYI, in tomcat 7 both cases (inside WEB-INF/lib and tomcat/lib)
works well.


I searched on breaking changes between tomcat 7 and 8/8.5/9 but nope.
Seems related to jarscanner.but no luck!


Because my servlet is in common to all projects I want to put it
inside
tomcat/lib folder and share it to all my projects


Somebody can help me?


Many thanks,

Agharta







-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



---