救命啊!哪位大哥帮帮忙啊 程序出来很大的问题哦

06-04-28 wszfq0303
我用eclipse3.0+jbosside+jboss4.0+mysql编了一个BMP,用客户端进行测试时,总是出错,大侠们帮我看看吧!

package com.liuyang.bmp.programmer.client;

import java.util.Collection;

import java.util.Iterator;

import java.util.Properties;

import javax.naming.Context;

import javax.naming.InitialContext;

import com.liuyang.bmp.interfaces.ProgrammerBMP;

import com.liuyang.bmp.interfaces.ProgrammerBMPHome;

public class ProgrammerClient {

public static void main(String[] args) throws Exception {

Properties p = new Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");

p.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");

Object ref = new InitialContext(p).lookup("ProgrammerBMP");

ProgrammerBMPHome home = (ProgrammerBMPHome)ref;

ProgrammerBMP liuyang = home.create("liuyang",25,"java","jboss");

ProgrammerBMP weifei = home.create("weifei",25,"java","eclipse");

Collection all = home.findByLanguage("java");

if((all!=null)&&(!all.isEmpty())){

Iterator it = all.iterator();

while(it.hasNext()){

ProgrammerBMP bmp = (ProgrammerBMP) it.next();

System.out.println(bmp.getName()+":"+bmp.getTool());

}

}

}

}

进行测试时总是抛出以下错误是什么原因啊??

log4j:WARN No appenders could be found for logger (org.jnp.interfaces.NamingContext).

log4j:WARN Please initialize the log4j system properly.

javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1302)

at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1382)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)

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

at com.liuyang.bmp.programmer.client.ProgrammerClient.main(ProgrammerClient.java:30)

Caused by: java.net.SocketTimeoutException: Receive timed out

at java.net.PlainDatagramSocketImpl.receive(Native Method)

at java.net.DatagramSocket.receive(DatagramSocket.java:711)

at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1272)

... 5 more

Exception in thread "main"

请大侠们指点迷精,万分感谢!!

ejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

<ejb-jar >

<description><![CDATA[No Description.]]></description>

<display-name>Generated by XDoclet</display-name>

<enterprise-beans>

<!-- Session Beans -->

<!--

To add session beans that you have deployment descriptor info for, add

a file to your XDoclet merge directory called session-beans.xml that contains

the <session></session> markup for those beans.

-->

<!-- Entity Beans -->

<entity >

<description><![CDATA[Description for ProgrammerBMP]]></description>

<display-name>ProgrammerBMPBean</display-name>

<ejb-name>ProgrammerBMP</ejb-name>

<home>com.liuyang.bmp.interfaces.ProgrammerBMPHome</home>

<remote>com.liuyang.bmp.interfaces.ProgrammerBMP</remote>

<ejb-class>com.liuyang.bmp.programmer.ProgrammerBMPBean</ejb-class>

<persistence-type>Bean</persistence-type>

<prim-key-class>java.lang.String</prim-key-class>

<reentrant>False</reentrant>

<resource-ref >

<res-ref-name>datasource</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>

</entity>

<!--

To add entity beans that you have deployment descriptor info for, add

a file to your XDoclet merge directory called entity-beans.xml that contains

the <entity></entity> markup for those beans.

-->

<!-- Message Driven Beans -->

<!--

To add message driven beans that you have deployment descriptor info for, add

a file to your XDoclet merge directory called message-driven-beans.xml that contains

the <message-driven></message-driven> markup for those beans.

-->

</enterprise-beans>

<!-- Relationships -->

<!-- Assembly Descriptor -->

<assembly-descriptor >

<!--

To add additional assembly descriptor info here, add a file to your

XDoclet merge directory called assembly-descriptor.xml that contains

the <assembly-descriptor></assembly-descriptor> markup.

-->

<!-- finder permissions -->

<!-- transactions -->

<!-- finder transactions -->

</assembly-descriptor>

</ejb-jar>

jboss-xml:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">

<jboss>

<enterprise-beans>

<!--

To add beans that you have deployment descriptor info for, add

a file to your XDoclet merge directory called jboss-beans.xml that contains

the <session></session>, <entity></entity> and <message-driven></message-driven>

markup for those beans.

-->

<entity>

<ejb-name>ProgrammerBMP</ejb-name>

<jndi-name>ejb/ProgrammerBMP</jndi-name>

<resource-ref>

<res-ref-name>datasource</res-ref-name>

<jndi-name>java:/MySQLDS</jndi-name>

</resource-ref>

<method-attributes>

</method-attributes>

</entity>

</enterprise-beans>

<resource-managers>

</resource-managers>

</jboss>

banq
2006-04-30 11:33
>p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

>p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");

>p.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");

>

JNDI问题,JBoss本地已经有JNDI配置,无需指定JNDI

猜你喜欢