Hi Manoj,
Please apply the here attached patch for issue [1] as a temporary fix until
this is properly fixed in next kernel release. The patch location is
'core/org.wso2.carbon.application.deployer/4.2.0'
[1] https://wso2.org/jira/browse/CARBON-14743
Thanks and Regards,
AsankaS.
--
*Asanka Sanjeewa*
Senior Software Engineer
Mobile: +94772532924
WSO2 Inc. http://wso2.com/
Blog: http://asanka-tech-blog.blogspot.com/
Index:
src/main/java/org/wso2/carbon/application/deployer/handler/DefaultAppDeployer.java
===================================================================
---
src/main/java/org/wso2/carbon/application/deployer/handler/DefaultAppDeployer.java
(revision 198954)
+++
src/main/java/org/wso2/carbon/application/deployer/handler/DefaultAppDeployer.java
(working copy)
@@ -17,11 +17,16 @@
*/
package org.wso2.carbon.application.deployer.handler;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
import org.apache.axis2.deployment.Deployer;
import org.apache.axis2.deployment.DeploymentEngine;
import org.apache.axis2.deployment.DeploymentException;
import org.apache.axis2.deployment.repository.util.DeploymentFileData;
import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.Bundle;
@@ -32,12 +37,17 @@
import org.wso2.carbon.application.deployer.config.Artifact;
import org.wso2.carbon.application.deployer.config.CappFile;
import
org.wso2.carbon.application.deployer.internal.AppDeployerServiceComponent;
+import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.List;
import java.util.Map;
+import javax.xml.namespace.QName;
+
/**
* This is one of the default handlers which is registered into the
ApplicationManager. This
* class deploys AAR services, JAXWS services, Data services and libs.
@@ -196,7 +206,10 @@
*/
installBundle(artifactPath);
artifact.setRuntimeObjectName(fileName);
- }
+ } else if
(SERVICE_META_TYPE.equals(artifact.getType())) {
+ // Copy service meta artifact into
'servicemetafiles' directory
+ deployServiceMetaArtifact(artifactPath,
fileName, axisConfig);
+ }
// deploy the dependencies of the current artifact
deployRecursively(artifact.getDependencies(), axisConfig);
}
@@ -302,5 +315,62 @@
}
return deployer;
}
+
+ /**
+ * Copy service meta artifacts into SERVICE_META_DIR.
+ * @param artifactPath
+ * @param fileName
+ * @param axisConfig
+ * @throws DeploymentException
+ */
+ private void deployServiceMetaArtifact(String artifactPath, String
fileName,
+ AxisConfiguration axisConfig) throws
DeploymentException {
+ if (!CarbonUtils.isWorkerNode()) {
+ String repo = axisConfig.getRepository().getPath();
+ String destinationPath = repo + SERVICE_META_DIR;
+ File artifactFile = new File(artifactPath);
+ InputStream in = null;
+ try {
+ in = FileUtils.openInputStream(artifactFile);
+
+ OMElement element = new
StAXOMBuilder(StAXUtils.createXMLStreamReader(in))
+ .getDocumentElement();
+ OMAttribute nameAttribute =
element.getAttribute(new QName("name"));
+ if (nameAttribute != null) {
+ String serviceGroupName =
nameAttribute.getAttributeValue();
+ if (serviceGroupName != null &&
!serviceGroupName.equals("")) {
+ File destinationFileName = new
File(destinationPath + File.separator
+ +
serviceGroupName + ".xml");
+
artifactFile.renameTo(destinationFileName);
+ log.info("Service meta named "
+ serviceGroupName + ".xml"
+ + " has been
deployed from " + artifactPath);
+ } else {
+ String msg = "Deployment of
service meta artifact failed. serviceGroup name is empty in "
+ + fileName;
+ throw new
DeploymentException(msg);
+ }
+ } else {
+ String msg = "Deployment of service
meta artifact failed. serviceGroup name not found in "
+ + fileName;
+ throw new DeploymentException(msg);
+ }
+ } catch (DeploymentException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ String msg = "Deployment of service meta
artifact failed. Error while reading "
+ + fileName;
+ throw new DeploymentException(msg);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException ex) {
+ log.error("Error while closing
input stream.", ex);
+ }
+ }
+ }
+ }
+ }
+
}
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev