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

Windows: Dev mode can crash when editing server.xml with a java.lang.NoClassDefFoundError. #429

Closed
mrglavas opened this issue Jun 2, 2023 · 22 comments
Labels
bug Something isn't working should-fix
Milestone

Comments

@mrglavas
Copy link
Contributor

mrglavas commented Jun 2, 2023

Steps to reproduce:

  • Install liberty-tools-intellij-0.0.9-SNAPSHOT.zip
  • Create a Maven project with EE9 and MP5 (from https://openliberty.io/start/)
  • Start dev mode
  • Add an empty feature tag to server.xml. Either save or allow it to auto-save.

image

Received the following exception in the terminal before the process died.

Exception in thread "Thread-4" java.lang.NoClassDefFoundError: org.apache.commons.io.file.StandardDeleteOption
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1341)
        at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:324)
        at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1192)
        at io.openliberty.tools.common.plugins.util.DevUtil.cleanUpTempConfig(DevUtil.java:2037)
        at io.openliberty.tools.common.plugins.util.DevUtil.runShutdownHook(DevUtil.java:2088)
        at io.openliberty.tools.common.plugins.util.DevUtil.access$500(DevUtil.java:107)
        at io.openliberty.tools.common.plugins.util.DevUtil$6.run(DevUtil.java:2075)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.file.StandardDeleteOption
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 7 more

I had to manually stop Liberty with mvn liberty:stop before I could start dev mode again. I tried this again and got the same result so it seems to be reproducible.

@mrglavas mrglavas added the bug Something isn't working label Jun 2, 2023
@mrglavas mrglavas changed the title Windows: Dev mode can crash when editing server.xml Windows: Dev mode can crash when editing server.xml with java.lang.NoClassDefFoundError. Jun 2, 2023
@mrglavas mrglavas changed the title Windows: Dev mode can crash when editing server.xml with java.lang.NoClassDefFoundError. Windows: Dev mode can crash when editing server.xml with a java.lang.NoClassDefFoundError. Jun 2, 2023
@TrevCraw TrevCraw added this to the GA milestone Jun 4, 2023
@rumanaHaque
Copy link

I just tried this on my VSCode install in Mac.
Started the server (so it is in dev mode)
Edited the server.xml to include an empty feature, and then saved the file.

image I did not get any exception.

@TrevCraw
Copy link
Contributor

TrevCraw commented Jun 5, 2023

Attempted to reproduce with IntelliJ on Windows environment. Got a different, but valid exception and dev mode is still running:

[ERROR] Failed to install features from configuration file
org.apache.maven.plugin.MojoExecutionException: CWWKF1299E: The following features could not be obtained: . Ensure that the features are valid for Open Liberty.
    at org.codehaus.mojo.pluginsupport.MojoSupport.execute (MojoSupport.java:137)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:120)
    at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojo (StartDebugMojoSupport.java:363)
    at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojoInstallFeature (StartDebugMojoSupport.java:348)
    at io.openliberty.tools.maven.server.DevMojo.runLibertyMojoInstallFeature (DevMojo.java:1911)
...
...
...
Caused by: io.openliberty.tools.common.plugins.util.PluginExecutionException: CWWKF1299E: The following features could not be obtained: . Ensure that the features are valid for Open Liberty.
    at io.openliberty.tools.common.plugins.util.InstallFeatureUtil.installFeatures (InstallFeatureUtil.java:615)
    at io.openliberty.tools.maven.server.InstallFeatureMojo.installFeatures (InstallFeatureMojo.java:99)
    at io.openliberty.tools.maven.server.InstallFeatureMojo.doExecute (InstallFeatureMojo.java:70)
    at org.codehaus.mojo.pluginsupport.MojoSupport.execute (MojoSupport.java:122)
...
...
...

@cherylking
Copy link
Member

cherylking commented Jun 5, 2023

Since the error is on DevUtil.cleanUpTempConfig(DevUtil.java:2037), this will probably be a Windows only problem related to file locking.

I checked the behavior of the Liberty Maven plugin and dev mode outside of Liberty Tools on Mac and found the following:

  1. The Liberty server starts ok with an empty feature element. It just logs an error in messages.log about the feature that was not found, which in this case is an empty feature.
E CWWKF0001E: A feature definition could not be found for 
  1. If you start dev mode from the command line outside of Liberty Tools using mvn liberty:dev for a project that contains an empty feature element in server.xml, it fails.
[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.8:dev (default-cli) on project guide-getting-started: Error installing features for server defaultServer: CWWKF1299E: The following features could not be obtained: . Ensure that the features are valid for Open Liberty. -> [Help 1]
  1. If you have dev mode running from command line outside of Liberty Tools, then edit the server.xml to add an empty feature element and save it...it gets an error but continues running dev mode.
[INFO] Installing features: [, jsonb-2.0, mphealth-4.0, mpconfig-3.0, mpmetrics-4.0, restfulws-3.0, jsonp-2.0, cdi-3.0]

[ERROR] Failed to install features from configuration file
org.apache.maven.plugin.MojoExecutionException: Error installing features for server defaultServer
    at io.openliberty.tools.maven.server.InstallFeatureMojo.doInstallFeatures (InstallFeatureMojo.java:77)
    at io.openliberty.tools.maven.server.InstallFeatureMojo.execute (InstallFeatureMojo.java:66)

The server shutdown works fine when I press q and hit enter key.

Opened issue 1682 in LMP to modify that behavior slightly to improve user experience.

@mezarin
Copy link
Member

mezarin commented Jun 5, 2023

On MAC the issue does not occur.
Using IDEA 2023.1.2, Semeru JDK 17.0.4, and the app using Maven 3.8.6, you get the failure stating that there is an invalid feature configuration as expected, but dev mode continues to function.
image

image (1)

@rumanaHaque
Copy link

I just tested this using Eclipse in Windows - and I was able to recreate.

image

@rumanaHaque
Copy link

Retried this in Windows Eclipse using the -X -e option using "Start ..."

Here's the stack trace of the exception.


[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.7.1:dev (default-cli) on project AcmeWebEjbEar: C:\eclipse-workspace\acme-ee10\acme-ee\AcmeWebEjbEar\target\liberty\wlp\usr\servers\defaultServer\messaging\messageStore\Log -> C:\Users\ADMINI~1\AppData\Local\Temp\2\tempConfig13557421902766991847\messaging\messageStore\Log: The process cannot access the file because another process has locked a portion of the file -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.7.1:dev (default-cli) on project AcmeWebEjbEar: C:\eclipse-workspace\acme-ee10\acme-ee\AcmeWebEjbEar\target\liberty\wlp\usr\servers\defaultServer\messaging\messageStore\Log -> C:\Users\ADMINI~1\AppData\Local\Temp\2\tempConfig13557421902766991847\messaging\messageStore\Log: The process cannot access the file because another process has locked a portion of the file
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)      
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: C:\eclipse-workspace\acme-ee10\acme-ee\AcmeWebEjbEar\target\liberty\wlp\usr\servers\defaultServer\messaging\messageStore\Log -> C:\Users\ADMINI~1\AppData\Local\Temp\2\tempConfig13557421902766991847\messaging\messageStore\Log: The process cannot access the file because another process has locked a portion of the file
    at org.codehaus.mojo.pluginsupport.MojoSupport.execute (MojoSupport.java:137)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)   
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)      
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.nio.file.FileSystemException: C:\eclipse-workspace\acme-ee10\acme-ee\AcmeWebEjbEar\target\liberty\wlp\usr\servers\defaultServer\messaging\messageStore\Log -> C:\Users\ADMINI~1\AppData\Local\Temp\2\tempConfig13557421902766991847\messaging\messageStore\Log: The process cannot access the file because another process has locked a portion of the file
    at sun.nio.fs.WindowsException.translateToIOException (WindowsException.java:92)
    at sun.nio.fs.WindowsException.rethrowAsIOException (WindowsException.java:103)
    at sun.nio.fs.WindowsFileCopy.copy (WindowsFileCopy.java:209)
    at sun.nio.fs.WindowsFileSystemProvider.copy (WindowsFileSystemProvider.java:284)
    at java.nio.file.Files.copy (Files.java:1305)
    at org.apache.commons.io.FileUtils.copyFile (FileUtils.java:850)
    at org.apache.commons.io.FileUtils.doCopyDirectory (FileUtils.java:1312)
    at org.apache.commons.io.FileUtils.doCopyDirectory (FileUtils.java:1310)
    at org.apache.commons.io.FileUtils.doCopyDirectory (FileUtils.java:1310)
    at org.apache.commons.io.FileUtils.copyDirectory (FileUtils.java:699)
    at org.apache.commons.io.FileUtils.copyDirectory (FileUtils.java:630)
    at io.openliberty.tools.common.plugins.util.DevUtil.installFeaturesToTempDir (DevUtil.java:4556)        
    at io.openliberty.tools.common.plugins.util.DevUtil.processConfigFileChange (DevUtil.java:4325)
    at io.openliberty.tools.common.plugins.util.DevUtil.processFileChanges (DevUtil.java:4181)
    at io.openliberty.tools.common.plugins.util.DevUtil.watchFiles (DevUtil.java:3145)
    at io.openliberty.tools.maven.server.DevMojo.doExecute (DevMojo.java:1436)
    at org.codehaus.mojo.pluginsupport.MojoSupport.execute (MojoSupport.java:122)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)   
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)      
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:   
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :AcmeWebEjbEar
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: org/apache/commons/io/file/StandardDeleteOption
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1341)
        at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:324)
        at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1192)
        at io.openliberty.tools.common.plugins.util.DevUtil.cleanUpTempConfig(DevUtil.java:2037)
        at io.openliberty.tools.common.plugins.util.DevUtil.runShutdownHook(DevUtil.java:2088)
        at io.openliberty.tools.common.plugins.util.DevUtil.access$500(DevUtil.java:107)
        at io.openliberty.tools.common.plugins.util.DevUtil$6.run(DevUtil.java:2075)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.file.StandardDeleteOption
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)  
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)    
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 7 more

@cherylking
Copy link
Member

cherylking commented Jun 5, 2023

Noting here that I put two fixes into ci.common and produced a 3.8.1-SNAPSHOT for liberty-maven-plugin that seems to have "fixed" this problem. We are not 100% certain that it truly fixed it, but the changes are good to have regardless. Once all the GHA builds are finished on the main branches, I will do the work to publish ci.common in preparation to publish LMP 3.8.1 and LGP 3.6.1 with the fixes. The fixes simply log a warning when an empty feature element is found in a server configuration file and does not add it to the list of features to be installed. This then avoids errors that were happening in dev mode trying to install empty features. The Liberty server will still log an error like the following when the server is started.

[INFO] [ERROR   ] CWWKF0001E: A feature definition could not be found for 

I also opened an issue in LCLS to revisit whether we should flag a diagnostic for an empty feature element.

@cherylking
Copy link
Member

Wondering if this can be recreated with a non-existing feature like "bogus-1.0" instead of an empty feature? The fixes I made in LMP/LGP would have no affect on that scenario.

@mrglavas
Copy link
Contributor Author

mrglavas commented Jun 8, 2023

@cherylking After updating to:

                <plugin>
                    <groupId>io.openliberty.tools</groupId>
                    <artifactId>liberty-maven-plugin</artifactId>
                    <version>3.8.1</version>
                </plugin>

I can still get dev mode to crash by specifying any feature (e.g. "mpOpenAPI-3.1"), not just a non-existing one like "bogus-1.0".

Also noticed a slight difference in the output between 3.7.1 and 3.8.1. When the 3.7.1 process exits, it says the build failed. When the 3.8.1 process exits, it says the build succeeded despite dev mode actually crashing. It prints similar stack traces at the end in both cases.

Maven plugin 3.7.1 output:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:36 min
[INFO] Finished at: 2023-06-08T11:37:30-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.7.1:dev (default-cli) on project maven-sample: C:\libertyToolsGit4\libertyToolsTest\projects\maven-sample\target\liberty\wlp\usr\servers\defaultServer\messaging\messageStore\Log -> C:\Users\MICHAE~1\AppData\Local\Temp\tempConfig14539418945527025808\messaging\messageStore\Log: The process cannot access the file because another process has locked a portion of the file -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Exception in thread "Thread-5" java.lang.NoClassDefFoundError: org.apache.commons.io.file.DeletingPathVisitor
        at org.apache.commons.io.file.PathUtils.deleteDirectory(PathUtils.java:434)
        at org.apache.commons.io.file.PathUtils.delete(PathUtils.java:391)
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1341)
        at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:324)
        at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1192)
        at io.openliberty.tools.common.plugins.util.DevUtil.cleanUpTempConfig(DevUtil.java:2037)
        at io.openliberty.tools.common.plugins.util.DevUtil.runShutdownHook(DevUtil.java:2088)
        at io.openliberty.tools.common.plugins.util.DevUtil.access$500(DevUtil.java:107)
        at io.openliberty.tools.common.plugins.util.DevUtil$6.run(DevUtil.java:2075)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.file.DeletingPathVisitor
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 9 more

Maven plugin 3.8.1 output:

[INFO] C:\libertyToolsGit4\libertyToolsTest\projects\maven-sample\target\liberty\wlp\usr\servers\defaultServer\messaging\messageStore\Log -> C:\Users\MICHAE~1\AppData\Local\Temp\tempConfig18008081689246074870\messaging\messageStore\Log: The process cannot access the file because another process has locked a portion of the file
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:43 min
[INFO] Finished at: 2023-06-08T11:19:43-04:00
[INFO] ------------------------------------------------------------------------
Exception in thread "Thread-4" java.lang.NoClassDefFoundError: org.apache.commons.io.file.StandardDeleteOption
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1341)
        at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:324)
        at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1192)
        at io.openliberty.tools.common.plugins.util.DevUtil.cleanUpTempConfig(DevUtil.java:2037)
        at io.openliberty.tools.common.plugins.util.DevUtil.runShutdownHook(DevUtil.java:2088)
        at io.openliberty.tools.common.plugins.util.DevUtil.access$500(DevUtil.java:107)
        at io.openliberty.tools.common.plugins.util.DevUtil$6.run(DevUtil.java:2075)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.file.StandardDeleteOption
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 7 more

@cherylking
Copy link
Member

@mrglavas You are saying if you add a valid feature to server.xml and save while dev mode is running, it crashes? And this is only with the latest 3.8.1 and not the earlier versions of Liberty Maven plugin? I don't know why the version of LMP would make any difference, as the code handling updates to server.xml with valid features would be no different between those versions.

@mrglavas
Copy link
Contributor Author

mrglavas commented Jun 8, 2023

@cherylking Adding a valid feature to server.xml and saving it crashes for both 3.7.1 and 3.8.1.

@cherylking
Copy link
Member

@cherylking Adding a valid feature to server.xml and saving it crashes for both 3.7.1 and 3.8.1.

@mrglavas Wondering if you could recreate this outside of the IDE with just a command prompt running mvn liberty:dev? After it is running, edit the server.xml and add a valid feature and save the file. What happens in the command prompt? Does dev mode crash?

@mrglavas
Copy link
Contributor Author

mrglavas commented Jun 8, 2023

@cherylking I ran mvn liberty:dev from the command prompt, added a feature to server.xml, saved the file and it also crashed:

image

@cherylking
Copy link
Member

cherylking commented Jun 8, 2023

@cherylking I ran mvn liberty:dev from the command prompt, added a feature to server.xml, saved the file and it also crashed:

ok, good to know. Thanks for trying that. This is obviously an issue with the plugins and not Liberty Tools. We will get an issue open and follow up.

@cherylking
Copy link
Member

fyi..I am working on some changes in ci.common to hopefully avoid this exception path. I will update here when a Liberty Maven plugin 3.8.2-SNAPSHOT is available to test with.

@TrevCraw
Copy link
Contributor

TrevCraw commented Jun 8, 2023

Looking at this list of messaging related features to find the ones that need to be installed to trigger this issue...

mpReactiveMessaging-1.0
messagingSecurity-3.0
messagingClient-3.0
messagingServer-3.0
jmsMdb-3.2
messaging-3.1
mdb-4.0
eventLogging-1.0
audit-1.0

...the only two that lead to exceptions when a new feature is added are

messagingServer-3.0
messagingSecurity-3.0

Note: the initial list may not be an exhaustive list of messaging features.

@cherylking
Copy link
Member

cherylking commented Jun 8, 2023

I published a 3.8.2-SNAPSHOT for Liberty Maven plugin. Please test with that and see if it has a positive effect on this scenario (from command line would be sufficient as it is unrelated to IDE).

You need to have the following in the pom.xml to use snapshots:

<pluginRepositories>
        <!-- Configure Sonatype OSS Maven snapshots repository -->
        <pluginRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

Updated with correct pom.xml configuration.

@TrevCraw
Copy link
Contributor

TrevCraw commented Jun 9, 2023

The fix in the 3.8.2-SNAPSHOT resolves the issue in my environment for both features listed above.

@cherylking
Copy link
Member

Can we mark this as resolved by the changes that went into ci.common in this PR? I have already published ci.common 1.8.26 and have PRs open in ci.maven and ci.gradle to use that version. I will publish LMP 3.8.2 and LGP 3.6.2 by EOB today.

@rumanaHaque
Copy link

I do have these 2 features in my server.xml

       <feature>messaging-3.1</feature>
       <feature>messagingClient-3.0</feature>
       <feature>messagingSecurity-3.0</feature>
       <feature>messagingServer-3.0</feature>

After going to lmp 3.8.1, I was unable to reproduce using the empty feature .
However, when I tried to add a new feature (I added mpMetrics-5.0), I got the same exception.

Exception in thread "Thread-1" java.lang.NoClassDefFoundError: org/apache/commons/io/file/StandardDeleteOption
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1341)
        at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:324)
        at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1192)
        at io.openliberty.tools.common.plugins.util.DevUtil.cleanUpTempConfig(DevUtil.java:2037)
        at io.openliberty.tools.common.plugins.util.DevUtil.runShutdownHook(DevUtil.java:2088)
        at io.openliberty.tools.common.plugins.util.DevUtil.access$500(DevUtil.java:107)
        at io.openliberty.tools.common.plugins.util.DevUtil$6.run(DevUtil.java:2075)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.file.StandardDeleteOption
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)       
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)

Switching to lmp 3.8.2-SNAPSHOT does resolve this probelm.

@mrglavas
Copy link
Contributor Author

mrglavas commented Jun 9, 2023

3.8.2-SNAPSHOT resolved the issue for me too.

@cherylking
Copy link
Member

The Liberty Maven plugin 3.8.2 and Liberty Gradle plugin 3.6.2 have been published and contain this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working should-fix
Projects
Status: 23.0.6
Development

No branches or pull requests

5 participants