8 Replies Latest reply on Jul 9, 2020 1:32 PM by user13313952

    Initiate java main(jar in WLS) from local

    user13313952

      Need pointers to initiate the main method (jar file with java class) which is deployed/installed to web logic server, from my local. This is not a web application.

      Guide me, If i have to write any scripts, that do not need major installations or configurations or licensing.

        • 1. Re: Initiate java main(jar in WLS) from local
          Martien van den Akker

          HI,

          It's not clear to me what you want to achieve. If you want to start an application using a main method, then you don't have to deploy it Weblogic.

          Do you mean a custom application that is deployed to Weblogic, or do you want to start weblogic your self?

           

          Kind regards,
          Martien

          • 2. Re: Initiate java main(jar in WLS) from local
            user13313952

            Thanks for your response.

            It is a custom core java code which i am currently running it from my JDeveloper, as needed. It is doing bunch of stuff like DB interation, custom logic etc, doing its stuff in different environment. But i wrapped that in a scheduler so it runs every 5 mins as long as my jdev is up and running. Its a dependency which i want to get rid off and put it in the WLS where the server is mostly uninterrupted. However, you still may have to invoke it from external rt. which is ok, as long as me or any admin will initiate it.

            Can be on server start up script or otherwise.

            • 3. Re: Initiate java main(jar in WLS) from local
              Martien van den Akker

              Hi,

               

              If you run it from JDev, then JDev will create a command output window where it shows the command it runs including the class path. You could get that command, put it in a command file (.cmd or .sh, depending on OS) and adapt the classpath to refer the libraries on the weblogic server.

              Since you moved it from Jdev to Weblogic, I presume that you don't use datasources, but create your jdbc connections your self. So that wouldn't be a big problem, I guess, unless you do use Weblogic datasources. In that case you need to connect to Weblogic to get the datasources using JNDI within a WLS context. That's different cake.

               

              But actually, you moved your app from JDeveloper to Weblogic to get independend scheduling. You could just run it incidentaly using JDeveloper as you did before, can't you?

               

              However, I find this a bit strange. The thing with Weblogic is that you have a highly scalable, multi-user, enterprise applicatoin server, where you run your application to have it scheduled. Why don't you build a relatively simple maintance app, for instance using a simple set of JSP's, or maybe even a rest service, that you can call? If you create a REST service that triggers the application, you could simple JavaScript app, for instance using OracleJET to trigger it. I think it's very much worth the effort.

               

              Kind regards,
              Martien

              • 4. Re: Initiate java main(jar in WLS) from local
                user13313952

                Martien,

                 

                Which .cmd file do i add the command to? setDomainEnv.cmd or startWebLogic.cmd ?

                 

                And where exactly in the file do i need to specify, there are many parameters in there? My command looks as below and i have a windows machine:-

                 

                java -server -classpath C:\JDeveloper\mywork\Application3\.adf;C:\JDeveloper\mywork\Ind\Sec\classes;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\JUnit\junit-4.10.jar;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\ojdbc8.jar;C:\oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\commons-codec-1.8.jar; com.sec.sched.ExecTimer

                 

                Also, i have budled the .class and source files into a jar and placed them in this location:- C:\Users\usr\AppData\Roaming\JDeveloper\system12.2.1.1.42.160607.2047\DefaultDomain\lib\ApiSched.jar

                 

                ApiSched.jar has the main method in this com.sec.sched.ExecTimer class

                 

                Appreciate your response

                • 5. Re: Initiate java main(jar in WLS) from local
                  user13313952

                  Also should i copy all the other jar files that are in the above command to the domain_home lib folder (C:\Users\usr\AppData\Roaming\JDeveloper\system12.2.1.1.42.160607.2047\DefaultDomain\lib\) ? Because those jars are pointing to my local folder.

                   

                  Also, how will i refer my class from the jar, because now i will eliminate these 2(C:\JDeveloper\mywork\Application3\.adf;C:\JDeveloper\mywork\Ind\Sec\classes;) from the command?

                   

                  And when i tried with below command, i got the error (Error: Could not find or load main class)

                   

                  java -server -classpath -jar C:\_buildJar\NychaSecApiSched.jar;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\JUnit\junit-4.10.jar;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\ojdbc8.jar;C:\oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\commons-codec-1.8.jar; com.sec.sched.ExecTimer

                   

                  by the way , i was trying them from my local command prompt, how do i access the WLS servers command prompt?

                  • 6. Re: Initiate java main(jar in WLS) from local
                    Martien van den Akker

                    Hi

                    The setDomainEnv.cmd is called from the startWebLogic.cmd. They start weblogic itself. It makes no sense (to me) to put your command in there.

                    Side note: in 12c you should not edit those files, but create a setUserOverrides.cmd file and put your customizations in there. If the file exists it will be executed.

                     

                    In your case I think you should create another command file, to call your application separately from Weblogic.

                     

                    I miss your ApiSchec.jar in the class path of:

                    java -server -classpath C:\JDeveloper\mywork\Application3\.adf;C:\JDeveloper\mywork\Ind\Sec\classes;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\JUnit\junit-4.10.jar;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\ojdbc8.jar;C:\oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar;C:\Users\usr\view\eco\Soa12C\Applications\Intg\Repository\libs\commons-codec-1.8.jar; com.sec.sched.ExecTimer

                    This is because I assume that the classes of this jar are in C:\JDeveloper\mywork\Ind\Sec\classes; so you could replace that part with your jar file.

                     

                    Kind regards,
                    Martien

                    • 7. Re: Initiate java main(jar in WLS) from local
                      Martien van den Akker

                      See my previous answer first...