Search code examples
antclassnotfoundexceptionwebsphere-8wsadminibm-was

Error while executing wsStopApp ant task unable to instantiate class com.ibm.ws.scripting.WasxShell


I am trying to execute the wsStopApp ant script of webSphere wsadmin scripts. The code is as below:

<target name="WAS_wsStopApp">
            <property name="dep_var" value="was_home" />
            <antcall target="depCheck" />
            <property name="dep_var" value="was_appname" />
            <antcall target="depCheck" />
            <taskdef name="wsStopApp" classname="com.ibm.websphere.ant.tasks.StopApplication" classpath="${was_cp}" />
            <echo message="Value of was_home is ${was_home} and classpath is ${was_cp}"/>
            <wsStopApp application="${was_appname}" user="${was_user}" password="${was_password}" failonerror="${was_failonerror}" washome="${was_home}" profileName="AppSrv03"/>
    </target>

All the properties are set properly in the properties file. The was_cp is set by the ant script as below

        <path id="was.runtime">
            <fileset dir="${was_home}/lib">
                    <include name="**/*.jar" />
            </fileset>
            <fileset dir="${was_home}/plugins">
                    <include name="**/*.jar" />
            </fileset>
            <fileset dir="${was_home}/java/jre/lib">
                    <include name="**/*.jar"/>
            </fileset>
    </path>
    <property name="was_cp" value="${toString:was.runtime}" />

I can see that it is including all the given jars in the class path. However after executing the wsStopApp target script, I am getting the below error:

[wsStopApp] profileHome=/opt/middleware/cloudapp/WebSphere/85-64/profiles/AppSrv03
[wsadmin] The IBM Class Sharing Adaptor will not work in this configuration.
[wsadmin] You are not running on a J9 Java VM.
[wsadmin] org.eclipse.core.runtime.CoreException: Plug-in "com.ibm.ws.admin.services" was unable to instantiate class com.ibm.ws.scripting.WasxShell".
[wsadmin]   at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
[wsadmin]   at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:188)
[wsadmin]   at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
[wsadmin]   at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
[wsadmin]   at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
------
------
[wsadmin] Caused by: java.lang.NoClassDefFoundError: com/ibm/CORBA/iiop/ORB
[wsadmin]     at java.lang.Class.forName0(Native Method)
[wsadmin]     at java.lang.Class.forName(Class.java:190)
[wsadmin]     at com.ibm.ws.util.PlatformHelperFactory.getBackupHelper(PlatformHelperFactory.jav:123)
[wsadmin]     at com.ibm.ws.util.PlatformHelperFactory.getPlatformHelper(PlatformHelperFactory.java:89)
[wsadmin]     at com.ibm.ws.management.AdminHelper.getPlatformHelper(AdminHelper.java:139
[wsadmin]     at com.ibm.ws.scripting.AbstractShell.<init>(AbstractShell.java:240)
[wsadmin]     at com.ibm.ws.scripting.WasxShell.<init>(WasxShell.java:200)

Could anyone please provide the resolution? The Websphere version I am using is is 8.5.


Solution

  • You need to run script with the ws_ant.bat/sh provided with your WebSphere profile. This works for me:

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="proj" default="main">
            <taskdef name="wsStopApp" classname="com.ibm.websphere.ant.tasks.StopApplication"/>
            <target name="main">
                <wsStopApp application="TestAppEAR" user="wasadmin" password="password"/>
            </target>
    </project>
    

    then call it:

    C:\IBM\WebSphere\AppServer85\profiles\AppSrv01\bin>ws_ant.bat -f stopAnt.xml
    
    Buildfile: D:\workspacePWroc\AntTest\stopAnt.xml
    
    main:
    [wsStopApp] Stopping Application [TestAppEAR]...
      [wsadmin] WASX7209I: Connected to process "server1" on node node01 using
     SOAP connector;  The type of process is: UnManagedProcess
    [wsStopApp] Stopped Application [TestAppEAR]
    
    BUILD SUCCESSFUL
    Total time: 8 seconds