Re: ClassNotFoundException listeners.ContextListener in IDE

2024-01-06 Thread Igal Sapir
Mark,

On Sat, Dec 30, 2023 at 5:20 AM Mark Thomas  wrote:

> On 25/12/2023 04:12, Igal Sapir wrote:
> > Any thoughts why I get ClassNotFoundException: listeners.ContextListener
> > (and other listeners) when I run Tomcat in an IDE (IntelliJ IDEA)?
>
> It looks like the docBase is set to the source dir for the webapps. That
> probably means there aren't any compiled classes present hence you get
> the CNFE.
>
> At a guess, I'd try adding the WEB-INF/classes directories as additional
> source locations. That should result in the resulting class files being
> included in the common class loader. It isn't exactly how Tomcat would
> be configured if running outside of the IDE but results should be the same.
>

It seems to be the same issue that I faced several years back, where I try
to run the code in the source directory whereas I should be running it from
the build directory?  Good thing we have the mailing list [1].

The solution was to run `ant` to build Tomcat, and then open Run/Debug
Configurations, and set set the Working Directory to the output directory
of ant, e.g. `output/build` in default settings.


> Personally, I haven't tried running Tomcat in an IDE for years. I always
> run Tomcat from the command line and then use remote debugging. It takes
> a little bit of setting up, but once configured I found it a lot easier
> to work with.
>

The issue I have with that is that each change requires a build which is
time consuming.  The way I have it set up I can make a change and restart
my debugging session immediately.

I hope to make a tutorial about the setup sometime which will make it easy
for others to configure as well.


>
> YMMV.
>

Thank you,

Igal

[1] https://lists.apache.org/thread/rvsl5h5lksdxjtvp63opbn5wsmpcflwk



>
> Mark
>
> >
> > SEVERE: Error configuring application listener of class
> > [listeners.ContextListener]
> > java.lang.ClassNotFoundException: listeners.ContextListener
> >
> >
> > Then when I try to make a request
> > jakarta.servlet.jsp.JspFactory.getDefaultFactory() returns null and
> throws
> > another exception (can be seen at the end of the console output)
> >
> > Here is the console output:
> >
> > /opt/java/jdk-22-ea+29/bin/java
> > -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46023
> ,suspend=y,server=n
> > --enable-preview
> >
> -javaagent:/opt/jetbrains/idea-IC-233.13135.103/plugins/java/lib/rt/debugger-agent.jar
> > -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8
> > -Dsun.stderr.encoding=UTF-8 -classpath
> >
> /workspace/src/tomcat/main/.idea/output/production/tomcat:/opt/java/apache-ant-1.10.8/lib/ant.jar:/workspace/build/tomcat-build-libs/junit-4.13.2/junit-4.13.2.jar:/workspace/build/tomcat-build-libs/ecj-4.29/ecj-4.29.jar:/workspace/build/tomcat-build-libs/easymock-4.3/easymock-4.3.jar:/workspace/build/tomcat-build-libs/hamcrest-2.2/hamcrest-2.2.jar:/workspace/build/tomcat-build-libs/cglib-3.3.0/cglib-nodep-3.3.0.jar:/workspace/build/tomcat-build-libs/objenesis-3.3/objenesis-3.3.jar:/workspace/build/tomcat-build-libs/bnd-7.0.0/biz.aQute.bnd-7.0.0.jar:/workspace/build/tomcat-build-libs/migration-1.0.7/jakartaee-migration-1.0.7-shaded.jar:/workspace/build/tomcat-build-libs/unboundid-6.0.11/unboundid-ldapsdk-6.0.11.jar:/workspace/src/tomcat/main/lib/jmh-core-1.36.jar:/workspace/src/tomcat/main/lib/jopt-simple-5.0.4.jar:/workspace/src/tomcat/main/lib/commons-math3-3.6.1.jar:/workspace/src/tomcat/main/lib/jmh-generator-annprocess-1.36.jar:/opt/jetbrains/idea-IC-233.13135.103/lib/idea_rt.jar
> > org.apache.catalina.startup.Bootstrap
> > Connected to the target VM, address: '127.0.0.1:46023', transport:
> 'socket'
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Server version name:   Apache Tomcat/11.0.x-dev
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Server built:  unknown
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Server version number: 11.0.x
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: OS Name:   Linux
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: OS Version:6.2.0-39-generic
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Architecture:  amd64
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Java Home: /opt/java/jdk-22-ea+29
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: JVM Version:   22-ea+29-2286
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: JVM Vendor:Oracle Corporation
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: CATALINA_BASE: /workspace/src/tomcat/main
> > Dec 24, 2023 8:04:24 PM
> org.apache.cat

Re: ClassNotFoundException listeners.ContextListener in IDE

2023-12-31 Thread koteswara Rao Gundapaneni
>
> Hi Mark,
>
>
> Please find my query to start with working without IDE
>
>
>
> On Sat, 30 Dec 2023, 18:50 Mark Thomas,  wrote:
>
>> On 25/12/2023 04:12, Igal Sapir wrote:
>> > Any thoughts why I get ClassNotFoundException: listeners.ContextListener
>> > (and other listeners) when I run Tomcat in an IDE (IntelliJ IDEA)?
>>
>> It looks like the docBase is set to the source dir for the webapps. That
>> probably means there aren't any compiled classes present hence you get
>> the CNFE.
>>
>> At a guess, I'd try adding the WEB-INF/classes directories as additional
>> source locations. That should result in the resulting class files being
>> included in the common class loader. It isn't exactly how Tomcat would
>> be configured if running outside of the IDE but results should be the
>> same.
>>
>> Personally, I haven't tried running Tomcat in an IDE for years. I always
>> run Tomcat from the command line and then use remote debugging. It takes
>> a little bit of setting up, but once configured I found it a lot easier
>> to work with.
>>
>
>
> I have small query regarding to run without IDE
>
> Whether it like catalina.bat jpda start and then use remote debugging  ?
>
>
>
>
> Regards
> Koti
>
>
>
>
>> YMMV.
>>
>> Mark
>>
>> >
>> > SEVERE: Error configuring application listener of class
>> > [listeners.ContextListener]
>> > java.lang.ClassNotFoundException: listeners.ContextListener
>> >
>> >
>> > Then when I try to make a request
>> > jakarta.servlet.jsp.JspFactory.getDefaultFactory() returns null and
>> throws
>> > another exception (can be seen at the end of the console output)
>> >
>> > Here is the console output:
>> >
>> > /opt/java/jdk-22-ea+29/bin/java
>> > -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46023
>> ,suspend=y,server=n
>> > --enable-preview
>> >
>> -javaagent:/opt/jetbrains/idea-IC-233.13135.103/plugins/java/lib/rt/debugger-agent.jar
>> > -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8
>> > -Dsun.stderr.encoding=UTF-8 -classpath
>> >
>> /workspace/src/tomcat/main/.idea/output/production/tomcat:/opt/java/apache-ant-1.10.8/lib/ant.jar:/workspace/build/tomcat-build-libs/junit-4.13.2/junit-4.13.2.jar:/workspace/build/tomcat-build-libs/ecj-4.29/ecj-4.29.jar:/workspace/build/tomcat-build-libs/easymock-4.3/easymock-4.3.jar:/workspace/build/tomcat-build-libs/hamcrest-2.2/hamcrest-2.2.jar:/workspace/build/tomcat-build-libs/cglib-3.3.0/cglib-nodep-3.3.0.jar:/workspace/build/tomcat-build-libs/objenesis-3.3/objenesis-3.3.jar:/workspace/build/tomcat-build-libs/bnd-7.0.0/biz.aQute.bnd-7.0.0.jar:/workspace/build/tomcat-build-libs/migration-1.0.7/jakartaee-migration-1.0.7-shaded.jar:/workspace/build/tomcat-build-libs/unboundid-6.0.11/unboundid-ldapsdk-6.0.11.jar:/workspace/src/tomcat/main/lib/jmh-core-1.36.jar:/workspace/src/tomcat/main/lib/jopt-simple-5.0.4.jar:/workspace/src/tomcat/main/lib/commons-math3-3.6.1.jar:/workspace/src/tomcat/main/lib/jmh-generator-annprocess-1.36.jar:/opt/jetbrains/idea-IC-233.13135.103/lib/idea_rt.jar
>> > org.apache.catalina.startup.Bootstrap
>> > Connected to the target VM, address: '127.0.0.1:46023', transport:
>> 'socket'
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: Server version name:   Apache Tomcat/11.0.x-dev
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: Server built:  unknown
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: Server version number: 11.0.x
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: OS Name:   Linux
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: OS Version:6.2.0-39-generic
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: Architecture:  amd64
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: Java Home: /opt/java/jdk-22-ea+29
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: JVM Version:   22-ea+29-2286
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: JVM Vendor:Oracle Corporation
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: CATALINA_BASE: /workspace/src/tomcat/main
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: CATALINA_HOME: /workspace/src/tomcat/main
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: Command line argument:
>> > -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46023
>> ,suspend=y,server=n
>> > Dec 24, 2023 8:04:24 PM
>> org.apache.catalina.startup.VersionLoggerListener log
>> > INFO: Command line argument: --enable-preview
>> > Dec 24, 2023 8:04:24 PM
>> org.

Re: ClassNotFoundException listeners.ContextListener in IDE

2023-12-30 Thread koteswara Rao Gundapaneni
Hi Mark,


Please find my query to start with



On Sat, 30 Dec 2023, 18:50 Mark Thomas,  wrote:

> On 25/12/2023 04:12, Igal Sapir wrote:
> > Any thoughts why I get ClassNotFoundException: listeners.ContextListener
> > (and other listeners) when I run Tomcat in an IDE (IntelliJ IDEA)?
>
> It looks like the docBase is set to the source dir for the webapps. That
> probably means there aren't any compiled classes present hence you get
> the CNFE.
>
> At a guess, I'd try adding the WEB-INF/classes directories as additional
> source locations. That should result in the resulting class files being
> included in the common class loader. It isn't exactly how Tomcat would
> be configured if running outside of the IDE but results should be the same.
>
> Personally, I haven't tried running Tomcat in an IDE for years. I always
> run Tomcat from the command line and then use remote debugging. It takes
> a little bit of setting up, but once configured I found it a lot easier
> to work with.
>


I have small query regarding to run without IDE

Whether it like catalina.bat jpda start and then use remote debugging

Is it  ???


Regards
Koti




> YMMV.
>
> Mark
>
> >
> > SEVERE: Error configuring application listener of class
> > [listeners.ContextListener]
> > java.lang.ClassNotFoundException: listeners.ContextListener
> >
> >
> > Then when I try to make a request
> > jakarta.servlet.jsp.JspFactory.getDefaultFactory() returns null and
> throws
> > another exception (can be seen at the end of the console output)
> >
> > Here is the console output:
> >
> > /opt/java/jdk-22-ea+29/bin/java
> > -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46023
> ,suspend=y,server=n
> > --enable-preview
> >
> -javaagent:/opt/jetbrains/idea-IC-233.13135.103/plugins/java/lib/rt/debugger-agent.jar
> > -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8
> > -Dsun.stderr.encoding=UTF-8 -classpath
> >
> /workspace/src/tomcat/main/.idea/output/production/tomcat:/opt/java/apache-ant-1.10.8/lib/ant.jar:/workspace/build/tomcat-build-libs/junit-4.13.2/junit-4.13.2.jar:/workspace/build/tomcat-build-libs/ecj-4.29/ecj-4.29.jar:/workspace/build/tomcat-build-libs/easymock-4.3/easymock-4.3.jar:/workspace/build/tomcat-build-libs/hamcrest-2.2/hamcrest-2.2.jar:/workspace/build/tomcat-build-libs/cglib-3.3.0/cglib-nodep-3.3.0.jar:/workspace/build/tomcat-build-libs/objenesis-3.3/objenesis-3.3.jar:/workspace/build/tomcat-build-libs/bnd-7.0.0/biz.aQute.bnd-7.0.0.jar:/workspace/build/tomcat-build-libs/migration-1.0.7/jakartaee-migration-1.0.7-shaded.jar:/workspace/build/tomcat-build-libs/unboundid-6.0.11/unboundid-ldapsdk-6.0.11.jar:/workspace/src/tomcat/main/lib/jmh-core-1.36.jar:/workspace/src/tomcat/main/lib/jopt-simple-5.0.4.jar:/workspace/src/tomcat/main/lib/commons-math3-3.6.1.jar:/workspace/src/tomcat/main/lib/jmh-generator-annprocess-1.36.jar:/opt/jetbrains/idea-IC-233.13135.103/lib/idea_rt.jar
> > org.apache.catalina.startup.Bootstrap
> > Connected to the target VM, address: '127.0.0.1:46023', transport:
> 'socket'
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Server version name:   Apache Tomcat/11.0.x-dev
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Server built:  unknown
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Server version number: 11.0.x
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: OS Name:   Linux
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: OS Version:6.2.0-39-generic
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Architecture:  amd64
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Java Home: /opt/java/jdk-22-ea+29
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: JVM Version:   22-ea+29-2286
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: JVM Vendor:Oracle Corporation
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: CATALINA_BASE: /workspace/src/tomcat/main
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: CATALINA_HOME: /workspace/src/tomcat/main
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Command line argument:
> > -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46023
> ,suspend=y,server=n
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Command line argument: --enable-preview
> > Dec 24, 2023 8:04:24 PM
> org.apache.catalina.startup.VersionLoggerListener log
> > INFO: Command line argument:
> >
> -javaagent:/opt/jetbrains/idea-IC-233.13135.103/plu

Re: ClassNotFoundException listeners.ContextListener in IDE

2023-12-30 Thread Mark Thomas

On 25/12/2023 04:12, Igal Sapir wrote:

Any thoughts why I get ClassNotFoundException: listeners.ContextListener
(and other listeners) when I run Tomcat in an IDE (IntelliJ IDEA)?


It looks like the docBase is set to the source dir for the webapps. That 
probably means there aren't any compiled classes present hence you get 
the CNFE.


At a guess, I'd try adding the WEB-INF/classes directories as additional 
source locations. That should result in the resulting class files being 
included in the common class loader. It isn't exactly how Tomcat would 
be configured if running outside of the IDE but results should be the same.


Personally, I haven't tried running Tomcat in an IDE for years. I always 
run Tomcat from the command line and then use remote debugging. It takes 
a little bit of setting up, but once configured I found it a lot easier 
to work with.


YMMV.

Mark



SEVERE: Error configuring application listener of class
[listeners.ContextListener]
java.lang.ClassNotFoundException: listeners.ContextListener


Then when I try to make a request
jakarta.servlet.jsp.JspFactory.getDefaultFactory() returns null and throws
another exception (can be seen at the end of the console output)

Here is the console output:

/opt/java/jdk-22-ea+29/bin/java
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46023,suspend=y,server=n
--enable-preview
-javaagent:/opt/jetbrains/idea-IC-233.13135.103/plugins/java/lib/rt/debugger-agent.jar
-Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8
-Dsun.stderr.encoding=UTF-8 -classpath
/workspace/src/tomcat/main/.idea/output/production/tomcat:/opt/java/apache-ant-1.10.8/lib/ant.jar:/workspace/build/tomcat-build-libs/junit-4.13.2/junit-4.13.2.jar:/workspace/build/tomcat-build-libs/ecj-4.29/ecj-4.29.jar:/workspace/build/tomcat-build-libs/easymock-4.3/easymock-4.3.jar:/workspace/build/tomcat-build-libs/hamcrest-2.2/hamcrest-2.2.jar:/workspace/build/tomcat-build-libs/cglib-3.3.0/cglib-nodep-3.3.0.jar:/workspace/build/tomcat-build-libs/objenesis-3.3/objenesis-3.3.jar:/workspace/build/tomcat-build-libs/bnd-7.0.0/biz.aQute.bnd-7.0.0.jar:/workspace/build/tomcat-build-libs/migration-1.0.7/jakartaee-migration-1.0.7-shaded.jar:/workspace/build/tomcat-build-libs/unboundid-6.0.11/unboundid-ldapsdk-6.0.11.jar:/workspace/src/tomcat/main/lib/jmh-core-1.36.jar:/workspace/src/tomcat/main/lib/jopt-simple-5.0.4.jar:/workspace/src/tomcat/main/lib/commons-math3-3.6.1.jar:/workspace/src/tomcat/main/lib/jmh-generator-annprocess-1.36.jar:/opt/jetbrains/idea-IC-233.13135.103/lib/idea_rt.jar
org.apache.catalina.startup.Bootstrap
Connected to the target VM, address: '127.0.0.1:46023', transport: 'socket'
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name:   Apache Tomcat/11.0.x-dev
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:  unknown
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 11.0.x
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:   Linux
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:6.2.0-39-generic
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:  amd64
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: /opt/java/jdk-22-ea+29
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:   22-ea+29-2286
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:Oracle Corporation
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /workspace/src/tomcat/main
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /workspace/src/tomcat/main
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument:
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46023,suspend=y,server=n
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: --enable-preview
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument:
-javaagent:/opt/jetbrains/idea-IC-233.13135.103/plugins/java/lib/rt/debugger-agent.jar
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dsun.stdout.encoding=UTF-8
Dec 24, 2023 8:04:24 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dsun.stderr.encoding=UTF-8
Dec 24, 2023 8:04:24 PM org.apache.catalina.core.AprLifecycleListener
lifecycleEvent