Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python脚本中处理wlst异常_Python_Maven_Weblogic_Wlst - Fatal编程技术网

在python脚本中处理wlst异常

在python脚本中处理wlst异常,python,maven,weblogic,wlst,Python,Maven,Weblogic,Wlst,我正在维护一个在试图删除丢失的MDS分区时被中断的构建 有东西要搬走就好了 我对这门学科不太熟悉,我也想学 拆卸前检查分区是否存在 处理错误并继续maven生命周期 问题中的pom部分是 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <v

我正在维护一个在试图删除丢失的MDS分区时被中断的构建

有东西要搬走就好了

我对这门学科不太熟悉,我也想学

  • 拆卸前检查分区是否存在
  • 处理错误并继续maven生命周期
问题中的pom部分是

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.1</version>
        <executions>
          <execution>
            <id>delete-MDS</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>${oracle.wlst}</executable>
              <arguments>
                <argument>${predeploy.script.deletemds}</argument>
                <argument>weblogic</argument>
                <argument>${adminServerPassword}</argument>
                <argument>${adminServerUrl}</argument>
                <argument>${mds.repository}</argument>
                <argument>${mds.partition}</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
当我运行它的时候

...
[INFO] Deleting MDS configuration
[INFO] Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
[INFO] For more help, use help(domainRuntime)
[INFO]
[INFO]
[INFO] Problem invoking WLST - Traceback (innermost last):
[INFO]   File "C:\Dev\trunk\<App>\<Project>\scripts\deleteMDSOnDomain.py", line 24, in ?
[INFO]   File "C:\Dev\Oracle\MIDDLE~1\ORACLE~1\common\wlst\mdsWLSTCommands.py", line 471, in deleteMetadataPartition
[INFO]   File "C:\Dev\Oracle\MIDDLE~1\ORACLE~1\common\wlst\mdsWLSTCommands.py", line 836, in executeDomainRuntimeMBeanOperation
[INFO]   File "C:\Dev\Oracle\MIDDLE~1\ORACLE~1\common\wlst\mdsWLSTCommands.py", line 1097, in saveStackAndRaiseException
[INFO] WLSTException: MDS-00555: The partitionName <App> is invalid.
[INFO] ORA-01403: no data found
[INFO] ORA-06512: at "<env>_MDS.MDS_INTERNAL_SHREDDED", line 580
[INFO] ORA-06512: at line 1
[INFO]  MDS-91009: Operation "deleteMetadataPartition" failure. Use dumpStack() to view the full stacktrace.
[INFO]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Result of cmd.exe /X /C "C:\Dev\Oracle\Middleware\oracle_common\common\bin\wlst.cmd scripts/deleteMDSOnDomain.py weblogic <pass> <url> mds-CustomPortalDS <App>" execution is: '1'.
[INFO] ------------------------------------------------------------------------
。。。
[信息]删除MDS配置
[信息]位置已更改为domainRuntime树。这是一个以DomainMBean为根的只读树。
[信息]有关更多帮助,请使用帮助(domainRuntime)
[信息]
[信息]
[信息]调用WLST时出现问题-回溯(最里面的最后一个):
[信息]文件“C:\Dev\trunk\\\scripts\deleteMDSOnDomain.py”,第24行,在中?
[信息]文件“C:\Dev\Oracle\MIDDLE~1\Oracle~1\common\wlst\mdsWLSTCommands.py”,第471行,在deleteMetadataPartition中
[INFO]文件“C:\Dev\Oracle\MIDDLE~1\Oracle~1\common\wlst\mdswlstcomands.py”,第836行,在ExecutedOMainRuntimeBean操作中
[INFO]文件“C:\Dev\Oracle\MIDDLE~1\Oracle~1\common\wlst\mdsWLSTCommands.py”,第1097行,位于saveStackAndRaiseException中
[信息]WLSTException:MDS-00555:分区名称无效。
[信息]ORA-01403:未找到任何数据
【信息】ORA-06512:第580行“内部切碎”
[信息]ORA-06512:第1行
[信息]MDS-91009:操作“deleteMetadataPartition”失败。使用dumpStack()查看完整的堆栈跟踪。
[信息]
[信息]------------------------------------------------------------------------
[错误]生成错误
[信息]------------------------------------------------------------------------
[INFO]cmd.exe/X/C“C:\Dev\Oracle\Middleware\Oracle\u common\common\bin\wlst.cmd scripts/deleteMDSOnDomain.py weblogic mds CustomPortalDS”执行的结果是:“1”。
[信息]------------------------------------------------------------------------
似乎wlst结果“1”已传播到maven,例如,我的py catch未完全处理该结果-我可以手动将其更改为“0,ok”吗

编辑:打字错误

一切都很好。下一步尝试取消部署应用程序的另一个插件会引发此错误。注意到后才意识到

[INFO] [Deployer:149001]No application named '<app>' exists for operation undeploy.
[INFO][Deployer:1499001]不存在用于取消部署操作的名为“”的应用程序。
我可以发誓它以前不在那里。。。无论如何,在下面的答案中,我也得到了一些代码来检查分区是否存在。

我更像是一个程序员,因此下面是我在删除MDS分区以首先检查它们是否存在时使用的一些WLST。不幸的是,您不得不求助于直接访问MDSDomainRuntime mBean,因为有人忘记了在WLST中公开listPartitions方法

from org.python.modules import jarray
from javax.management import ObjectName, Attribute

#skipped mapping input to variables here

connect(username, password, url)

domainRuntime()

mdsName = ObjectName('oracle.mds.lcm:name=MDSDomainRuntime,type=MDSDomainRuntime')
beans = mbs.queryMBeans(mdsName, None)

if (beans.size() == 0):
    # This _should_ be impossible
    raise Exception("Could not find mbean '%s' in the current tree '%s'." % (mdsName, pwd()))

beanName = beans.iterator().next().getObjectName()
params = jarray.array([mdsRepository], java.lang.Object) 
signature = ['java.lang.String']  
partitions = mbs.invoke(beanName, "listPartitions", params, signature)  

if (mdsPartition not in partitions):  
    print("Partition '%s' does not exist in repository '%s'." % (mdsPartition, mdsRepository))
else:
    params = jarray.array([mdsRepository, mdsPartition], java.lang.Object)
    signature = jarray.array(['java.lang.String','java.lang.String'], java.lang.String)
    mbs.invoke(beanName, 'deleteMetadataPartition', params, signature)
    print("Partition '%s' deleted from repository '%s'." % (mdsPartition, mdsRepository))

看来你应该抓住错误了。
deleteMataPartition
看起来像什么?您可以调用
exit()
,它将在脚本末尾默认为0。不幸的是,deleteMetadataPartition是专有的魔术
from org.python.modules import jarray
from javax.management import ObjectName, Attribute

#skipped mapping input to variables here

connect(username, password, url)

domainRuntime()

mdsName = ObjectName('oracle.mds.lcm:name=MDSDomainRuntime,type=MDSDomainRuntime')
beans = mbs.queryMBeans(mdsName, None)

if (beans.size() == 0):
    # This _should_ be impossible
    raise Exception("Could not find mbean '%s' in the current tree '%s'." % (mdsName, pwd()))

beanName = beans.iterator().next().getObjectName()
params = jarray.array([mdsRepository], java.lang.Object) 
signature = ['java.lang.String']  
partitions = mbs.invoke(beanName, "listPartitions", params, signature)  

if (mdsPartition not in partitions):  
    print("Partition '%s' does not exist in repository '%s'." % (mdsPartition, mdsRepository))
else:
    params = jarray.array([mdsRepository, mdsPartition], java.lang.Object)
    signature = jarray.array(['java.lang.String','java.lang.String'], java.lang.String)
    mbs.invoke(beanName, 'deleteMetadataPartition', params, signature)
    print("Partition '%s' deleted from repository '%s'." % (mdsPartition, mdsRepository))