救命啊!哪位大哥幫幫忙啊 程式出來很大的問題哦

wszfq0303發表於2006-04-28
我用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>

相關文章