Search code examples
weblogicweblogic12cwlst

Creating Portable Weblogic Scripting Tool


I want to create WLST to do scripting in my server because I don't have the access to the wlst.sh. I used the WLST to execute a script that deploy a war file. When I execute it with:

java -cp $(echo lib/*.jar | tr ' ' ':') -Dprod.props.file=lib/props.txt -Dbea.home= -Dweblogic.home=/drives/app/wlst weblogic.WLST /drives/app/wlst/deploy.py

I can deploy my war file (the script is working), but it shows error before and after it execute the script.

This question is similiar too this, but since the question is already answered and seems outdated (I use Weblogic 12.2.1.3.0) I ask this question.

The module I included are:

    ├── lib
    │   ├── com.bea.core.xml.xmlbeans_1.0.0.0_2-6-0-12.1.3-0-0.jar
    │   ├── com.oracle.cie.comdev_7.8.2.0.jar
    │   ├── com.oracle.cie.config_8.6.0.0.jar
    │   ├── com.oracle.cie.config-owsm_8.6.0.0.jar
    │   ├── com.oracle.cie.config-security_8.6.0.0.jar
    │   ├── com.oracle.cie.config-wls_8.6.0.0.jar
    │   ├── com.oracle.cie.config-wls-schema_8.6.0.0.jar
    │   ├── com.oracle.cie.dependency_1.8.2.0.jar
    │   ├── com.oracle.cie.encryption_2.6.0.0.jar
    │   ├── com.oracle.cie.service-table_1.6.0.0.jar
    │   ├── com.oracle.cie.wizard_7.8.2.0.jar
    │   ├── com.oracle.core.weblogic.msgcat-12.2.1-3-0.jar
    │   ├── com.oracle.glcm.encryption_2.7.2.0.jar
    │   └── jython-modules.jar
    │   └── weblogic.jar
    │   └── wlfullclient.jar

This is the error I get it execute my script:

java.lang.ClassNotFoundException: com.oracle.cie.gdr.external.InventoryFactory
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.oracle.cie.common.ReflectionHelper.process(ReflectionHelper.java:43)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.init(EnvironmentServiceImpl.java:384)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.<init>(EnvironmentServiceImpl.java:89)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.getInstance(EnvironmentServiceImpl.java:364)
        at com.oracle.cie.domain.env.EnvironmentServiceFactory.getEnvironmentService(EnvironmentServiceFactory.java:35)
        at com.oracle.cie.domain.env.EnvironmentServiceFactory.getEnvironmentService(EnvironmentServiceFactory.java:72)
        at com.oracle.cie.domain.script.jython.WLScriptContext.init(WLScriptContext.java:303)
        at com.oracle.cie.domain.script.jython.WLScriptContext.setup(WLScriptContext.java:270)
        at com.oracle.cie.domain.script.jython.WLST_offline.setupContext(WLST_offline.java:46)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at weblogic.management.scripting.utils.WLSTUtil.initOfflineContext(WLSTUtil.java:514)
        at weblogic.management.scripting.utils.WLSTUtil.setupOfflineInternal(WLSTUtil.java:488)
        at weblogic.management.scripting.utils.WLSTUtil.setupOffline(WLSTUtil.java:361)
        at weblogic.management.scripting.utils.WLSTUtilWrapper.setupOffline(WLSTUtilWrapper.java:29)
        at weblogic.management.scripting.utils.WLSTInterpreter.<init>(WLSTInterpreter.java:250)
        at weblogic.management.scripting.WLST.main(WLST.java:134)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at weblogic.WLST.main(WLST.java:47)

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at weblogic.management.scripting.utils.WLSTUtil.initOfflineContext(WLSTUtil.java:514)
        at weblogic.management.scripting.utils.WLSTUtil.setupOfflineInternal(WLSTUtil.java:488)
        at weblogic.management.scripting.utils.WLSTUtil.setupOffline(WLSTUtil.java:361)
        at weblogic.management.scripting.utils.WLSTUtilWrapper.setupOffline(WLSTUtilWrapper.java:29)
        at weblogic.management.scripting.utils.WLSTInterpreter.<init>(WLSTInterpreter.java:250)
        at weblogic.management.scripting.WLST.main(WLST.java:134)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at weblogic.WLST.main(WLST.java:47)
Caused by: java.lang.IllegalStateException: com.oracle.cie.domain.env.EnvironmentServiceException: Failed to get inventory for /drives
        at com.oracle.cie.domain.script.jython.WLScriptContext.init(WLScriptContext.java:353)
        at com.oracle.cie.domain.script.jython.WLScriptContext.setup(WLScriptContext.java:270)
        at com.oracle.cie.domain.script.jython.WLST_offline.setupContext(WLST_offline.java:46)
        ... 15 more
Caused by: com.oracle.cie.domain.env.EnvironmentServiceException: Failed to get inventory for /drives
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.init(EnvironmentServiceImpl.java:425)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.<init>(EnvironmentServiceImpl.java:89)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.getInstance(EnvironmentServiceImpl.java:364)
        at com.oracle.cie.domain.env.EnvironmentServiceFactory.getEnvironmentService(EnvironmentServiceFactory.java:35)
        at com.oracle.cie.domain.env.EnvironmentServiceFactory.getEnvironmentService(EnvironmentServiceFactory.java:72)
        at com.oracle.cie.domain.script.jython.WLScriptContext.init(WLScriptContext.java:303)
        ... 17 more
Caused by: java.lang.ClassNotFoundException: com.oracle.cie.gdr.external.InventoryFactory
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.oracle.cie.common.ReflectionHelper.process(ReflectionHelper.java:43)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.init(EnvironmentServiceImpl.java:384)
        ... 22 more
Error execing the Python script "/drives/app/wlst/lib/wlfullclient.jar!/wlstScriptDir/jrf_mt_provisioning_cli.py" caused an error "Traceback (innermost last):
  File "/drives/app/wlst/lib/wlfullclient.jar!/wlstScriptDir/jrf_mt_provisioning_cli.py", line 19, in ?
ImportError: no module named lifecycle
"
Error execing the Python script "/drives/app/wlst/lib/wlfullclient.jar!/wlstScriptDir/coh_persistence.py" caused an error "Traceback (innermost last):
  File "/drives/app/wlst/lib/wlfullclient.jar!/wlstScriptDir/coh_persistence.py", line 14, in ?
ImportError: no module named datagrid
"

And this is the error I get after it execute my script:

SEVERE: Failed to get inventory for /drives
java.lang.ClassNotFoundException: com.oracle.cie.gdr.external.InventoryFactory
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.oracle.cie.common.ReflectionHelper.process(ReflectionHelper.java:43)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.init(EnvironmentServiceImpl.java:384)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.<init>(EnvironmentServiceImpl.java:89)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.getInstance(EnvironmentServiceImpl.java:364)
        at com.oracle.cie.domain.env.EnvironmentServiceFactory.getEnvironmentService(EnvironmentServiceFactory.java:35)
        at com.oracle.cie.domain.env.EnvironmentServiceFactory.getEnvironmentService(EnvironmentServiceFactory.java:72)
        at com.oracle.cie.domain.script.jython.WLScriptContext.init(WLScriptContext.java:303)
        at com.oracle.cie.domain.script.jython.WLScriptContext.setup(WLScriptContext.java:270)
        at com.oracle.cie.domain.script.jython.WLST_offline.setupContext(WLST_offline.java:46)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at weblogic.management.scripting.utils.WLSTUtil.initOfflineContext(WLSTUtil.java:514)
        at weblogic.management.scripting.utils.WLSTUtil.setupOfflineInternal(WLSTUtil.java:488)
        at weblogic.management.scripting.utils.WLSTUtil.setupOffline(WLSTUtil.java:361)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.PyObject.invoke(Unknown Source)
        at org.python.pycode._pyx24.disconnect$2(<iostream>:140)
        at org.python.pycode._pyx24.call_function(<iostream>)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyFunction.__call__(Unknown Source)
        at org.python.pycode._pyx23.f$0(/drives/app/wlst/deploy.py:25)
        at org.python.pycode._pyx23.call_function(/drives/app/wlst/deploy.py)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.Py.runCode(Py.java:1226)
        at org.python.util.PythonInterpreter.execfile(Unknown Source)
        at weblogic.management.scripting.WLST.main(WLST.java:186)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at weblogic.WLST.main(WLST.java:47)

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at weblogic.management.scripting.utils.WLSTUtil.initOfflineContext(WLSTUtil.java:514)
        at weblogic.management.scripting.utils.WLSTUtil.setupOfflineInternal(WLSTUtil.java:488)
        at weblogic.management.scripting.utils.WLSTUtil.setupOffline(WLSTUtil.java:361)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.PyObject.invoke(Unknown Source)
        at org.python.pycode._pyx24.disconnect$2(<iostream>:140)
        at org.python.pycode._pyx24.call_function(<iostream>)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyFunction.__call__(Unknown Source)
        at org.python.pycode._pyx23.f$0(/drives/app/wlst/deploy.py:25)
        at org.python.pycode._pyx23.call_function(/drives/app/wlst/deploy.py)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.Py.runCode(Py.java:1226)
        at org.python.util.PythonInterpreter.execfile(Unknown Source)
        at weblogic.management.scripting.WLST.main(WLST.java:186)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at weblogic.WLST.main(WLST.java:47)
Caused by: java.lang.IllegalStateException: com.oracle.cie.domain.env.EnvironmentServiceException: Failed to get inventory for /drives
        at com.oracle.cie.domain.script.jython.WLScriptContext.init(WLScriptContext.java:353)
        at com.oracle.cie.domain.script.jython.WLScriptContext.setup(WLScriptContext.java:270)
        at com.oracle.cie.domain.script.jython.WLST_offline.setupContext(WLST_offline.java:46)
        ... 33 more
Caused by: com.oracle.cie.domain.env.EnvironmentServiceException: Failed to get inventory for /drives
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.init(EnvironmentServiceImpl.java:425)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.<init>(EnvironmentServiceImpl.java:89)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.getInstance(EnvironmentServiceImpl.java:364)
        at com.oracle.cie.domain.env.EnvironmentServiceFactory.getEnvironmentService(EnvironmentServiceFactory.java:35)
        at com.oracle.cie.domain.env.EnvironmentServiceFactory.getEnvironmentService(EnvironmentServiceFactory.java:72)
        at com.oracle.cie.domain.script.jython.WLScriptContext.init(WLScriptContext.java:303)
        ... 35 more
Caused by: java.lang.ClassNotFoundException: com.oracle.cie.gdr.external.InventoryFactory
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.oracle.cie.common.ReflectionHelper.process(ReflectionHelper.java:43)
        at com.oracle.cie.domain.env.EnvironmentServiceImpl.init(EnvironmentServiceImpl.java:384)
        ... 40 more

My other reference is this thread.

My question is, is it possible to solve this error? I know that the error didn't impact my script, but it would be nice to remove this error. I was thinking maybe I miss some module to include, but I can't figure out what's the module I'm looking for.


Solution

  • When you do lock and edit it creates a nonexclusive lock to the domain and same can be achieved with command line as below:

    Generate a client jar from weblogic using below:

    Change directories to the server/lib directory.

    cd WL_HOME/server/lib
    

    Use the following command to create wlfullclient.jar in the server/lib directory:

    java -jar ../../modules/com.bea.core.jarbuilder_X.X.X.X.jar
    

    where X.X.X.X is the version number of the jarbuilder module in the WL_HOME/server/lib directory. For example:

    java -jar ../../../modules/com.bea.core.jarbuilder_1.0.1.0.jar
    

    You can now copy and bundle the wlfullclient.jar with client applications. Add the wlfullclient.jar to the client application’s classpath.

    once this is done use the below command to automate the deployment:

    export CLASSPATH='location where your client jar resides'
    java -cp $CLASSPATH weblogic.Deployer -adminurl ADMIN_URL:PORT -username weblogic -password weblogic1! -deploy app.war -name appname -targets AdminServer -debug - usenonexclusivelock