在本地测试通过的EJB,如何把测试程序放在另外一台机器上,也可以测试通过。

jyu1221 2002-07-12 11:33:22
测试通过的机器:win2000+weblogic6.1
需要把测试程序(CLIENT端的程序)放在另外一台机器的上的配置:WIN2000+JRE2.0
EJB程序和测试程序都是在JBUILDER中生成的。
...全文
39 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
qiyao 2002-07-12
  • 打赏
  • 举报
回复
好运与你同行。。。。。
qiyao 2002-07-12
  • 打赏
  • 举报
回复
也就是:
(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, "System"
properties.put(Context.SECURITY_CREDENTIALS, "12345678");
}
qiyao 2002-07-12
  • 打赏
  • 举报
回复
你要把他们你client程序,不有为NULL
wjmmml 2002-07-12
  • 打赏
  • 举报
回复
这个基本上实现不了,为什么叫测试客户端呢,是用做你测试时用的,而不是你应用的一部分,拿到那里都可以,因为ejb设计到命名服务,目录服务,这些你要在命令行都实现了后,那你的测试客护短才可以放在任何地方
jyu1221 2002-07-12
  • 打赏
  • 举报
回复
可以确定user=system
password=12345678
qiyao 2002-07-12
  • 打赏
  • 举报
回复
t3://192.168.1.125:7001这机的user=? password=?
你能确定他们吗?
jyu1221 2002-07-12
  • 打赏
  • 举报
回复
//客户端程序:

package jyufirst;

import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;

public class StockTestClient1 {
private StockHome stockHome = null;

//Construct the EJB test client
public StockTestClient1() {
try {
//get naming context
Context ctx = getInitialContext();

//look up jndi name
Object ref = ctx.lookup("Stock");

//cast to Home interface
stockHome = (StockHome) PortableRemoteObject.narrow(ref, StockHome.class);
Stock stock = stockHome.create();
int i = stock.GetPrice();
System.out.print(i);
}
catch(Exception e) {
e.printStackTrace();
}
}

private Context getInitialContext() throws Exception {
// String url = "t3://localhost:7001";
String url = "t3://192.168.1.125: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;
}
}

//----------------------------------------------------
// Utility Methods
//----------------------------------------------------

public StockHome getHome() {
return stockHome;
}
//Main method

public static void main(String[] args) {
StockTestClient1 client = new StockTestClient1();
// 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.
}
}
jyu1221 2002-07-12
  • 打赏
  • 举报
回复
//客户端程序:

package jyufirst;

import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;

public class StockTestClient1 {
private StockHome stockHome = null;

//Construct the EJB test client
public StockTestClient1() {
try {
//get naming context
Context ctx = getInitialContext();

//look up jndi name
Object ref = ctx.lookup("Stock");

//cast to Home interface
stockHome = (StockHome) PortableRemoteObject.narrow(ref, StockHome.class);
Stock stock = stockHome.create();
int i = stock.GetPrice();
System.out.print(i);
}
catch(Exception e) {
e.printStackTrace();
}
}

private Context getInitialContext() throws Exception {
// String url = "t3://localhost:7001";
String url = "t3://192.168.1.125: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;
}
}

//-----------------------------------------------------
// Utility Methods
//-----------------------------------------------------

public StockHome getHome() {
return stockHome;
}
//Main method

public static void main(String[] args) {
StockTestClient1 client = new StockTestClient1();
// 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.
}
}
jyu1221 2002-07-12
  • 打赏
  • 举报
回复
PING 192.168.1.125是可以通的
hexiaofeng 2002-07-12
  • 打赏
  • 举报
回复
能ping 通192.168.1.125么??
qiyao 2002-07-12
  • 打赏
  • 举报
回复
程序贴上
jyu1221 2002-07-12
  • 打赏
  • 举报
回复
客户程序的错误信息是:
Unable to connect to WebLogic server at t3://192.168.1.125:7001


Andrawu 2002-07-12
  • 打赏
  • 举报
回复
给一个e文你看看:

Application Client-Tier Security
Authentication requirements for J2EE application clients are the same as the requirements for other J2EE components. Access to protected resources in either the EJB tier or the Web tier requires user authentication, whereas access to unprotected resources does not.

An application client can use the Java Authentication and Authorization Service (JAAS) for authentication. JAAS implements a Java version of the standard Pluggable Authentication Module (PAM) framework, which permits applications to remain independent from underlying authentication technologies. You can plug new or updated authentication technologies under an application without making any modifications to the application itself. Applications enable the authentication process by instantiating a LoginContext object, which, in turn, references a configuration to determine the authentication technologies or login modules that will be used to perform the authentication.

A typical login module could prompt for and verify a user name and password. Other modules could read and verify a voice or fingerprint sample.

In some cases, a login module needs to communicate with the user to obtain authentication information. Login modules use a javax.security.auth.callback.CallbackHandler for this purpose. Applications implement the CallbackHandler interface and pass it to the login context, which forwards it directly to the underlying login modules. A login module uses the callback handler both to gather input (such as a password or smart card PIN number) from users or to supply information (such as status information) to users. By allowing the application to specify the callback handler, an underlying login module can remain independent of the different ways applications interact with users.

For example, the implementation of a callback handler for a GUI application might display a window to solicit user input. Or, the implementation of a callback handler for a command line tool might simply prompt the user for input directly from the command line.

The login module passes an array of appropriate callbacks to the callback handler's handle method (for example, a NameCallback for the user name and a PasswordCallback for the password), and the callback handler performs the requested user interaction and sets appropriate values in the callbacks. For example, to process a NameCallback, the CallbackHandler may prompt for a name, retrieve the value from the user, and call the setName method of the NameCallback to store the name.


更详细的请从:http://java.sun.com/j2ee/download.html#tutorial下载。
oceanboywjk 2002-07-12
  • 打赏
  • 举报
回复
weblogic安装后默认无需设置用户和密码就能访问,但只能访问不能deploy
jyu1221 2002-07-12
  • 打赏
  • 举报
回复
谢谢大家的大力支持,请再告诉我一下关于密码的问题,我马上结贴。
jyu1221 2002-07-12
  • 打赏
  • 举报
回复
现在已经可以测试通过了,
不过是没有设置用户名称、密码
和设置了用户名称、密码都可以测试通过。
不知道该用户名称、密码是起什么作用的,和WEBLOGIN安装时的密码有什么关系。

我在客户端的命令是这么写的就可以了:
java -classpath ".;./weblogic.jar;" jyufirst.StockTestClient1

其中的weblogic.jar这个文件是从WEBLOGIC中COPY过来的。


原来写错误的格式:
java jyufirst.StockTestClient1 -classpath ".;./weblogic.jar;"

jyu1221 2002-07-12
  • 打赏
  • 举报
回复
已经写上了,可是还是不可以

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧