wood burning stoves 2.0*
The moose likes BEA/Weblogic and the fly likes start weblogic server within java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "start weblogic server within java code" Watch "start weblogic server within java code" New topic
Author

start weblogic server within java code

Kevin Huang
Greenhorn

Joined: Mar 27, 2004
Posts: 13
From edoc.bea.com, I got:

====
...
The following sections describe alternate ways to start an Administration Server:

Starting an Administration Server from the Windows Start Menu
Starting an Administration Server When the Host Computer Boots
Starting an Administration Server With the java weblogic.Server Command
...
====

Could we start weblogic server with java code?
Something like ServerLoader provided by JBoss?

Thanks in advance.

-Kevin
Annie Smith
Ranch Hand

Joined: Mar 05, 2005
Posts: 172
Originally posted by Kevin Huang:

Could we start weblogic server with java code?


You could make use of Runtime.exec() and call the script. But be sure you read this before: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Alternatively, you could write a code which does the same thing as the startup script.


Cheers!<br /><b>Annie</b>
Annie Smith
Ranch Hand

Joined: Mar 05, 2005
Posts: 172
Of course, I have some doubts about how this would be of some use.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18496
    
  40

The weblogic.Server command is a Java class. Another option is to build the arguments manually, and call the main() method of the weblogic.Server class. Just don't forget to add the correct weblogic jar into your classpath.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Kevin Huang
Greenhorn

Joined: Mar 27, 2004
Posts: 13
Thanks.

-Kevin
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
In the weblogic.Server command can you give interactively username,password,portnumber .
when you provide these the weblogicserver should be started
if so tellme how to do this
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18496
    
  40

Originally posted by pvsr rao:
In the weblogic.Server command can you give interactively username,password,portnumber .
when you provide these the weblogicserver should be started
if so tellme how to do this


Calling the weblogic.server class directly is an alternate way to start weblogic. Kevin is doing it this way because he wants to start it programmatically from Java.

In your case, why are you considering it, instead of using the standard scripts?

Henry
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
i have the situation like this.
i have gui which contains textfields,label and button
in different textfields you should enter domainname,servername,username,password
and when you click a button named create it should automatically starts a server with specified domainname,servername,config.xml name ,password and username.please tell me how can we do it
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Originally posted by pvsr rao:
i have the situation like this.
i have gui which contains textfields,label and button
in different textfields you should enter domainname,servername,username,password
and when you click a button named create it should automatically starts a server with specified domainname,servername,config.xml name ,password and username.please tell me how can we do it


You can use the Ant task from your java program to start the WLS.

This is the workaround not the solution.

As far as I know When WLS will starts up it also start the DEBUGGER, PointBase, Portal Search Engine. apart from this it will initilize the classpath varibale with the requried jars files.

you can call classes of Ant task into your java program.

http://forum.java.sun.com/thread.jspa?threadID=650552&messageID=3826282
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
we should not use any ant task.from the java program when i give the domainname,servername,username,password etc,weblogicserver should be started with specified parameters.please tell me how to do it
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
can we do like this to start weblogicserver from java program

public class serv
{
public void main(String args[])
{
try
{
Class.forName("weblogic.Server");
Runtime r=Runtime.getRuntime();
Process p=null;


//p=r.exec(s.main(new String[]{}));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
if not please send me how to do this
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18496
    
  40

IMO, directly calling the main method of the weblogic.Server class should only be done, if you are doing simple setup, and then handing off control to the class.

Otherwise, I suggest that you exec "startWeblogic.???" script that was generated for your domain. Just figure out how you would do it from the command line, and exec() the same command from java.

BTW, I don't mean to seem dodgy, but the location of the script is dependent on how the domain is configured. And how the script works is dependent on the version of Weblogic that you are using.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: start weblogic server within java code
 
Similar Threads
Starting Weblogic in MyEclipse
Getting error while starting weblogic 10.3 server from start\programs\oraweblogic\....
Weblogic 8.1.4.0 startup problem (classpath)
Dubug issue in Weblogic
please answer this 128 questions for WLS. Urgently!