你的EJB在WLS700下是怎么部署的?贴出来看看

解决方案 »

  1.   


    jbuilder7自动生成home,remote,bean,添加代码,然后编译,生产。jar文件。右键点击鼠标选择deploy发布,发布成功后,新建一个test client,jbuilder会生产连接到ejb得代码,然后你就可以象使用普通类一样使用client类。
    完全配置JBuilder7和Weblogic7  
    作者:chenying     发表时间:2002/08/06 05:30pm
     
    JBuilder7和Weblogic7都出来了,在这里记录了一些配置过程,希望对大家有帮助
    :)
    假设将Weblogic7安装在c:/bea
    <一>Weblogic7
    安装略,
    配置选择菜单中的Configuration Wizard就可以进行配置了1.Select a template:选择WLS Domain,Name默认的mydomain
    2.Choose Server Type: Managed Server(...)最长的
    3.Specify directory for "mydomain" domain:C:\bea\user_projects\
    4.Value Administrative Server Info-Admin Server Name or IP 写机器的ip就可以了,其它的默认值即可
    5.Configure Managed Server: 
     <1> Server Name:默认为myserver,我这里是默认的
     <2> Server Listen Address:写机器的ip .其它的默认
    6.Create System UserName and Password:写用户名和密码,随便写了
    7.Install Server as Windows Servic:这里问要不要在启动操作系统时启动,可根据自己的需用选择。
    8.Install Domain in Windows Start Menu:这里问要不要在开始菜单添加快捷方式,建议是“Yes”.这样在开始菜单中会出现EBA Weblogic Platform 7.0-User projects-my domain-Start Server

    <二>JBuiler7
    1.Tools-Configure Servers
    选择Weblogic Application Server 6.x+后,选择Enable server,使标签的选项为可编辑的。
     A、General标签
    <1> Home directory : C:/bea/weblogic700/server
    <2> Main class: weblogic.Server
    <3> VM paramenters:-ms64m -mx64m    -Djava.library.path=C:/bea/weblogic700/server/bin    -Dbea.home=C:/bea -Dweblogic.Domain=mydomain    -Dweblogic.Name=myserver    -Djava.security.policy==C:/bea/weblogic700/server/lib/weblogic.policy    -Dweblogic.management.discover=false    -Dweblogic.ProductionModeEnabled=false    
    -Dweblogic.management.username=admin -Dweblogic.management.password=password
        Main class和VM paramenters在选择Home directory后系统自动给出(总之不用自己填)
     <4> Working directory:C:/bea/user_projects/mydomain
         即使不将weblogic安装到c盘,系统也会创建c:/bea的。
         mydomain是在weblogic中创建的名称。
    B、Custom标签
     <1> JDK installation directory: C:/bea/jdk131_02(系统在c盘自建的)
     <2> BEA home directory: C:/bea(同上)
     <3> Domain diredtory : C:/bea/user_projects/mydomain(同上)
     <4> User name 和 Password :是weblogic的用户名和密码
     <5> Domain name 、Server name、 Version 都是默认的就可以了,例如mydomain,myserver,7.0(C:/bea/weblogic700)2、Tools-Enterprise Setup
     A、CORBA标签 
     在Configuration中,选择new
     <1>Name for this configuaration:随便写,在这里我写的是weblogic
     <2>Path for ORB tools: C:/bea/weblogic700/server/bin
     <3>Library for projects: WebLogic 6.x+ Deploy ,Path for ORB tools写对了,这个选一下就好了。
     <4>IDL compiler command: idlj.exe
     <5>Command option for output directory: 随便一个存在的文件夹就可以了,当然最好所在的磁盘空间越大越好。3、Project-Default Project Properties
     主要是server 标签
     选择Single server for all services in project ,选择WebLogic Application Server 6.x+就可以了。就写到这了........... 
     
      

  2.   

    不好意思,刚才忘了发布了,不过现在这个错误就是我一开始说的那个错误。
    部署是成功的,现在又出现了另一个错误。
    就是说在client中找不到create()和sayhello()方法!
    我把代码列一下:
    //hello.java
    package Hellodemo;
    import javax.ejb.*;
    import java.util.*;
    import java.rmi.*;public interface Hello extends javax.ejb.EJBObject {
     public String SayHello() throws RemoteException;
    }//HelloHome.java
    package hellodemo;import javax.ejb.*;
    import java.util.*;
    import java.rmi.*;public interface HelloHome extends javax.ejb.EJBHome {
     public Hello create() throws CreateException, RemoteException;
    }//HelloBean.java
    package hellodemo;import javax.ejb.*;public class HelloBean implements SessionBean {
     SessionContext sessionContext;
     public void ejbCreate() throws CreateException {
       /**@todo Complete this method*/
     }
     public void ejbRemove() {
       /**@todo Complete this method*/
     }
     public void ejbActivate() {
       /**@todo Complete this method*/
     }
     public void ejbPassivate() {
       /**@todo Complete this method*/
     }
     public void setSessionContext(SessionContext sessionContext) {
       this.sessionContext = sessionContext;
     }
     public java.lang.String SayHello() {
       /**@todo Complete this method*/
       return new String("Hello World!");
     }
    }//HelloBeanTestClient.java
    package hellodemo;import javax.naming.*;
    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;/**
    * <p>Title: HelloDemo</p>
    * <p>Description: An EJB Example To Learn</p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: Njupt</p>
    * @author JiaenHe
    * @version 1.0
    */public class HelloBeanTestClient1 {
     private HelloHome helloHome = null; //Construct the EJB test client
     public HelloBeanTestClient1() {
       try {
         //get naming context
         Context ctx = getInitialContext();     //look up jndi name
         Object ref = ctx.lookup("HelloBean");     //cast to Home interface
         helloHome = (HelloHome) PortableRemoteObject.narrow(ref, HelloHome.class);
       }
       catch(Exception e) {
         e.printStackTrace();
       }
     } private Context getInitialContext() throws Exception {
       String url = "t3://hje:7001";
       String user = null;
       String password = null;
       Properties properties = null;
       try {
         properties = new Properties();
         properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
         properties.put(Context.PROVIDER_URL, url);
         if (user != null) {
           properties.put(Context.SECURITY_PRINCIPAL, user);
           properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
         }     return new InitialContext(properties);
       }
       catch(Exception e) {
         System.out.println("Unable to connect to WebLogic server at " + url);
         System.out.println("Please make sure that the server is running.");
         throw e;
       }
     } public void testRemoteCallsWithDefaultArguments(Hello hello) {
       if (hello == null) {
         return ;
       }
       try {
         hello.SayHello();
       }
       catch(Exception e) {
         e.printStackTrace();
       }
     } //----------------------------------------------------------------------------
     // Utility Methods
     //---------------------------------------------------------------------------- public HelloHome getHome() {
       return helloHome;
     }
     //Main method public static void main(String[] args) {
       HelloBeanTestClient1 client = new HelloBeanTestClient1();
       // Use the getHome() method of the client object to call Home interface
       // methods that will return a Remote interface reference.  Then
       // use that Remote interface reference to access the EJB.
       client.create();
       System.out.println(client.SayHello());
     }
    }问题出在main中,create()和SayHello()都说是找不到的,错误为:
    "HelloBeanTestClient1.java": Error #: 300 : method create() not found in class hellodemo.HelloBeanTestClient1 at line 85, column 12
    "HelloBeanTestClient1.java": Error #: 300 : method SayHello() not found in class hellodemo.HelloBeanTestClient1 at line 86, column 31
      

  3.   

    还有,我的jb7和weblogic7的配置和楼上那位老兄说的是一样的,只是在安装weblogic7时我选的server type是single server而已了,这个应该没有太大的影响的吧,可是我就是这样配好后,在解client时就是不能找到create和我定义的那个sayhello方法,何解??烦恼中!!
      

  4.   

    解决了,呵呵,原来在用jb7建client程序时要把那下面那些选项全部选中,
    特别是那个generate log,开始我就是没选它所以jb7自动生成的代码中没有
    自建create和sayhello方法,现在选中后好了。
    anyway,多谢了!!:)
    不过,如果不选中generate logging messaes的话,jb7就不会在client程序中自动生成create和自定义的sayhello方法,这是为什么啊,有那么大影响吗??!!不是只要选中generate main和generate methods using the default parameter等两项就可以吗?这个问题如何解决啊??再请指教!!
      

  5.   

    没有什么影响,在client类的构造方法中jbuilder不是已经生产home接口了吗,
     helloHome = (HelloHome) PortableRemoteObject.narrow(ref, HelloHome.class);然后home。create()方法可以返回bean(实际上是bean的remote接口,不过也一样的用)。然后bean。sayhello()就可以了。client.create() syhello()当然是错的,因为HelloBeanTestClient1根本就没有定义这两个方法。正确的方法是象jbuilder自动生成的代码一样自己建立sayHello方法。