Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSGI can't use Logger #20039

Closed
wezell opened this issue Mar 5, 2021 · 4 comments · Fixed by #20048
Closed

OSGI can't use Logger #20039

wezell opened this issue Mar 5, 2021 · 4 comments · Fixed by #20048

Comments

@wezell
Copy link
Contributor

wezell commented Mar 5, 2021

If you register an OSGI plugin, and in that use the dotCMS class Logger it will log output - but only the first time it is loaded. If you then undeploy the plugin and then redeploy it, logging will no longer work. This is because we are using the class as a key for the map of loggers and the original class that registered the logger is no longer available in the classpath and throws an error when the clazz.getName is called.

We need to use Strings as the keys to the logger map. This will make it more resilient to class loading issues.

@wezell wezell changed the title OSGI can't use loggers OSGI can't use Logger Mar 5, 2021
wezell added a commit that referenced this issue Mar 5, 2021
wezell added a commit that referenced this issue Mar 5, 2021
wezell added a commit that referenced this issue Mar 5, 2021
dsilvam pushed a commit that referenced this issue Mar 10, 2021
* #20039 fix osgi logging

* #20039 fix osgi logging

* #20039 printing when a logger is removed
@dsilvam dsilvam linked a pull request Mar 10, 2021 that will close this issue
@dsilvam dsilvam added this to the Maintenance Sprint milestone Mar 10, 2021
@wezell
Copy link
Contributor Author

wezell commented Mar 10, 2021

Tested with the Cronjob example plugin

@dsilvam
Copy link
Contributor

dsilvam commented Mar 11, 2021

Passed Internal QA: Job plugin still logging after redeployment.

@victoralfaro-dotcms
Copy link
Contributor

victoralfaro-dotcms commented Mar 12, 2021

Uploaded and started

10:22:59.439  INFO  job.Activator - Injecting: com.dotmarketing.osgi.job.CustomJob into classloader: ParallelWebappClassLoader
  context: ROOT
  delegate: true
----------> Parent Classloader:
java.net.URLClassLoader@685cb137

10:23:00.025  INFO  job.FreeServerFromClusterJob - Server 56cd63a2-86b1-4ca0-98ba-8d8c2d88fe4b with license null was Removed
10:23:00.077  INFO  cluster.ClusterFactory - Cluster topography has changed. This might force a rewire
10:23:00.077  INFO  cluster.ClusterFactory - Expecting Servers:[]
10:23:00.077  INFO  cluster.ClusterFactory - Found Servers:[]
10:23:00.077  INFO  cluster.ClusterFactory - Cluster Active. Rewiring
10:23:00.858  INFO  job.Activator - Injecting: com.dotmarketing.osgi.job.TestClass into classloader: ParallelWebappClassLoader
  context: ROOT
  delegate: true
----------> Parent Classloader:
java.net.URLClassLoader@685cb137

10:23:00.890  INFO  job.Activator - Injecting: com.dotmarketing.osgi.job.CustomJob into classloader: ParallelWebappClassLoader
  context: ROOT
  delegate: true
----------> Parent Classloader:
java.net.URLClassLoader@685cb137

10:23:01.395  INFO  job.Activator - Added Quartz Job: Custom Job
Started bundle: file:/Users/victoralfaro/dev/dotcms/tomcat9/webapps/ROOT/WEB-INF/felix/load/com.dotcms.job-0.2.jar
10:23:01.407  INFO  job.CustomJob - ------------------------------------------
10:23:01.407  INFO  job.CustomJob - Start custom job
10:23:01.407  INFO  job.CustomJob -
10:23:01.407  INFO  job.CustomJob - param1: value1
10:23:01.407  INFO  job.CustomJob - param2: value2
10:23:01.407  INFO  job.CustomJob -
10:23:01.407  INFO  job.TestClass - Printing from TestClass.printA
10:23:01.407  INFO  job.TestClass - Printing from TestClass.printB
10:23:01.407  INFO  job.CustomJob -
10:23:01.407  INFO  job.CustomJob - Finish custom job (osgi version).
10:23:01.407  INFO  job.CustomJob - ------------------------------------------

Stopped and undeployed

10:27:50.034  INFO  job.CustomJob - Finish custom job (osgi version).
10:27:50.034  INFO  job.CustomJob - ------------------------------------------
10:27:54.576  INFO  job.Activator - Removing: com.dotmarketing.osgi.job.CustomJob from classloader: ParallelWebappClassLoader
  context: ROOT
  delegate: true
----------> Parent Classloader:
java.net.URLClassLoader@685cb137

10:27:54.639  INFO  job.Activator - Removing: com.dotmarketing.osgi.job.TestClass from classloader: ParallelWebappClassLoader
  context: ROOT
  delegate: true
----------> Parent Classloader:
java.net.URLClassLoader@685cb137

10:27:54.721  INFO  AJAX.OSGIAJAX - OSGI Bundle com.dotcms.job-0.2.jar Stopped
10:27:54.724  INFO  AJAX.OSGIAJAX - Portlets Removed: []
10:27:54.724  INFO  AJAX.OSGIAJAX - Actionlets Removed: []
10:28:00.063  INFO  job.FreeServerFromClusterJob - Server 56cd63a2-86b1-4ca0-98ba-8d8c2d88fe4b with license null was Removed
10:28:36.959  INFO  AJAX.OSGIAJAX - OSGI Bundle com.dotcms.job-0.2.jar Undeployed
10:28:36.959  INFO  AJAX.OSGIAJAX - Portlets Removed: []
10:28:36.959  INFO  AJAX.OSGIAJAX - Actionlets Removed: []
Failed to uninstall bundle: /Users/victoralfaro/dev/dotcms/tomcat9/webapps/ROOT/WEB-INF/felix/load/com.dotcms.job-0.2.jar with id: 15. The bundle has already been uninstalled
10:28:45.723  INFO  cluster.ClusterFactory - Cluster topography has changed. This might force a rewire
10:28:45.723  INFO  cluster.ClusterFactory - Expecting Servers:[]
10:28:45.723  INFO  cluster.ClusterFactory - Found Servers:[]
10:28:45.723  INFO  cluster.ClusterFactory - Cluster Active. Rewiring
10:28:50.648  INFO  AJAX.OSGIAJAX - OSGI Bundle com.dotcms.job.fragment-0.2.jar Undeployed
10:28:50.648  INFO  AJAX.OSGIAJAX - Portlets Removed: []
10:28:50.648  INFO  AJAX.OSGIAJAX - Actionlets Removed: []
Failed to uninstall bundle: /Users/victoralfaro/dev/dotcms/tomcat9/webapps/ROOT/WEB-INF/felix/load/com.dotcms.job.fragment-0.2.jar with id: 14. The bundle has already been uninstalled
10:29:00.042  INFO  job.FreeServerFromClusterJob - Server 56cd63a2-86b1-4ca0-98ba-8d8c2d88fe4b with license null was Removed

Started again

Started bundle: file:/Users/victoralfaro/dev/dotcms/tomcat9/webapps/ROOT/WEB-INF/felix/load/com.dotcms.job-0.2.jar
10:30:11.643  INFO  job.Activator - Added Quartz Job: Custom Job
10:30:20.012  INFO  job.CustomJob - ------------------------------------------
10:30:20.012  INFO  job.CustomJob - Start custom job
10:30:20.012  INFO  job.CustomJob -
10:30:20.012  INFO  job.CustomJob - param1: value1
10:30:20.012  INFO  job.CustomJob - param2: value2
10:30:20.012  INFO  job.CustomJob -
10:30:20.012  INFO  job.TestClass - Printing from TestClass.printA
10:30:20.012  INFO  job.TestClass - Printing from TestClass.printB
10:30:20.012  INFO  job.CustomJob -
10:30:20.012  INFO  job.CustomJob - Finish custom job (osgi version).
10:30:20.012  INFO  job.CustomJob - ------------------------------------------
10:30:30.023  INFO  job.CustomJob - ------------------------------------------
10:30:30.023  INFO  job.CustomJob - Start custom job
10:30:30.023  INFO  job.CustomJob -
10:30:30.023  INFO  job.CustomJob - param1: value1
10:30:30.023  INFO  job.CustomJob - param2: value2
10:30:30.023  INFO  job.CustomJob -
10:30:30.023  INFO  job.TestClass - Printing from TestClass.printA
10:30:30.023  INFO  job.TestClass - Printing from TestClass.printB
10:30:30.023  INFO  job.CustomJob -
10:30:30.023  INFO  job.CustomJob - Finish custom job (osgi version).
10:30:30.023  INFO  job.CustomJob - ------------------------------------------

@bryanboza
Copy link
Member

Fixed, tested on release-21.04 // Postgres

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants