Topic: 有人熟悉jboss么? (javax.naming.NoInitialContextException) |
Print this page |
1.有人熟悉jboss么? (javax.naming.NoInitialContextException) | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-09 17:53 我有一个问题,ejb部署上去了 可是客户端(调试用的)运行有问题 源码: 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()); } } } 运行结果: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] who can tell me why? thanks~ |
2.Re:有人熟悉jboss么? [Re: TopCool] | Copy to clipboard |
Posted by: ww77721 Posted on: 2003-06-09 17:55 classpath 中包含 %jboss_home%/client/jbossall-client.jar |
3.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-10 14:30 D:\Temp\jboss\testejb>set classpath classpath=.;"D:\jboss-3.0.6\server\default\lib\javax.servlet.jar;D:\jboss-3.0.6\ client\jboss-clent.jar;D:\jboss-3.0.6\client\jnp-client.jar;D:\jboss-3.0.6\serve r\all\deploy\jbossweb-ejb.ja;D:\jboss-3.0.6\client\jbossall-client.jar;D:\Temp\j boss\testejb\src\a.jar"; D:\Temp\jboss\testejb>java InterestClient Exception in thread "main" java.lang.NoClassDefFoundError: javax/net/SocketFacto ry at org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingConte xtFactory.java:42) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6 65) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246 ) at javax.naming.InitialContext.init(InitialContext.java:222) at javax.naming.InitialContext.<init>(InitialContext.java:198) at InterestClient.main(InterestClient.java:33) 还是不行呀,兄弟~~~ help me... |
4.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: ww77721 Posted on: 2003-06-10 15:17 怎么还用到了 javax 下的 net 包 把 client 目录下的 jnet.jar 也加到 classpath 中 |
5.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-10 15:34 D:\Temp\jboss\testejb>set classpath classpath=.;D:\jboss-3.0.6;\server\default\lib\javax.servlet.jar;D:\jboss-3.0.6; \client\jboss-clent.jar;D:\jboss-3.0.6;\client\jnp-client.jar;D:\jboss-3.0.6;\se rver\all\deploy\jbossweb-ejb.ja;D:\jboss-3.0.6;\client\jbossall-client.jar;D:\jb oss-3.0.6;\client\jnet.jar;D:\Temp\jboss\testejb\src\a.jar; 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] 我真服了jboss这个烂东西了,什么玩艺呀,连个客户端都不好调试,也没有个说明,网上找了一下,都是一代而过。。。。。 |
6.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: ww77721 Posted on: 2003-06-10 15:56 TopCool wrote: 你的 classpath 还是有问题吧 D:\jboss-3.0.6;\server\default\lib\javax.servlet.jar --- 这个地方怎么多了个 ';',其他很多地方都多了个 ';' |
7.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-10 16:09 呵呵,我有改了一下,还是不行! D:\Temp\jboss>set classpath=.; D:/jboss-3.0.6/client/concurrent.jar; D:/jboss-3. 0.6/client/jaas.jar; D:/jboss-3.0.6/client/jboss-common-client.jar; D:/jboss-3.0 .6/client/jboss-client.jar; D:/jboss-3.0.6/client/jbossmq-client.jar; D:/jboss-3 .0.6/client/jboss-system-client.jar; D:/jboss-3.0.6/client/jboss-j2ee.jar; D:/jb oss-3.0.6/client/jbosssx-client.jar; D:/jboss-3.0.6/client/jboss-jsr77.jar; D:/j boss-3.0.6/client/jmx-rmi-connector-client.jar; D:/jboss-3.0.6/client/jnet.jar; D:/jboss-3.0.6/client/jnp-client.jar; D:/jboss-3.0.6/client/jcert.jar; D:/jboss- 3.0.6/client/log4j.jar; D:/jboss-3.0.6/client/jbossall-client.jar;D:\Temp\jboss\ testejb\src\a.jar; D:\Temp\jboss\testejb\client>java InterestClient javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o rg.jnp.interfaces.NamingContextFactory] 好像不是classpath的问题吧? |
8.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: ww77721 Posted on: 2003-06-10 17:58 错误信息就是 jnp 的工厂类没有找到,它应该属于 jnp-client.jar 或者 jbossall-client.jar 这两个包里,你的 classpath 太复杂了,其实只留下 jbossall-client.jar,log4j.jar,jnet.jar,a.jar 这几个包就应该可以了 你试着用 javap org.jnp.interfaces.NamingContextFactory 看一看着各类再不在当前的 classpath 中,如果不在说明你的 classpath 还是有问题 |
9.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-11 09:06 hehe谢谢,已经没有这个问题了,但是又有了一个问题 D:\Temp\jboss\testejb\client>java InterestClient Got context javax.naming.NameNotFoundException: comp not bound 09:09:48,799 INFO [MainDeployer] Deployed package: file:/D:/jboss-3.0.6/server/ default/deploy/testejb.jar 看,我得ejb么已经部署上去了 这是我得jboss.xml <?xml version="1.0" encoding="UTF-8"?> <jboss> <enterprise-beans> <session> <ejb-name>Interest</ejb-name> <jndi-name>interest/Interest</jndi-name> </session> </enterprise-beans> </jboss> 这是ejb-jar.xml <?xml version="1.0" encoding="UTF-8"?> <ejb-jar> <description>JBoss Interest Sample Application</description> <display-name>Interest EJB</display-name> <enterprise-beans> <session> <ejb-name>Interest</ejb-name> <home>org.jboss.docs.interest.InterestHome</home> <remote>org.jboss.docs.interest.Interest</remote> <ejb-class>org.jboss.docs.interest.InterestBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Bean</transaction-type> </session> </enterprise-beans> </ejb-jar> comp是什么意思,请教~~ |
10.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: ww77721 Posted on: 2003-06-11 09:25 当你的程序运行在 container 环境中的时候 java:comp 才需要 当你的程序运行在客户端的时候,直接使用 lookup("interest/Interest") 就可以了 在运行之前你可以访问 http://localhost:端口/jmx-console/ 然后使用 service=JNDIView 点击最后的 list 下面的 invoke 看一看现在 jboss3 的 jndi 里面都有哪些对象 直接看最下面的 global 部分就可以了,看看有没 有 interest/Interest 如果有,那就说明部署成功了,调用应该就没有问题了 |
11.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-11 11:59 没有 看 Operation list Results Back to Agent View Back to MBean View -------------------------------------------------------------------------------- Ejb Module: file%/D%/jboss-3.0.6/server/default/deploy/jmx-ejb-adaptor.jar java:comp namespace of the jmx/ejb/Adaptor bean: +- env (class: org.jnp.interfaces.NamingContext) | +- Server-Name (class: java.lang.String) Ejb Module: file%/D%/jboss-3.0.6/server/default/deploy/testejb.jar java:comp namespace of the Interest bean: +- UserTransaction (class: javax.transaction.UserTransaction) +- env (class: org.jnp.interfaces.NamingContext) Ejb Module: file%/D%/jboss-3.0.6/server/default/deploy/ejb-management.jar java:comp namespace of the MEJB bean: +- env (class: org.jnp.interfaces.NamingContext) | +- Server-Name (class: java.lang.String) java: Namespace +- DefaultDS (class: org.jboss.resource.adapter.jdbc.local.LocalDataSource) +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory) +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory) +- DefaultJMSProvider (class: org.jboss.jms.jndi.JBossMQProvider) +- CounterService (class: org.jboss.varia.counter.CounterService) +- comp (class: javax.naming.Context) +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl) +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory) +- jaas (class: javax.naming.Context) | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext) | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext) | +- http-invoker (class: org.jboss.security.plugins.SecurityDomainContext) +- timedCacheFactory (class: javax.naming.Context) Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory) +- Mail (class: javax.mail.Session) +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory) +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter) +- TransactionManager (class: org.jboss.tm.TxManager) Global JNDI Namespace +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory) +- RMIXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory) +- UserTransactionSessionFactory (class: org.jboss.tm.usertx.server.UserTransactionSessionFactoryImpl) +- topic (class: org.jnp.interfaces.NamingContext) | +- testDurableTopic (class: org.jboss.mq.SpyTopic) | +- testTopic (class: org.jboss.mq.SpyTopic) | +- securedTopic (class: org.jboss.mq.SpyTopic) +- queue (class: org.jnp.interfaces.NamingContext) | +- A (class: org.jboss.mq.SpyQueue) | +- testQueue (class: org.jboss.mq.SpyQueue) | +- ex (class: org.jboss.mq.SpyQueue) | +- DLQ (class: org.jboss.mq.SpyQueue) | +- D (class: org.jboss.mq.SpyQueue) | +- C (class: org.jboss.mq.SpyQueue) | +- B (class: org.jboss.mq.SpyQueue) +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory) +- RMIConnectionFactory (class: org.jboss.mq.SpyConnectionFactory) +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction) +- ejb (class: org.jnp.interfaces.NamingContext) | +- mgmt (class: org.jnp.interfaces.NamingContext) | | +- MEJB (proxy: $Proxy14 implements interface javax.management.j2ee.ManagementHome,interface javax.ejb.Handle) | +- jmx (class: org.jnp.interfaces.NamingContext) | | +- ejb (class: org.jnp.interfaces.NamingContext) | | | +- Adaptor (proxy: $Proxy18 implements interface org.jboss.jmx.adaptor.interfaces.AdaptorHome,interface javax.ejb.Handle) +- jmx:zwz:rmi (class: org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl) +- invokers (class: org.jnp.interfaces.NamingContext) | +- zwz (class: org.jnp.interfaces.NamingContext) | | +- pooled (class: org.jboss.invocation.pooled.interfaces.PooledInvokerProxy) | | +- jrmp (class: org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy) | | +- http (class: org.jboss.invocation.http.interfaces.HttpInvokerProxy) +- interest (class: org.jnp.interfaces.NamingContext) | +- Interest (proxy: $Proxy22 implements interface org.jboss.docs.interest.InterestHome,interface javax.ejb.Handle) +- jmx (class: org.jnp.interfaces.NamingContext) | +- rmi (class: org.jnp.interfaces.NamingContext) | | +- RMIAdaptor (class: org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl) +- UILXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory) +- UILConnectionFactory (class: org.jboss.mq.SpyConnectionFactory) testejb.jar 不在list下,在上面,怎么回事? 麻烦你了!! |
12.Re:有人熟悉jboss [Re: TopCool] | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-11 12:01 看看: Ejb Module: file%/D%/jboss-3.0.6/server/default/deploy/testejb.jar java:comp namespace of the Interest bean: +- UserTransaction (class: javax.transaction.UserTransaction) +- env (class: org.jnp.interfaces.NamingContext) 我的是testejb.jar 不在下面,在上面,请教为什么 |
13.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: ww77721 Posted on: 2003-06-11 12:15 +- interest (class: org.jnp.interfaces.NamingContext) | +- Interest (proxy: $Proxy22 implements interface org.jboss.docs.interest.InterestHome,interface javax.ejb.Handle) 这不是有吗,你已经部署成功了,可以用 lookup("interest/Interest"); 找到了 |
14.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-11 12:37 是呀,已经部署上去了 但是运行客户端还是不行 D:\Temp\jboss\testejb\client>java InterestClient Got context javax.naming.NameNotFoundException: comp not bound 谢谢你的回答~ |
15.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: TopCool Posted on: 2003-06-11 12:41 也,成功了,咔咔 D:\Temp\jboss\testejb\client>java InterestClient Got context Got reference Interest on 1000 units, at 10% per period, compounded over 2 periods is: 210.00000000000023 谢谢你的帮助,波一个~~~~ 呵呵 |
16.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: jhlqab Posted on: 2003-06-28 00:52 c:\jboss_tomcat\examples\build>ant InterestClient Got context javax.naming.NameNotFoundException: interest not bound BUILD SUCCESSFUL |
17.Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) [Re: TopCool] | Copy to clipboard |
Posted by: jhlqab Posted on: 2003-06-28 01:13 大家帮忙看看啊,这是什么问题,前面的部署全部是成功的。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |