幫忙看看我得ejb客戶端
報錯
D:\Temp\jboss\testejb>java InterestClient
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
下面是原始碼:
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import javax.naming.*;
import org.jboss.docs.interest.Interest;
import org.jboss.docs.interest.InterestHome;
/** This simple application tests the 'Interest' Enterprise JavaBean which is
implemented in the package 'org.jboss.docs.interest'. For this to work, the
Bean must be deployed on an EJB server.
*/
class InterestClient
{
/** This method does all the work. It creates an instance of the Interest EJB on
the EJB server, and calls its `calculateCompoundInterest()' method, then prints
the result of the calculation.
*/
public static void main(String[] args)
{
// Enclosing the whole process in a single `try' block is not an ideal way
// to do exception handling, but I don't want to clutter the program up
// with catch blocks
try
{
// Get a naming context
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL,"jnp://localhost:1099");
//properties.put(Context.PROVIDER_URL_PKGS,"org.jboss.naming:org.jnp.interfaces");
InitialContext jndiContext = new InitialContext(properties);
System.out.println("Got context");
// Get a reference to the Interest Bean
Object ref = jndiContext.lookup("java:comp/env/ejb/Interest");
System.out.println("Got reference");
// Get a reference from this to the Bean's Home interface
InterestHome home = (InterestHome)
PortableRemoteObject.narrow(ref, InterestHome.class);
// Create an Interest object from the Home interface
Interest interest = home.create();
// call the calculateCompoundInterest() method to do the calculation
System.out.println("Interest on 1000 units, at 10% per period, compounded over 2 periods is:");
System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
哪位大哥幫忙一下,ejb部署上去了,然後寫一個客戶端,除錯。
結果就不知道怎麼錯了。
D:\Temp\jboss\testejb>java InterestClient
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
下面是原始碼:
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import javax.naming.*;
import org.jboss.docs.interest.Interest;
import org.jboss.docs.interest.InterestHome;
/** This simple application tests the 'Interest' Enterprise JavaBean which is
implemented in the package 'org.jboss.docs.interest'. For this to work, the
Bean must be deployed on an EJB server.
*/
class InterestClient
{
/** This method does all the work. It creates an instance of the Interest EJB on
the EJB server, and calls its `calculateCompoundInterest()' method, then prints
the result of the calculation.
*/
public static void main(String[] args)
{
// Enclosing the whole process in a single `try' block is not an ideal way
// to do exception handling, but I don't want to clutter the program up
// with catch blocks
try
{
// Get a naming context
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL,"jnp://localhost:1099");
//properties.put(Context.PROVIDER_URL_PKGS,"org.jboss.naming:org.jnp.interfaces");
InitialContext jndiContext = new InitialContext(properties);
System.out.println("Got context");
// Get a reference to the Interest Bean
Object ref = jndiContext.lookup("java:comp/env/ejb/Interest");
System.out.println("Got reference");
// Get a reference from this to the Bean's Home interface
InterestHome home = (InterestHome)
PortableRemoteObject.narrow(ref, InterestHome.class);
// Create an Interest object from the Home interface
Interest interest = home.create();
// call the calculateCompoundInterest() method to do the calculation
System.out.println("Interest on 1000 units, at 10% per period, compounded over 2 periods is:");
System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
哪位大哥幫忙一下,ejb部署上去了,然後寫一個客戶端,除錯。
結果就不知道怎麼錯了。
相關文章
- 釋出成功了,但客戶段呼叫有問題,幫幫忙啊
- 我的第一個entity Ejb就出錯!大家幫幫忙
- 在客戶端儲存對EJB的遠端呼叫是否可行?客戶端
- 來幫我看看這個簡單的遠端客戶端呼叫EJB出錯的例子,謝謝了客戶端
- 看視訊必備:YouTube客戶端客戶端
- EJB客戶端如何不用任何client jar去動態呼叫遠端伺服器的EJB?客戶端clientJAR伺服器
- 怎樣在websphere環境外的客戶端呼叫webshphere的ejb?Web客戶端
- 利用好的客服工具以便幫助你獲得更多的客戶
- 從刷票瞭解如何獲得客戶端IP客戶端
- 在Intranet中獲得客戶端IP地址客戶端
- 請各位大佬幫忙看看我的 Page Object 模式用的對不對Object模式
- 獲得客戶端ip的方法,排除代理伺服器客戶端伺服器
- 從PHP客戶端看MongoDB通訊協議TDPHP客戶端MongoDB協議
- Flyme影片客戶端加入廣告了 煤油怎麼看?客戶端
- dubbo客戶端客戶端
- Pulsar客戶端客戶端
- mqtt 客戶端MQQT客戶端
- 客戶端,服務端客戶端服務端
- 服務端,客戶端服務端客戶端
- CRM客戶管理系統對管理客戶的幫助
- Nacos - 客戶端心跳續約及客戶端總結客戶端
- 高手幫忙
- 高手幫忙!
- 大神幫忙看一看,講一下思路
- CRM客戶關係管理:贏得和留住客戶的指南
- 物理DataGuard客戶端無縫切換--客戶端TAF 配置客戶端
- 客戶端加解密客戶端解密
- Zookeeper 客戶端 API客戶端API
- java websocket 客戶端JavaWeb客戶端
- 客戶端筆記客戶端筆記
- Redis-客戶端Redis客戶端
- redis客戶端管理Redis客戶端
- CXF--客戶端客戶端
- 中斷客戶端客戶端
- github客戶端使用Github客戶端
- Java EE 7: EJB 釋出 CDI事件透過WebSocket到瀏覽器客戶端Java事件Web瀏覽器客戶端
- ASP.NET獲得客戶端瀏覽器語言設定ASP.NET客戶端瀏覽器
- 從客戶端遊戲漏洞看開發中的安全隱患客戶端遊戲