Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

start weblogic server within java code

 
Kevin Huang
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Annie Smith
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, I have some doubts about how this would be of some use.
 
Henry Wong
author
Marshal
Pie
Posts: 20995
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kevin Huang
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

-Kevin
 
pvsr rao
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20995
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20995
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic