Форум программистов «Весельчак У»
  *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

  • Рекомендуем проверить настройки временной зоны в вашем профиле (страница "Внешний вид форума", пункт "Часовой пояс:").
  • У нас больше нет рассылок. Если вам приходят письма от наших бывших рассылок mail.ru и subscribe.ru, то знайте, что это не мы рассылаем.
   Начало  
Наши сайты
Помощь Поиск Календарь Почта Войти Регистрация  
 
Страниц: [1]   Вниз
  Печать  
Автор Тема: Java&CORBA - Помогите нубу с Hello world апплетом!!!  (Прочитано 8169 раз)
0 Пользователей и 1 Гость смотрят эту тему.
corbo
Гость
« : 18-05-2010 19:24 » new

Помогите, плз, пример "с книжки" не работает!
Сервер:
Код:
// The package containing our stubs.
import HelloWorld.*;

// HelloServer will use the naming service.
import org.omg.CosNaming.*;

// The package containing special exceptions thrown by the name service.
import org.omg.CosNaming.NamingContextPackage.*;

// All CORBA applications need these classes.
import org.omg.CORBA.*;
import org.omg.PortableServer.*;

public class HelloServer
{
  public static void main(String args[])
  {
    try{
    
      // Create and initialize the ORB
      ORB orb = ORB.init(args, null);
      
      // Create the servant object
      HelloServant helloRef = new HelloServant();
      
      POA rootpoa=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
      rootpoa.the_POAManager().activate();
      
 org.omg.CORBA.Object ref= rootpoa.servant_to_reference(helloRef);
      Hello href=HelloHelper.narrow(ref);
      
      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
      NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
        
      NameComponent path[] = ncRef.to_name("HelloWorld");
    
      ncRef.rebind(path, href);

 System.out.println("HelloServer is running...");
 
 orb.run();
      
    } catch(Exception e) {
        System.err.println("ERROR: " + e);
        e.printStackTrace(System.out);
      }  
  }
}



class HelloServant extends HelloPOA
{  
int i=0;
    public String sayHello(String Name)
    {
i++;
   return "The world says HELLO to " + Name + " for the " + i + ". time.";
}
}

создаю апплет- клиент>
Код:
// The package containing our stubs.
import HelloWorld.*;

// HelloClient will use the naming service.
import org.omg.CosNaming.*;

// The package containing special exceptions thrown by the name service.
import org.omg.CosNaming.NamingContextPackage.*;

// All CORBA applications need these classes.
import org.omg.CORBA.*;

// Needed for the applet.
import java.awt.Graphics;

public class HelloApplet extends java.applet.Applet
{
  public void init()
  {
    try{

      // Create and initialize the ORB
      // The applet 'this' is passed to make parameters from the  tag
      // available to initialize the ORB
      ORB orb = ORB.init(this, null);
      
      // Get the root naming context
      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
      NamingContext ncRef = NamingContextHelper.narrow(objRef);

      // Resolve the object reference in naming
      NameComponent nc = new NameComponent("HelloWorld", " ");
      NameComponent path[] = {nc};
      Hello helloRef = HelloHelper.narrow(ncRef.resolve(path));
      
      // Call the Hello server object and print the results
      message = helloRef.sayHello(" Applet! ");

    
    } catch(Exception e) {
        System.out.println("HelloApplet exception: " + e);
        e.printStackTrace(System.out);
      }  
  }
  String message = " ";

  public void paint(Graphics g)
  {
    g.drawString(message, 25, 50);
  }

}

HTML >
Код:
<HTML>
<!--Copyright 2000, Sun Microsystems, Inc. -->
<HEAD>
   <TITLE>Getting Started with Java IDL: Running HelloApplet</TITLE>
   <X-SAS-WINDOW TOP=42 BOTTOM=477 LEFT=4 RIGHT=534>
</HEAD>
<BODY BGCOLOR="#FFFFFF">


<H1 ALIGN=CENTER>Running the Hello World Applet</H1>
<HR>

<P>If all goes well, the applet appears below:

<P>
<APPLET CODE=HelloApplet.class        
        WIDTH=500
        HEIGHT=300>
<PARAM name="org.omg.CORBA.ORBInitialHost" value="127.0.0.1">
<PARAM name="org.omg.CORBA.ORBInitialPort" value=1050>
</APPLET>
  

</BODY>
</HTML>

В броузере Mozilla получаю ошибку>

com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.0.1; port: 1050"
org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No
   at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)
   at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)
   at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source)
... 14 more
и т.п.
дело в том что без броузера все по туториалу работает, так что фишка в нем (не пропускает IIOP что ли, тогда как установить?...)
обьясните плз!
« Последнее редактирование: 19-05-2010 03:17 от Алексей1153++ » Записан
corbo
Гость
« Ответ #1 : 18-05-2010 19:29 » 

сорь лол пример вот
h**p://java.sun.com/j2se/1.3/docs/guide/idl/jidlExample.html
« Последнее редактирование: 19-05-2010 03:18 от Алексей1153++ » Записан
Страниц: [1]   Вверх
  Печать  
 

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines