Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » how to run Application Client(AWT) for EJB using eclipse?
how to run Application Client(AWT) for EJB using eclipse? [message #180272] Fri, 29 September 2006 13:08 Go to next message
Eclipse UserFriend
Originally posted by: udaykanth.rapeti.gmail.com

hi,
i am new to elcipse and i found many tutorials on ejb's using
eclipse but i still got a doubt, how to run a Application Client program
which uses EJB's using Eclipse+JBoss and also plz tell me how to execute
that client application on other computer which connects to its server.
Thank you in advance.........
Re: how to run Application Client(AWT) for EJB using eclipse? [message #180591 is a reply to message #180272] Thu, 05 October 2006 10:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wknauf_NO_._INSIDE_hg-online.de

Hi !

Running the application client is quite simple: right click the class containing
the main method, choose "Run" -> "Run as..." -> "Java Application".

Starting it from the command line is a bit more difficult. First of all you need
the client jar (you could extract it from the EAR file deployed to JBoss).
This command will start it:

java -cp %JBOSS_HOME%\client\jbossall-client.jar;MyAppClient.jar my.MainClass

where "my.MainClass" is the full class name of the class with the main method.

For a remote client: you simply have to change the property
"Context.PROVIDER_URL" to the remote host:

Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
props.setProperty(Context.PROVIDER_URL, "jnp://my-remote-host:1099");
InitialContext initialContext = new InitialContext(props);


Hope this helps

Wolfgang

R Udaykanth schrieb:
> hi,
> i am new to elcipse and i found many tutorials on ejb's using
> eclipse but i still got a doubt, how to run a Application Client program
> which uses EJB's using Eclipse+JBoss and also plz tell me how to execute
> that client application on other computer which connects to its server.
> Thank you in advance.........
>
>
Re: how to run Application Client(AWT) for EJB using eclipse? [message #180987 is a reply to message #180591] Fri, 06 October 2006 06:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: udaykanth.rapeti.gmail.com

Thank you very much for your response,

when i run my client application using
'RunAs->JavaApplication ' i am getting an exception.....................
the below is my code in main function.....
PLZ NOTE: i used Xdoclet for creating Ejb......




temp.user.MyUser user=null;

try{


System.out.println("Calling EJB....\n<br>");


temp.user.MyUserHome muhome=temp.user.MyUserUtil.getHome();

System.out.println("Ccreating EJB....\n<br>");

/* mbtest=mbhome.create();*/


user=muhome.create(0, "dfhdfh", "62125049", "10","gr");


System.out.println(user.getId()+"<br>");


}catch(Exception exception)

{

System.out.println("Error :"+exception.getLocalizedMessage());

exception.printStackTrace();

}


The below is my output.............,
Calling EJB....

<br>

Error :Need to specify class name in environment or system property, or as
an applet parameter, or in an application resource file:
java.naming.factory.initial

javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial

at javax.naming.spi.NamingManager.getInitialContext(NamingManag er.java:640)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext .java:243)

at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialCo ntext.java:280)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

at temp.user.MyUserUtil.lookupHome(MyUserUtil.java:22)

at temp.user.MyUserUtil.getHome(MyUserUtil.java:42)

at Main.main(Main.java:13)
Re: how to run Application Client(AWT) for EJB using eclipse? [message #180994 is a reply to message #180987] Fri, 06 October 2006 07:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: udaykanth.rapeti.gmail.com

the same code is perfectly running in the web Application(i.e calling EJB's
in JSP's)
Re: how to run Application Client(AWT) for EJB using eclipse? [message #181002 is a reply to message #180987] Fri, 06 October 2006 12:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wknauf_NO_._INSIDE_hg-online.de

Hi !

in an app client you need to initialize the InitialContext in a different way
than you do it in a web client (there the server does it for you).

Full code should be:
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
props.setProperty("j2ee.clientName", "MyClient");

InitialContext initialContext = new InitialContext(props);


Of course you have to change the provider URL for your remote server.

The "j2ee.clientName" is needed it you want to specify an environment naming
context (for EJB references specified in "application-client.xml"). You do not
need it if you look up the beans in the Global JNDI.

Hope this helps

Wolfgang

udaykanth schrieb:
>
>
> Error :Need to specify class name in environment or system property, or as
> an applet parameter, or in an application resource file:
> java.naming.factory.initial
>
> javax.naming.NoInitialContextException: Need to specify class name in
> environment or system property, or as an applet parameter, or in an
> application resource file: java.naming.factory.initial
>
> at javax.naming.spi.NamingManager.getInitialContext(NamingManag er.java:640)
>
>
Re: how to run Application Client(AWT) for EJB using eclipse? [message #181024 is a reply to message #181002] Fri, 06 October 2006 13:51 Go to previous message
Eclipse UserFriend
Originally posted by: udaykanth.rapeti.gmail.com

hi sir,
i set the Properties to intialContext as u specified, it
executed fine without any exception's . so, thank you very much for solving
my problem.
bye bye.
Previous Topic:How can I get the server information that I've configured in WTP?
Next Topic:1.5.1: Where is JBoss ?
Goto Forum:
  


Current Time: Fri Apr 19 22:38:45 GMT 2024

Powered by FUDForum. Page generated in 0.03006 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top