From 72427915eb7032264b4803f5b3cdfb31822b1031 Mon Sep 17 00:00:00 2001 From: richardyam-tibco Date: Thu, 26 May 2022 09:13:28 -0700 Subject: [PATCH 1/5] AMBW-45791 Support : Deploy same BW6 EAR file multiple times with different profile/GV using bw6-plugin-maven --- Source/bw6-maven-plugin/pom.xml | 2 +- .../maven/plugin/admin/client/RemoteDeployer.java | 15 ++++++++++++--- .../bw/maven/plugin/application/BWDeployMojo.java | 6 +++++- .../plugin/application/BWEARInstallerMojo.java | 7 ++++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Source/bw6-maven-plugin/pom.xml b/Source/bw6-maven-plugin/pom.xml index cbc295a3..bb1ceafd 100644 --- a/Source/bw6-maven-plugin/pom.xml +++ b/Source/bw6-maven-plugin/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.tibco.plugins bw6-maven-plugin - 2.9.2 + 2.9.4 maven-plugin Plugin Code for Apache Maven and TIBCO BusinessWorks™ Plugin Code for Apache Maven and TIBCO BusinessWorks™. diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/admin/client/RemoteDeployer.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/admin/client/RemoteDeployer.java index e70be9c3..ba1f0bc4 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/admin/client/RemoteDeployer.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/admin/client/RemoteDeployer.java @@ -297,7 +297,10 @@ public AppNode getOrCreateAppNode(final String domainName, final String appSpace return createAppNode(domainName, appSpaceName, appNodeName, agentName, httpPort, osgiPort, description); } - public void addAndDeployApplication(final String domainName, final String appSpaceName, final String appName, final String earName, final String file, final boolean replace, final String profile, final boolean backupEar, final String backupLocation,final String version,final boolean externalProfile, final String externalProfileLoc, final String appNodeName, final String path) throws Exception { + public void addAndDeployApplication(final String domainName, final String appSpaceName, final String appName, final String earName, + final String file, final boolean replace, final String profile, final boolean backupEar, + final String backupLocation,final String version,final boolean externalProfile, + final String externalProfileLoc, final String appNodeName, final String path, boolean skipUploadArchive) throws Exception { List applications = getApplications(domainName, appSpaceName, null, true); String appDescription=null; @@ -326,8 +329,14 @@ public void addAndDeployApplication(final String domainName, final String appSpa } } } - log.info("Uploading the Archive file -> " + earName + ", EAR Upload Path -> "+ path); - uploadArchive(domainName, path, file, true); + + if (!skipUploadArchive) { + log.info("Uploading the Archive file -> " + earName + ", EAR Upload Path -> "+ path); + uploadArchive(domainName, path, file, true); + } + else { + log.info("Skipping - Uploading the Archive file -> " + earName + ", EAR Upload Path -> "+ path); + } log.info("Deploying the Application with name -> " + appName + " with Profile -> " + profile); deployApplication(domainName, appSpaceName, earName, path, startOndeploy, replace, profile,externalProfile,appDescription); if(externalProfile){ diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWDeployMojo.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWDeployMojo.java index 30c0d6e6..febb2628 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWDeployMojo.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWDeployMojo.java @@ -120,6 +120,9 @@ public class BWDeployMojo extends AbstractMojo { @Parameter(property = "earUploadPath") private String earUploadPath; + @Parameter(property = "skipUploadArchive") + private boolean skipUploadArchive; + @Parameter(property="retryCount", defaultValue = "10") private int retryCount; @@ -243,7 +246,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { deployer.addAndDeployApplication(domain, appSpace, applicationName, earName, earFile.getAbsolutePath(), redeploy, profile, backup, backupLocation, version, externalProfile, - externalProfileLoc, appNode, earUploadPath); + externalProfileLoc, appNode, earUploadPath, skipUploadArchive); deployer.close(); deployer.close(); BWEarUtils.deleteEARFileEntries(earLocation); @@ -346,6 +349,7 @@ private void loadFromDeploymentProperties() throws MalformedURLException, IOExce .getProperty("externalProfile")); externalProfileLoc = deployment.getProperty("externalProfileLoc"); earUploadPath = deployment.getProperty("earUploadPath"); + skipUploadArchive = Boolean.parseBoolean(deployment.getProperty("skipUploadArchive")); getAppNodeConfigProps(deployment); } catch (Exception e) { getLog().error(e); diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java index 8871a0e1..f1fa2edc 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java @@ -134,6 +134,9 @@ public class BWEARInstallerMojo extends AbstractMojo { @Parameter(property = "externalEarLoc") private String externalEarLoc; + @Parameter(property="skipUploadArchive") + private boolean skipUploadArchive; + @Parameter(property = "createAdminCompo" , defaultValue = "true" ) private boolean createAdminCompo; @@ -271,7 +274,8 @@ public void execute() throws MojoExecutionException { getLog().info("AppSpace is Running."); } getLog().info("domain -> " + domain + " earName -> " + earName + " Ear file to be uploaded -> " + files[0].getAbsolutePath()); - deployer.addAndDeployApplication(domain, appSpace, applicationName, earName, files[0].getAbsolutePath(), redeploy, profile, backup, backupLocation,version,externalProfile,externalProfileLoc, appNode, earUploadPath); + deployer.addAndDeployApplication(domain, appSpace, applicationName, earName, files[0].getAbsolutePath(), redeploy, profile, + backup, backupLocation,version,externalProfile,externalProfileLoc, appNode, earUploadPath, skipUploadArchive); deployer.close(); } } catch(Exception e) { @@ -380,6 +384,7 @@ private void loadFromDeploymentProperties() throws MalformedURLException, IOExce externalProfileLoc=deployment.getProperty("externalProfileLoc"); externalEarLoc=deployment.getProperty("externalEarLoc"); earUploadPath = deployment.getProperty("earUploadPath"); + skipUploadArchive = Boolean.parseBoolean(deployment.getProperty("skipUploadArchive")); getAppNodeConfigProps(deployment); } catch(Exception e) { deployToAdmin = false; From bd8524bc88b62a5f36e8073663410b8b9f8da4f4 Mon Sep 17 00:00:00 2001 From: richardyam-tibco Date: Mon, 19 Sep 2022 15:11:51 -0700 Subject: [PATCH 2/5] AMBW-46468 [Maven][Unit testing][Regression] "Failed to start BW Engine" error comes while running Unit test projects. Need to update org.eclipse.osgi bundle to latest used by BW 6.9.0 --- .../bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java index 3307caeb..104d9404 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java @@ -86,7 +86,7 @@ public void generateConfig() properties.put( "osgi.bundles", builder.toString() ); properties.put( "osgi.bundles.defaultStartLevel", "5" ); properties.put( "osgi.install.area", "file:" + BWTestConfig.INSTANCE.getTibcoHome() + BWTestConfig.INSTANCE.getBwHome() + "/system/hotfix/lib/common"); - properties.put("osgi.framework", "file:" + BWTestConfig.INSTANCE.getTibcoHome() + BWTestConfig.INSTANCE.getBwHome() + "/system/lib/common/org.eclipse.osgi_3.15.300.v20200520-1959.jar"); + properties.put("osgi.framework", "file:" + BWTestConfig.INSTANCE.getTibcoHome() + BWTestConfig.INSTANCE.getBwHome() + "/system/lib/common/org.eclipse.osgi_3.16.200.v20210226-1447.jar"); properties.put("osgi.configuration.cascaded", "false"); FileOutputStream stream = new FileOutputStream(configIni); From a06c037c2c945dd23dad62878257ca0076c21b38 Mon Sep 17 00:00:00 2001 From: richardyam-tibco Date: Thu, 22 Sep 2022 09:07:08 -0700 Subject: [PATCH 3/5] AMBW-46776 [Regression][MAC] Null pointer exception is getting thrown when we run Maven samples --- .../com/tibco/bw/maven/plugin/test/helpers/TestFileParser.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/helpers/TestFileParser.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/helpers/TestFileParser.java index ab5409fa..f1687c15 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/helpers/TestFileParser.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/helpers/TestFileParser.java @@ -256,6 +256,9 @@ else if( "Operation".equals(cEl.getNodeName())) BWTestConfig.INSTANCE.getLogger().debug("Process : "+ processName + ", Activity : "+ activityName+ ", Id : "+ location +", Error : Invalid Mock Output File Path - "+mockOutputFilePath); throw new Exception("Process : "+ processName + ", Activity : "+ activityName+ ", Id : "+ location +", Error : Invalid Mock Output File Path - "+mockOutputFilePath); } + // on Mac and Unix - will replace backslash with forward slash + // on Windows - noop + mockOutputFilePath = mockOutputFilePath.replace("\\", File.separator); File file = new File(mockOutputFilePath); if(!file.isAbsolute()){ BWTestConfig.INSTANCE.getLogger().debug("Provided Mock File path is relative "+file.getPath()); From 4ba38a49310f3754cec0f0bb6bf145bc83878b0c Mon Sep 17 00:00:00 2001 From: richardyam-tibco Date: Thu, 22 Sep 2022 09:24:38 -0700 Subject: [PATCH 4/5] AMBW-46748 [Maven] Profile value is not updated in 'generate pom.xml' once user deploys application using 'external profile'/ 'other profile' option --- .../tibco/bw/maven/plugin/admin/client/RemoteDeployer.java | 5 ++++- .../bw/maven/plugin/application/BWEARInstallerMojo.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/admin/client/RemoteDeployer.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/admin/client/RemoteDeployer.java index ba1f0bc4..bd16a704 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/admin/client/RemoteDeployer.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/admin/client/RemoteDeployer.java @@ -339,7 +339,10 @@ public void addAndDeployApplication(final String domainName, final String appSpa } log.info("Deploying the Application with name -> " + appName + " with Profile -> " + profile); deployApplication(domainName, appSpaceName, earName, path, startOndeploy, replace, profile,externalProfile,appDescription); - if(externalProfile){ + // fix from runtime side only + // UI doesn't seem to fix the externalProfile flag when profile is set to an application Profile + // We should use the external profile here if this is really the case + if(externalProfile && !externalProfileLoc.isEmpty() && (profile != null && profile.equals("other")) ) { setProfile(domainName,appSpaceName,version,appName,externalProfileLoc); log.info("Starting Application -> "+ appName); if(startOndeploy){ diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java index f1fa2edc..b207afbd 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java @@ -479,7 +479,10 @@ private boolean validateFields() { } boolean isValidexternalProfileLoc = true; - if(externalProfile && externalProfileLoc.isEmpty()) { + // fix from runtime side only + // UI doesn't seem to fix the externalProfile flag when profile is set to an application Profile + // We should give error only if profile is set to "other" and not an interal application profile + if(externalProfile && externalProfileLoc.isEmpty() && (profile != null && profile.equals("other")) ) { isValidexternalProfileLoc = false; errorMessage.append("[external Profile Location value is required]"); } From 5f1d21bdf86784883ae37f2c40aefab84a46bce9 Mon Sep 17 00:00:00 2001 From: richardyam-tibco Date: Tue, 18 Oct 2022 15:24:27 -0700 Subject: [PATCH 5/5] BWCE-4934 ClassNotFoundException Error while running BWUnit tests with Java Projects --- .../test/setuplocal/ConfigFileGenerator.java | 64 ++++++++++++++++--- .../bw/maven/plugin/utils/Constants.java | 3 + 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java index 104d9404..1a011852 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/test/setuplocal/ConfigFileGenerator.java @@ -16,12 +16,21 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.project.MavenProject; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import org.w3c.dom.Element; import com.tibco.bw.maven.plugin.osgi.helpers.ManifestParser; import com.tibco.bw.maven.plugin.test.helpers.BWTestConfig; +import com.tibco.bw.maven.plugin.utils.Constants; public class ConfigFileGenerator { @@ -44,13 +53,16 @@ public void generateConfig() addPluginsFromDir(target, builder); } - List cxfProjects = new ArrayList(); + List requiredDevPropertiesProjects = new ArrayList(); List projects = BWTestConfig.INSTANCE.getSession().getProjects(); for( MavenProject project : projects ) { if (project.getPackaging().equals("bwmodule") || project.getPackaging().equals("bwear")) { + if (isJavaProject(project)) { + requiredDevPropertiesProjects.add(project); + } Set artifacts = project.getDependencyArtifacts(); if(artifacts != null) { @@ -65,7 +77,7 @@ public void generateConfig() } } if(isCXF){ - cxfProjects.add(project); + requiredDevPropertiesProjects.add(project); } } } @@ -94,7 +106,7 @@ public void generateConfig() stream.flush(); stream.close(); - generateDevPropertiesFile(cxfProjects); + generateDevPropertiesFile(requiredDevPropertiesProjects); } catch(Exception e ) @@ -104,18 +116,52 @@ public void generateConfig() } - private void generateDevPropertiesFile(List cxfProjects) throws IOException, DependencyResolutionRequiredException{ + private boolean isJavaProject(MavenProject project) { + File projectFile = new File(project.getBasedir(), Constants.DOT_PROJECT_FILE); + NodeList nList = getNatureList(projectFile); + if (nList != null) { + for(int i = 0; i < nList.getLength(); i++) { + if (nList.item(i) != null) { + Element node = (Element)nList.item(i); + String nature = node.getTextContent(); + if (nature != null && nature.equals(Constants.NATURE_JAVE_PROJECT_PROPERTY)) + return true; + } + } + } + return false; + } + + private NodeList getNatureList(File dotProject) { + NodeList nList = null; + try { + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + dbFactory.setNamespaceAware(true); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(dotProject); + nList = doc.getElementsByTagName(Constants.NATURE_PROPERTY); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } catch (SAXException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return nList; + } + + private void generateDevPropertiesFile(List requiredDevPropertiesProjects) throws IOException, DependencyResolutionRequiredException{ File devProps = new File( BWTestConfig.INSTANCE.getConfigDir() , "dev.properties"); devProps.createNewFile(); Properties properties = new Properties(); properties.put("@ignoredot@","true"); - for(MavenProject cxfProject : cxfProjects) + for(MavenProject reqProject : requiredDevPropertiesProjects) { //find classpath - Manifest projectManifest = ManifestParser.parseManifest( cxfProject.getBasedir() ); + Manifest projectManifest = ManifestParser.parseManifest( reqProject.getBasedir() ); String bundleClassPath = projectManifest.getMainAttributes().getValue("Bundle-ClassPath"); - BWTestConfig.INSTANCE.getLogger().debug("Bundle-Classpath for project "+ cxfProject.getName() +" -> "+bundleClassPath); + BWTestConfig.INSTANCE.getLogger().debug("Bundle-Classpath for project "+ reqProject.getName() +" -> "+bundleClassPath); String pathString = ""; if(bundleClassPath != null) { @@ -126,8 +172,8 @@ private void generateDevPropertiesFile(List cxfProjects) throws IO } } pathString = "bin,target/classes" + pathString; - properties.put(cxfProject.getName(), pathString); - BWTestConfig.INSTANCE.getLogger().debug("Adding CXF project entry to dev.properties -> "+ cxfProject.getName()+ "="+ pathString); + properties.put(reqProject.getName(), pathString); + BWTestConfig.INSTANCE.getLogger().debug("Adding project entry to dev.properties -> "+ reqProject.getName()+ "="+ pathString); } FileOutputStream stream = new FileOutputStream(devProps); diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/utils/Constants.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/utils/Constants.java index 91fa2bdd..e80bf5e7 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/utils/Constants.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/utils/Constants.java @@ -22,6 +22,9 @@ public interface Constants { public static final String TEMP_SUBSTVAR = "external.substvar"; public static final String TIMESTAMP = "timestamp"; public static final String COMPONENT_PROCESS = "ComponentProcess"; + public static final String DOT_PROJECT_FILE = ".project"; + public static final String NATURE_PROPERTY = "nature"; + public static final String NATURE_JAVE_PROJECT_PROPERTY = "org.eclipse.jdt.core.javanature"; // TCI public static final String TCI_SERVER_ENDPOINT_ENV = "TCI_PLATFORM_API_ENDPOINT";