[jboss-user] [Installation, Configuration & Deployment] - No Attribute found with name: PartitionName

AndrewBoyd do-not-reply at jboss.com
Tue Oct 24 09:47:08 EDT 2006


Hi All,
  I'm using JBossAS 3.2.6.  I'm getting the following exception:

  | [ServiceConfigurator] Problem configuring service jboss:service=FarmMember,partition=DefaultPartition
  | t.DeploymentException: No Attribute found with name: PartitionName
  | 
But the attribute is there.

I have created my own FarmMemberService

  | public class FarmMemberService extends URLDeploymentScanner implements FarmMemberServiceMBean
  | 

In the deploy.last I have changed the farm-service.xml.  The only thing I have changed is the value for the mbean code:

  | <server>
  |    
  |    <classpath codebase="lib" archives="jbossha.jar"/>
  |    
  |    <mbean code="net.myCo.mercury.util.FarmMemberService" name="jboss:service=FarmMember,partition=DefaultPartition" >   
  |       <depends>jboss:service=DefaultPartition</depends>    
  |    	<attribute name="PartitionName">DefaultPartition</attribute>
  |    	
  |       <depends>jboss.web:service=WebServer</depends>           
  | 
  |     <!-- Uncomment (and comment/remove version below) to enable usage of the
  |       DeploymentCache
  |     <depends optional-attribute-name="Deployer">jboss.deployment:type=DeploymentCache</depends>
  |     -->
  |     <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>
  |     
  |     
  | 
  |     <!-- The URLComparator can be used to specify a deployment ordering
  |          for deployments found in a scanned directory.  The class specified
  |          must be an implementation of java.util.Comparator, it must be able
  |          to compare two URL objects, and it must have a no-arg constructor.
  |          Two deployment comparators are shipped with JBoss:
  |            - org.jboss.deployment.DeploymentSorter 
  |              Sorts by file extension, as follows:
  |                "sar", "service.xml", "rar", "jar", "war", "wsr", "ear", "zip", 
  |                "*"
  |            - org.jboss.deployment.scanner.PrefixDeploymentSorter
  |              If the name portion of the url begins with 1 or more digits, those 
  |              digits are converted to an int (ignoring leading zeroes), and 
  |              files are deployed in that order.  Files that do not start with 
  |              any digits will be deployed last, and they will be sorted by
  |              extension as above with DeploymentSorter.
  |     -->
  |     <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute>
  |     <!--
  |     <attribute name="URLComparator">org.jboss.deployment.scanner.PrefixDeploymentSorter</attribute>
  |     -->
  | 
  |     <!-- The Filter specifies a java.io.FileFilter for scanned
  |          directories.  Any file not accepted by this filter will not be
  |          deployed.  The org.jboss.deployment.scanner.DeploymentFilter 
  |          rejects the following patterns:
  |              "#*", "%*", ",*", ".*", "_$*", "*#", "*$", "*%", "*.BAK", 
  |              "*.old", "*.orig", "*.rej", "*.bak", "*,v", "*~", ".make.state", 
  |              ".nse_depinfo", "CVS", "CVS.admin", "RCS", "RCSLOG", "SCCS", 
  |              "TAGS", "core", "tags"
  |     -->
  |     <attribute name="Filter">org.jboss.deployment.scanner.DeploymentFilter</attribute>
  | 
  |     <attribute name="ScanPeriod">5000</attribute>
  | 
  |     <!-- URLs are comma seperated and unprefixed arguments are considered
  |        file URLs and resolve relative to server home(JBOSS_DIST/server/default)
  |        unless the given path is absolute. Any referenced directories cannot
  |        be unpackaged archives, use the parent directory of the unpacked
  |        archive.
  |      -->
  |     <attribute name="URLs">
  |        farm/
  |     </attribute>
  |    </mbean>
  |    
  | </server>
  | 

As you can see there is an attribute named PartitionName:

  | <attribute name="PartitionName">DefaultPartition</attribute>
  | 

My implememtation is pretty much a cut and past from the JBoss code.  The only difference is that I removed one line that called super.farmDeploy.  I could not simply extend it because of a private member:

  | public class FarmMemberService extends URLDeploymentScanner implements FarmMemberServiceMBean{
  |     private MBeanServer mServer;
  |     protected ObjectName mClusterPartitionName = null;
  |     protected String mBackgroundPartition = "DefaultPartition";
  |     private File mTempDirectory;
  | 
  |     protected final static String SERVICE_NAME = "FarmMemberService";
  |     protected HashMap parentDUMap = new HashMap();
  | 
  |     protected ArrayList remotelyDeployed = new ArrayList();
  |     protected ArrayList remotelyUndeployed = new ArrayList();
  | 
  |     public String getPartitionName(){
  |         return mBackgroundPartition;
  |     }
  | 
  |     public void setPartitionName(String pPartitionName){
  |         if((getState() != STARTED) && (getState() != STARTING)){
  |             mBackgroundPartition = pPartitionName;
  |         }
  |     }
  | 
  |     /**
  |      * Backward compatibility, mapped to the URLs attribute of URLDeploymentScannerMBean
  |      *
  |      * @deprecated
  |      */
  |     public void setFarmDeployDirectory(String urls)
  |             throws MalformedURLException{
  |         super.setURLs(urls);
  |     }
  | 
  |     /**
  |      * Backward compatibility, but ignored as it does nothing.
  |      *
  |      * @deprecated
  |      */
  |     public void setScannerName(String name){
  |         log.warn("ScannerName does nothing");
  |     }
  | 
  |     // Service implementation ----------------------------------------
  | 
  |     public String getName(){
  |         return "Farm Member Service";
  |     }
  | 
  |     /**
  |      * Saves the MBeanServer reference, create the Farm Member Name and
  |      * add its Notification Listener to listen for Deployment / Undeployment
  |      * notifications from the MainDeployer.
  |      */
  |     public ObjectName preRegister(MBeanServer pServer, ObjectName pName)
  |             throws Exception{
  |         mServer = pServer;
  |         return super.preRegister(pServer, pName);
  |     }
  | 
  |     /**
  |      * Looks up the Server Config instance to figure out the
  |      * temp-directory and the farm-deploy-directory
  |      */
  |     protected void createService() throws Exception{
  |         super.createService();
  |         ServerConfig lConfig = ServerConfigLocator.locate();
  |         mTempDirectory = lConfig.getServerTempDir();
  | 
  |         createUnexistingLocalDir();
  |     }
  | 
  |     /**
  |      * Register itself as RPC-Handler to the HA-Partition
  |      * and add the farm deployment directory to the scanner
  |      */
  |     protected void startService()
  |             throws Exception{
  |         // scan before we enable the thread, so JBoss version shows up afterwards
  |         scannerThread.doScan();
  | 
  |         mClusterPartitionName = new ObjectName("jboss:service=" + mBackgroundPartition);
  | 
  |         log.debug("registerRPCHandler");
  |         HAPartition lHAPartition = (HAPartition) mServer.getAttribute(
  |                 mClusterPartitionName,
  |                 "HAPartition"
  |         );
  |         lHAPartition.registerRPCHandler(SERVICE_NAME, this);
  | 
  |         ArrayList response = lHAPartition.callMethodOnCluster(
  |                 SERVICE_NAME,
  |                 "farmDeployments",
  |                 new Object[]{
  |                 },
  |                 true
  |         );
  | 
  |         log.debug("Found " + response.size() + " farmDeployments responses");
  |         for(int i = 0; i < response.size(); i++){
  |             Object map = response.get(i);
  |             if(map != null && map instanceof HashMap){
  |                 HashMap farmed = (HashMap) map;
  |                 pullNewDeployments(lHAPartition, farmed);
  |             }
  |         }
  | 
  |         // enable scanner thread if we are enabled
  |         scannerThread.setEnabled(scanEnabled.get());
  |     }
  | 
  | 
  |     protected void pullNewDeployments(HAPartition partition, HashMap farmed) throws Exception{
  |         log.info("**** pullNewDeployments ****");
  |         Iterator it = farmed.keySet().iterator();
  |         while(it.hasNext()){
  |             String depName = (String) it.next();
  |             DeployedURL du = (DeployedURL) parentDUMap.get(depName);
  |             Date last = (Date) farmed.get(depName);
  |             if(du != null){
  |                 Date theLast = new Date(du.getFile().lastModified());
  |                 if(!theLast.before(last)){
  |                     continue;
  |                 }
  |             }
  |             ArrayList files = partition.callMethodOnCluster(
  |                     SERVICE_NAME,
  |                     "getFarmedDeployment",
  |                     new Object[]{
  |                             depName
  |                     },
  |                     true
  |             );
  |             for(int i = 0; i < files.size(); i++){
  |                 Object obj = files.get(i);
  |                 if(obj != null && obj instanceof FileContent){
  |                     FileContent content = (FileContent) obj;
  |                     String parentName = depName.substring(0, depName.indexOf('/'));
  |                     farmDeploy(parentName, content, last);
  |                 }
  |             }
  |         }
  |     }
  | 
  |     protected File findParent(String parentName){
  |         URL[] urls = (URL[]) urlList.toArray(new URL[]{});
  |         for(int i = 0; i < urlList.size(); i++){
  |             if(urls.getProtocol().equals("file")){
  |                 File file = new File(urls.getFile());
  |                 if(file.isDirectory()){
  |                     if(file.getName().equals(parentName)) return file;
  |                 }
  |             }
  |         }
  |         return null;
  |     }
  | 
  |     public HashMap farmDeployments(){
  |         log.debug("farmDeployments request, parentDUMap.size=" + parentDUMap.size());
  |         Iterator it = parentDUMap.keySet().iterator();
  |         HashMap farmed = new HashMap();
  |         while(it.hasNext()){
  |             String key = (String) it.next();
  |             DeployedURL du = (DeployedURL) parentDUMap.get(key);
  |             farmed.put(key, new Date(du.getFile().lastModified()));
  |         }
  |         return farmed;
  |     }
  | 
  |     public void farmDeploy(String parentName, FileContent file, Date date){
  |         try{
  |             File parent = findParent(parentName);
  |             if(parent == null){
  |                 log.info("Could not find parent: " + parentName + " for deployment: " + file + ", data: " + date);
  |                 return;
  |             }
  | 
  |             String fullName = parentName + "/" + file.mFile.getName();
  | 
  |             DeployedURL du = null;
  |             synchronized(parentDUMap){
  |                 du = (DeployedURL) parentDUMap.get(fullName);
  |             }
  |             log.info("DeployedURL : "+du);
  |             boolean deployIt = false;
  |             if(du == null){
  |                 deployIt = true;
  |             } else{
  |                 Date lastChanged = new Date(du.getFile().lastModified());
  |                 deployIt = lastChanged.before(date);
  |             }
  |             log.info("deployIt : "+deployIt);
  |             if(deployIt){
  |                 // we remember this deployment to avoid recursive farm calls!
  |                 //
  |                 synchronized(remotelyDeployed){
  |                     remotelyDeployed.add(fullName);
  |                 }
  | 
  |                 // Create File locally and use it
  |                 File lFile = new File(mTempDirectory, file.mFile.getName());
  |                 FileOutputStream lOutput = new FileOutputStream(lFile);
  |                 lOutput.write(file.mContent);
  |                 lOutput.close();
  |                 log.info("farmDeployment(), deploy locally: " + lFile);
  |                 // Adjust the date and move the file to /farm
  |                 // but delete it first if already there
  |                 File lFarmFile = new File(parent, file.mFile.getName());
  |                 if(lFarmFile.exists()){
  |                     lFarmFile.delete();
  |                 }
  |                 lFile.setLastModified(date.getTime());
  |                 lFile.renameTo(lFarmFile);
  |             } else{
  |                 log.info(file.mFile.getName() + " is already deployed by farm service on this node");
  |             }
  |         }
  |         catch(Exception e){
  |             logException(e);
  |         }
  |     }
  | 
  |     public void farmUndeploy(String parentName, String fileName){
  |         try{
  |             // First check if file is already deployed
  |             log.info("doUndeployment(), File: " + parentName + "/" + fileName);
  |             File parent = findParent(parentName);
  |             if(parent == null){
  |                 log.info("Could not find parent: " + parentName + " for undeployment: " + fileName);
  |                 return;
  |             }
  |             File deployed = new File(parent, fileName);
  |             if(deployed.exists()){
  |                 // we remember this undeployment to avoid recursive farm calls!
  |                 //
  |                 synchronized(remotelyUndeployed){
  |                     String fullName = parentName + "/" + fileName;
  |                     remotelyUndeployed.add(fullName);
  |                 }
  | 
  |                 deployed.delete();
  |                 log.info("farmUndeployment(), removed file" + deployed);
  |             } else{
  |                 log.info("Deployed file : " + deployed.getAbsoluteFile() +
  |                          " does not exist");
  |             }
  |         }
  |         catch(Exception e){
  |             logException(e);
  |         }
  |     }
  | 
  |     protected FileContent getFileContent(File pFile){
  |         InputStream lInput = null;
  |         try{
  |             // Create File ByteArray
  |             byte[] lBuffer = new byte[ 1024 ];
  |             lInput = new FileInputStream(pFile);
  |             ByteArrayOutputStream lOutput = new ByteArrayOutputStream();
  |             int j = 0;
  |             while((j = lInput.read(lBuffer)) > 0){
  |                 lOutput.write(lBuffer, 0, j);
  |             }
  |             return new FileContent(pFile, lOutput.toByteArray());
  |         }
  |         catch(java.io.FileNotFoundException fnfe){
  |             logException(fnfe);
  |         }
  |         catch(IOException ioe){
  |             logException(ioe);
  |         }
  |         finally{
  |             try{
  |                 lInput.close();
  |             } catch(Exception ignored){
  |             }
  |         }
  |         return null;
  |     }
  | 
  | 
  |     public FileContent getFarmedDeployment(String depName){
  |         try{
  |             DeployedURL du = (DeployedURL) parentDUMap.get(depName);
  |             File file = du.getFile();
  |             return getFileContent(file);
  |         }
  |         catch(Exception ex){
  |             logException(ex);
  |         }
  |         return null;
  |     }
  | 
  |     // removed the super.deploy(du) so that it doesn't expect a jar file.
  |     protected void deploy(final DeployedURL du){
  |         File file = du.getFile();
  |         File parent = file.getParentFile();
  |         log.info("file : " + file +
  |                  " parent file : " + parent);
  |         if(parent == null) return;
  | 
  |         String fullName = parent.getName() + "/" + file.getName();
  |         synchronized(parentDUMap){
  |             parentDUMap.put(fullName, du);
  |         }
  | 
  |         if(getState() == STARTING) return;
  | 
  |         try{
  |             // We check if we must do a remote call or not: maybe the deploy
  |             // is already the consequence of a farm call! (avoid recusivity!)
  |             //
  |             boolean consequenceOfRemoteCall = false;
  |             synchronized(remotelyDeployed){
  |                 consequenceOfRemoteCall = remotelyDeployed.remove(fullName);
  |             }
  | 
  |             if(!consequenceOfRemoteCall){
  |                 FileContent fileContent = getFileContent(file);
  |                 Date fileDate = new Date(file.lastModified());
  |                 HAPartition haPartition = (HAPartition) mServer.getAttribute(mClusterPartitionName, "HAPartition");
  |                 haPartition.callMethodOnCluster(SERVICE_NAME, "farmDeploy",
  |                                                  new Object[]{parent.getName(), fileContent, fileDate},
  |                                                  true);
  |             }
  |         }
  |         catch(Exception ex){
  |             logException(ex);
  |         }
  |     }
  | 
  |     protected void undeploy(final DeployedURL du){
  | 
  |         File file = du.getFile();
  |         File parent = file.getParentFile();
  |         String parentName = parent.getName();
  |         String fileName = file.getName();
  |         super.undeploy(du);
  | 
  |         String fullName = parent.getName() + "/" + file.getName();
  |         synchronized(parentDUMap){
  |             parentDUMap.remove(fullName);
  |         }
  | 
  |         if(getState() == STOPPING) return;
  | 
  |         try{
  |             // We check if we must do a remote call or not: maybe the undeploy
  |             // is already the consequence of a farm call! (avoid recusivity!)
  |             //
  |             boolean consequenceOfRemoteCall = false;
  |             synchronized(remotelyUndeployed){
  |                 consequenceOfRemoteCall = remotelyUndeployed.remove(fullName);
  |             }
  | 
  |             if(!consequenceOfRemoteCall){
  |                 HAPartition lHAPartition = (HAPartition) mServer.getAttribute(
  |                         mClusterPartitionName,
  |                         "HAPartition"
  |                 );
  |                 lHAPartition.callMethodOnCluster(
  |                         SERVICE_NAME,
  |                         "farmUndeploy",
  |                         new Object[]{
  |                                 parentName,
  |                                 fileName
  |                         },
  |                         true
  |                 );
  |             }
  |         }
  |         catch(Exception ex){
  |             logException(ex);
  |         }
  |     }
  | 
  |     /**
  |      * Go through the myriad of nested JMX exception to pull out the true
  |      * exception if possible and log it.
  |      *
  |      * @param e The exception to be logged.
  |      */
  |     private void logException(Throwable e){
  |         if(e instanceof javax.management.RuntimeErrorException){
  |             e = ((javax.management.RuntimeErrorException) e).getTargetError();
  |         } else if(e instanceof javax.management.RuntimeMBeanException){
  |             e = ((javax.management.RuntimeMBeanException) e).getTargetException();
  |         } else if(e instanceof javax.management.RuntimeOperationsException){
  |             e = ((javax.management.RuntimeOperationsException) e).getTargetException();
  |         } else if(e instanceof javax.management.MBeanException){
  |             e = ((javax.management.MBeanException) e).getTargetException();
  |         } else if(e instanceof javax.management.ReflectionException){
  |             e = ((javax.management.ReflectionException) e).getTargetException();
  |         }
  |         e.printStackTrace();
  |         log.error(e);
  |     }
  | 
  |     protected void createUnexistingLocalDir(){
  |         if(this.urlList != null){
  |             Iterator iter = this.urlList.iterator();
  |             while(iter.hasNext()){
  |                 URL url = null;
  |                 try{
  |                     url = (URL) iter.next();
  |                     if(url.getProtocol().equals("file")){
  |                         File targetDir = new File(url.getFile());
  |                         if(!targetDir.exists())
  |                             targetDir.mkdirs();
  |                     }
  |                 }
  |                 catch(Exception e){
  |                     log.info("Problem while creating a farm directory: " + url, e);
  |                 }
  |             }
  |         }
  |     }
  | 
  | }
  | 
As you can see I have the method getPartitionName().  

Does anyone know what I need to do to get this to worK?

Thanks,

Andrew

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3980366#3980366

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3980366



More information about the jboss-user mailing list