This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 333160 - JMX: ModuleName string extraction code does not handle -1 not found index in 3 of 5 cases
Summary: JMX: ModuleName string extraction code does not handle -1 not found index in ...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: http://wiki.eclipse.org/EclipseLink/D...
Whiteboard:
Keywords:
Depends on: 316513
Blocks: 333161 333336
  Show dependency tree
 
Reported: 2010-12-23 10:43 EST by Michael OBrien CLA
Modified: 2022-06-09 10:32 EDT (History)
2 users (show)

See Also:


Attachments
Preliminary patch for 3 of 5 sections where -1 was not handled in a indexOf() search - WAS integration testing pending (4.48 KB, patch)
2010-12-23 11:11 EST, Michael OBrien CLA
no flags Details | Diff
Pre-code-review patch of fix for indexOf() usage where there is no match for application or module names in classLoader toString - verified on WLS and JBoss (11.04 KB, patch)
2010-12-23 14:05 EST, Michael OBrien CLA
no flags Details | Diff
Pre-code-review patch of fix for indexOf() usage where there is no match for application or module names in classLoader toString - verified on WLS and JBoss (10.54 KB, patch)
2010-12-23 15:29 EST, Michael OBrien CLA
no flags Details | Diff
Pre-code-review patch of fix for indexOf() usage where there is no match for application or module names in classLoader toString - verified on WebSphere, WebLogic and JBoss (14.97 KB, patch)
2010-12-24 11:29 EST, Michael OBrien CLA
no flags Details | Diff
2.2 milestone patch of both 333160 and 333336 (23.61 KB, patch)
2011-01-11 14:49 EST, Michael OBrien CLA
no flags Details | Diff
10427734 for 333160 and 333336 on 2.1.3 backport (28.57 KB, patch)
2011-02-25 16:08 EST, Michael OBrien CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael OBrien CLA 2010-12-23 10:43:29 EST
>The following code needs to be fixed to handle cases where the WebSphere module name is unexpected (not found = -1 indexOf()
The code currently assumes that all WebSphere platforms use the format below for their enterprise modules

https://bugs.eclipse.org/bugs/show_bug.cgi?id=316513#c19
jar:file:/C:/opt/was7b/AppServer/profiles/AppSrv01/installedApps/xps435Node01Cell/org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEJB.jar!/_example]
>prefixed with ".jar!/"

JMXServerPlatformBase.initializeApplicationNameAndModuleName():505 and the 3 of the 5 other subString(indexOf(..)) sections need to be fixed and defer to a default DEFAULT_SERVER_NAME_AND_VERSION for undefined module names.

>In the case of a the following scenario where the indexOf() returns -1 (not found)
startIndex	-1	
endIndex	5	

>and ends up using 4 as the subString position (possibly in error depending on the length())
>The following
        if (jpaModuleName == null) {
            String subString = databaseSessionName.substring(databaseSessionName.indexOf(
                    APP_SERVER_CLASSLOADER_MODULE_EJB_SEARCH_STRING_PREFIX) + 
                    APP_SERVER_CLASSLOADER_MODULE_EJB_SEARCH_STRING_PREFIX.length());
>should be something like

       // Get the name past the matching string if we have a match
        int startIndex = databaseSessionName.indexOf(
                APP_SERVER_CLASSLOADER_MODULE_EJB_SEARCH_STRING_PREFIX);
        if (jpaModuleName == null && startIndex > -1) {
            String subString = databaseSessionName.substring(startIndex + 
                    APP_SERVER_CLASSLOADER_MODULE_EJB_SEARCH_STRING_PREFIX.length());
Comment 1 Michael OBrien CLA 2010-12-23 10:56:29 EST
>We need to get the exact version of the WAS server (I have 7.0.0.5) and get the SE JMX test suite (bug # coded up for regression testing
We also need to see how we can modify our server testing to exercise and verify the attribute names generated via classLoader string searching in bug# 333161
Comment 2 Michael OBrien CLA 2010-12-23 11:11:10 EST
Created attachment 185777 [details]
Preliminary patch for 3 of 5 sections where -1 was not handled in a indexOf() search - WAS integration testing pending

>Prelimnary patch - I need to test this on a WebSphere 7 server first (1 to 4 hours)
Comment 3 Michael OBrien CLA 2010-12-23 13:06:35 EST
10427734
Comment 4 Michael OBrien CLA 2010-12-23 14:05:01 EST
Created attachment 185782 [details]
Pre-code-review patch of fix for indexOf() usage where there is no match for application or module names in classLoader toString - verified on WLS and JBoss

    The proposed changes are the same for 2.1 and 2.2 (not yet code-reviewed) - test results on WebLogic and JBoss are below (WebSphere and GlassFish are pending)

>WebLogic 10.3.3.0+
<23-Dec-2010 1:47:03 o'clock PM EST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 10.3.x.0  Fri Oct 1 20:26:51 PDT 2010 1368456 >
[EL Info]: 2010-12-23 13:51:37.967--ServerSession(21536270)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--EclipseLink, version: Eclipse Persistence Services - 2.1.3.qualifier
[EL Finest]: 2010-12-23 13:51:38.126--ServerSession(21536270)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The applicationName for the MBean attached to session [file:/F:/view_w35e/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB/build/classes/_example] is [org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR]
[EL Finest]: 2010-12-23 13:51:38.126--ServerSession(21536270)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The moduleName for the MBean attached to session [file:/F:/view_w35e/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB/build/classes/_example] is [enterprise]


>JBoss 5 EAP
13:56:27,365 INFO  [STDOUT] [EL Finest]: 2010-12-23 13:56:27.365--ServerSession(22541557)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--The applicationName for the MBean attached to session [vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2] is [unknown]
13:56:27,365 INFO  [STDOUT] [EL Finest]: 2010-12-23 13:56:27.365--ServerSession(22541557)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--The moduleName for the MBean attached to session [vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2] is [unknown]
Comment 5 Michael OBrien CLA 2010-12-23 15:29:34 EST
Created attachment 185787 [details]
Pre-code-review patch of fix for indexOf() usage where there is no match for application or module names in classLoader toString - verified on WLS and JBoss

>Minor adjustment to patch - while debugging JBoss noticed that my null checks were now invalid
because I set the fallback default names at the start instead of at the end of the try/catch block

>Debugging
this    JBossPlatform  (id=399)   
databaseSessionName    "vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2" (id=462)   
classLoaderName    "BaseClassLoader@bc4fb{vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/}" (id=466)   
jpaModuleName    null   
jpaApplicationName    null   
startIndex    190   
subString    "_example2" (id=467)   

>Logs
trunk
15:20:02,295 INFO  [STDOUT] [EL Finest]: 2010-12-23 15:20:02.285--ServerSession(32651944)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--The applicationName for the MBean attached to session [vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2] is [org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear]
15:20:06,360 INFO  [STDOUT] [EL Finest]: 2010-12-23 15:20:06.358--ServerSession(32651944)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--The moduleName for the MBean attached to session [vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2] is [_example2]
Comment 6 Michael OBrien CLA 2010-12-24 11:29:06 EST
Created attachment 185810 [details]
Pre-code-review patch of fix for indexOf() usage where there is no match for application or module names in classLoader toString - verified on WebSphere, WebLogic and JBoss

>WebSphere 7.0.0.5
http://127.0.0.1:9080/enterprise/FrontController?action=demo
[12/24/10 11:20:40:883 EST] 00000013 SystemOut     O [EL Finest]: 2010-12-24 11:20:40.883--ServerSession(1702651260)--Thread(Thread[WebContainer : 0,5,main])--EclipseLink JMX Runtime Services is referencing the [Platform ConversionManager] ClassLoader at: [
com.ibm.ws.classloader.CompoundClassLoader@fd80fd8[app:org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEAR]
   Local ClassPath: C:\opt\was7b\AppServer\profiles\AppSrv01\installedApps\xps435Node01Cell\org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEAR.ear\org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEJB.jar;C:\opt\was7b\AppServer\profiles\AppSrv01\installedApps\xps435Node01Cell\org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEAR.ear\org.eclipse.persistence.example.jpa.server.entities.jar
   Parent: com.ibm.ws.classloader.ProtectionClassLoader@3a1d3a1d
   Delegation Mode: PARENT_FIRST]
[12/24/10 11:20:40:884 EST] 00000013 SystemOut     O [EL Finest]: 2010-12-24 11:20:40.883--ServerSession(1702651260)--Thread(Thread[WebContainer : 0,5,main])--The applicationName for the MBean attached to session [jar:file:/C:/opt/was7b/AppServer/profiles/AppSrv01/installedApps/xps435Node01Cell/org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEJB.jar!/_example] is [org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEAR]
[12/24/10 11:20:40:884 EST] 00000013 SystemOut     O [EL Finest]: 2010-12-24 11:20:40.884--ServerSession(1702651260)--Thread(Thread[WebContainer : 0,5,main])--The moduleName for the MBean attached to session [jar:file:/C:/opt/was7b/AppServer/profiles/AppSrv01/installedApps/xps435Node01Cell/org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.websphere.EnterpriseEJB.jar!/_example] is [_example]

>JBoss 5 EAP
http://127.0.0.1:8080/enterprise/FrontController?action=demo
this	JBossPlatform  (id=373)	
databaseSessionName	"vfszip_/C_/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2" (id=464)	
classLoaderName	"BaseClassLoader@19c4f4e{vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/}" (id=466)	

11:09:18,711 INFO  [STDOUT] [EL Finest]: 2010-12-24 11:09:18.709--ServerSession(29051400)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--The applicationName for the MBean attached to session [vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2] is [org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear]
11:09:19,662 INFO  [STDOUT] [EL Finest]: 2010-12-24 11:09:19.66--ServerSession(29051400)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--The moduleName for the MBean attached to session [vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2] is [_example2]

>WebLogic 10.3.3.0
http://127.0.0.1:7001/enterprise/FrontController?action=demo
[EL Finest]: 2010-12-24 11:14:06.683--ServerSession(15892568)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The applicationName for the MBean attached to session [file:/F:/view_w35e/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB/build/classes/_example] is [org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR]
[EL Finest]: 2010-12-24 11:14:06.683--ServerSession(15892568)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The moduleName for the MBean attached to session [file:/F:/view_w35e/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB/build/classes/_example] is [enterprise]


>Test Fail Fast: Exception condition output
(Test case: introduce a forced NPE in the code - temporarily for testing)

10:16:04,454 INFO  [STDOUT] [EL Finest]: 2010-12-24 10:16:04.452--ServerSession(4286345)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--The applicationName for the MBean attached to session [BaseClassLoader@43d24e{vfszip:/C:/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/}] is [unavailable]
10:16:09,945 INFO  [STDOUT] [EL Finest]: 2010-12-24 10:16:09.944--ServerSession(4286345)--Thread(Thread[http-127.0.0.1-8080-2,5,jboss])--The moduleName for the MBean attached to session [vfszip_/C_/opt/jboss-eap-5.0b/jboss-as/server/default/deploy/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar/_example2] is [unavailable]
10:16:46,845 ERROR [STDERR] java.lang.NullPointerException
10:16:46,846 ERROR [STDERR] 	at org.eclipse.persistence.platform.server.JMXServerPlatformBase.initializeApplicationNameAndModuleName(JMXServerPlatformBase.java:527)
Comment 7 Michael OBrien CLA 2010-12-24 11:57:47 EST
>review
http://dev.eclipse.org/mhonarc/lists/eclipselink-dev/msg05294.html
Comment 8 Michael OBrien CLA 2011-01-01 17:16:30 EST
>Trunk SVN rev# 8763
https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8763
>2.2 backport pending approval
Comment 9 Michael OBrien CLA 2011-01-10 16:01:32 EST
>changes in bug # 333336 for 2.2 will be part of the backport part of this fix
Comment 10 Michael OBrien CLA 2011-01-11 14:49:55 EST
Created attachment 186556 [details]
2.2 milestone patch of both 333160 and 333336

>see SVN rev # 8798 for the 2.2 stream milestone 20110111
https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8798
Comment 11 Michael OBrien CLA 2011-01-11 14:51:15 EST
>pending possible 2.1.x backport?
Comment 12 Michael OBrien CLA 2011-02-25 16:08:47 EST
Created attachment 189853 [details]
10427734 for 333160 and 333336 on 2.1.3 backport
Comment 13 Michael OBrien CLA 2011-02-25 16:18:09 EST
>Backport for 2.1.3 in SVN rev# 9046
https://fisheye2.atlassian.com/changelog/eclipselink?cs=9046
Comment 14 Eclipse Webmaster CLA 2022-06-09 10:32:56 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink