﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-XZC.Log-随笔分类-Eclipse</title><link>http://www.blogjava.net/xzclog/category/15440.html</link><description /><language>zh-cn</language><lastBuildDate>Sat, 28 Nov 2015 12:40:58 GMT</lastBuildDate><pubDate>Sat, 28 Nov 2015 12:40:58 GMT</pubDate><ttl>60</ttl><item><title>Eclipse无法调试及编译时内存不足的解决</title><link>http://www.blogjava.net/xzclog/archive/2015/11/26/428370.html</link><dc:creator>xzc</dc:creator><author>xzc</author><pubDate>Thu, 26 Nov 2015 07:56:00 GMT</pubDate><guid>http://www.blogjava.net/xzclog/archive/2015/11/26/428370.html</guid><wfw:comment>http://www.blogjava.net/xzclog/comments/428370.html</wfw:comment><comments>http://www.blogjava.net/xzclog/archive/2015/11/26/428370.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xzclog/comments/commentRss/428370.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xzclog/services/trackbacks/428370.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #333333; font-family: Arial; font-size: 16px; line-height: 26px; background-color: #ffffff; "><p>转自：<div style="display: inline-block; "></div></p></span><span class="Apple-style-span" style="color: #333333; font-family: Arial; font-size: 16px; line-height: 26px; background-color: #ffffff; "><a href="http://blog.csdn.net/caihaijiang/article/details/5903154">http://blog.csdn.net/caihaijiang/article/details/5903154</a></span><span class="Apple-style-span" style="color: #333333; font-family: Arial; font-size: 16px; line-height: 26px; background-color: #ffffff; "><p>Eclipse下Debug时，弹出错误提示：&#8220;Unable to install breakpoint due to missing line number attributes. Modify compiler options to generate line number attributes&#8221;，无法进行调试。</p><p>&nbsp;</p><p>遇到这个错误时找到的解答方案汇总：</p><p>1、修改<span class="hilite5">Eclipse</span>的java编译器使用jdk，而不是jre；<br />2、使用Ant编译时，未打开debug开关，在写javac 任务时，设置debug="true"，否则不能调试。THe settings for the&nbsp;<span class="hilite5">eclipse</span>&nbsp;compiler don't affect the ant build and even if you launch the ant build from within<span class="hilite5">eclipse</span>. ant controls it's own compiler settings.you can tell ant&nbsp;to generate debugging info like this 'javac ... debug="true".../&gt;；（我遇到的问题，是采用这个办法解决的）<br />3、编译器的设置问题，window-&gt;preferences-&gt;java-&gt;Compiler在compiler起始页，classfile Generation区域中确认已经勾选了All line number attributes to generated class files。如果已经勾选，从新来一下再Apply一下。或者从项目层次进行设定，项目属性-&gt;java compiler同样在起始页，确定已经勾选。</p><p>&nbsp;</p><p>&nbsp;</p><p>Eclipse编译时出现Outof Memory问题，解决办法如下：</p><p>window-&gt;preferences-&gt;java-&gt;Installed JREs，选择安装的jre（如jdk1.5.0），单击右边按钮&#8220;Edit&#8221;，弹出&#8220;Edit JRE&#8221;的对话框，在Default VM Argument的输入框中输入：-Xmx512m，然后按确定，即可。(-Xms是设定最小内存，-Xmx是设定最大内存）</p></span><img src ="http://www.blogjava.net/xzclog/aggbug/428370.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xzclog/" target="_blank">xzc</a> 2015-11-26 15:56 <a href="http://www.blogjava.net/xzclog/archive/2015/11/26/428370.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图解eclipse+myelcipse开发EJB </title><link>http://www.blogjava.net/xzclog/archive/2006/08/14/63403.html</link><dc:creator>xzc</dc:creator><author>xzc</author><pubDate>Mon, 14 Aug 2006 02:13:00 GMT</pubDate><guid>http://www.blogjava.net/xzclog/archive/2006/08/14/63403.html</guid><wfw:comment>http://www.blogjava.net/xzclog/comments/63403.html</wfw:comment><comments>http://www.blogjava.net/xzclog/archive/2006/08/14/63403.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xzclog/comments/commentRss/63403.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xzclog/services/trackbacks/63403.html</trackback:ping><description><![CDATA[在开发ejb之前，我们先得配置好服务器，我使用的是Weblogic9.0中文版，关于Weblogic9.0配置请看我的另一片文章。<a class="singleposttitle" id="viewpost1_TitleUrl" href="/rickhunter/articles/25479.html">配置Weblogic9.0</a><br />    <br />    首先需要配置好eclipse。我这里主要说明weblogic的配置。<br />    <img height="524" alt="ejb19.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb19.jpg" width="744" border="0" /><br /><br />    <font color="#ee82ee">注意JDK选择JDK5.0的版本。</font><br />    <br />    顺便将weblogic8的配置也贴上来，供大家比较参考<br />    <img height="524" alt="ejb18.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb18.jpg" width="702" border="0" /><br />    <br />    <font color="#ee82ee">注意weblogic8的JDK版本必须是JDK1.4。</font><br />    <br />    接下来就开始我们的开发了。<br /><hr width="100%" size="2" /><img height="500" alt="ejb1.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb1.jpg" width="525" border="0" /><br /><br /><img height="500" alt="ejb2.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb2.jpg" width="525" border="0" /><br /><br /><img height="234" alt="ejb3.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb3.jpg" width="221" border="0" /><br /><br /><img height="274" alt="ejb4.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb4.jpg" width="585" border="0" /><br /><br /><img height="578" alt="ejb5.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb5.jpg" width="525" border="0" /><br /><br />下面就是SessionBean的代码<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img id="Code_Closed_Image" onclick="this.style.display='none'; Code_Closed_Text.style.display='none'; Code_Open_Image.style.display='inline'; Code_Open_Text.style.display='inline';" height="16" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" width="11" align="top" /><img id="Code_Open_Image" style="DISPLAY: none" onclick="this.style.display='none'; Code_Open_Text.style.display='none'; Code_Closed_Image.style.display='inline'; Code_Closed_Text.style.display='inline';" height="16" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" align="top" /><span id="Code_Closed_Text" style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)">30</span><span id="Code_Open_Text" style="DISPLAY: none"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: rgb(0,128,128)"> 1</span> <span style="COLOR: rgb(0,0,255)">package</span><span style="COLOR: rgb(0,0,0)"> com.ejb;<br /></span><span style="COLOR: rgb(0,128,128)"> 2</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)"> 3</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> java.rmi.RemoteException;<br /></span><span style="COLOR: rgb(0,128,128)"> 4</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)"> 5</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> javax.ejb.EJBException;<br /></span><span style="COLOR: rgb(0,128,128)"> 6</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> javax.ejb.SessionBean;<br /></span><span style="COLOR: rgb(0,128,128)"> 7</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> javax.ejb.SessionContext;<br /></span><span style="COLOR: rgb(0,128,128)"> 8</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)"> 9</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">10</span> <span style="COLOR: rgb(0,128,0)"> * XDoclet-based session bean.  The class must be declared<br /></span><span style="COLOR: rgb(0,128,128)">11</span> <span style="COLOR: rgb(0,128,0)"> * public according to the EJB specification.<br /></span><span style="COLOR: rgb(0,128,128)">12</span> <span style="COLOR: rgb(0,128,0)"> *<br /></span><span style="COLOR: rgb(0,128,128)">13</span> <span style="COLOR: rgb(0,128,0)"> * To generate the EJB related files to this EJB:<br /></span><span style="COLOR: rgb(0,128,128)">14</span> <span style="COLOR: rgb(0,128,0)"> *        - Add Standard EJB module to XDoclet project properties<br /></span><span style="COLOR: rgb(0,128,128)">15</span> <span style="COLOR: rgb(0,128,0)"> *        - Customize XDoclet configuration for your appserver<br /></span><span style="COLOR: rgb(0,128,128)">16</span> <span style="COLOR: rgb(0,128,0)"> *        - Run XDoclet<br /></span><span style="COLOR: rgb(0,128,128)">17</span> <span style="COLOR: rgb(0,128,0)"> *<br /></span><span style="COLOR: rgb(0,128,128)">18</span> <span style="COLOR: rgb(0,128,0)"> * Below are the xdoclet-related tags needed for this EJB.<br /></span><span style="COLOR: rgb(0,128,128)">19</span> <span style="COLOR: rgb(0,128,0)"> * <br /></span><span style="COLOR: rgb(0,128,128)">20</span> <span style="COLOR: rgb(0,128,0)"> * @ejb.bean name="HelloWorld"<br /></span><span style="COLOR: rgb(0,128,128)">21</span> <span style="COLOR: rgb(0,128,0)"> *           display-name="Name for HelloWorld"<br /></span><span style="COLOR: rgb(0,128,128)">22</span> <span style="COLOR: rgb(0,128,0)"> *           description="Description for HelloWorld"<br /></span><span style="COLOR: rgb(0,128,128)">23</span> <span style="COLOR: rgb(0,128,0)"> *           jndi-name="ejb/HelloWorld"<br /></span><span style="COLOR: rgb(0,128,128)">24</span> <span style="COLOR: rgb(0,128,0)"> *           type="Stateless"<br /></span><span style="COLOR: rgb(0,128,128)">25</span> <span style="COLOR: rgb(0,128,0)"> *           view-type="remote"<br /></span><span style="COLOR: rgb(0,128,128)">26</span> <span style="COLOR: rgb(0,128,0)"> </span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">27</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">class</span><span style="COLOR: rgb(0,0,0)"> HelloWorld </span><span style="COLOR: rgb(0,0,255)">implements</span><span style="COLOR: rgb(0,0,0)"> SessionBean {<br /></span><span style="COLOR: rgb(0,128,128)">28</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">29</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"> The session context </span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">30</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">private</span><span style="COLOR: rgb(0,0,0)"> SessionContext context;<br /></span><span style="COLOR: rgb(0,128,128)">31</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">32</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> HelloWorld() {<br /></span><span style="COLOR: rgb(0,128,128)">33</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,0,255)">super</span><span style="COLOR: rgb(0,0,0)">();<br /></span><span style="COLOR: rgb(0,128,128)">34</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> TODO 自动生成构造函数存根</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">35</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)">    }<br /></span><span style="COLOR: rgb(0,128,128)">36</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">37</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">38</span> <span style="COLOR: rgb(0,128,0)">     * Set the associated session context. The container calls this method <br /></span><span style="COLOR: rgb(0,128,128)">39</span> <span style="COLOR: rgb(0,128,0)">     * after the instance creation.<br /></span><span style="COLOR: rgb(0,128,128)">40</span> <span style="COLOR: rgb(0,128,0)">     * <br /></span><span style="COLOR: rgb(0,128,128)">41</span> <span style="COLOR: rgb(0,128,0)">     * The enterprise bean instance should store the reference to the context <br /></span><span style="COLOR: rgb(0,128,128)">42</span> <span style="COLOR: rgb(0,128,0)">     * object in an instance variable.<br /></span><span style="COLOR: rgb(0,128,128)">43</span> <span style="COLOR: rgb(0,128,0)">     * <br /></span><span style="COLOR: rgb(0,128,128)">44</span> <span style="COLOR: rgb(0,128,0)">     * This method is called with no transaction context. <br /></span><span style="COLOR: rgb(0,128,128)">45</span> <span style="COLOR: rgb(0,128,0)">     * <br /></span><span style="COLOR: rgb(0,128,128)">46</span> <span style="COLOR: rgb(0,128,0)">     * </span><span style="COLOR: rgb(128,128,128)">@throws</span><span style="COLOR: rgb(0,128,0)"> EJBException Thrown if method fails due to system-level error.<br /></span><span style="COLOR: rgb(0,128,128)">47</span> <span style="COLOR: rgb(0,128,0)">     </span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">48</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)"> setSessionContext(SessionContext newContext)<br /></span><span style="COLOR: rgb(0,128,128)">49</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)"> EJBException {<br /></span><span style="COLOR: rgb(0,128,128)">50</span> <span style="COLOR: rgb(0,0,0)">        context </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> newContext;<br /></span><span style="COLOR: rgb(0,128,128)">51</span> <span style="COLOR: rgb(0,0,0)">    }<br /></span><span style="COLOR: rgb(0,128,128)">52</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">53</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)"> ejbRemove() </span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)"> EJBException, RemoteException {<br /></span><span style="COLOR: rgb(0,128,128)">54</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> TODO 自动生成方法存根</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">55</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">56</span> <span style="COLOR: rgb(0,0,0)">    }<br /></span><span style="COLOR: rgb(0,128,128)">57</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">58</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)"> ejbActivate() </span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)"> EJBException, RemoteException {<br /></span><span style="COLOR: rgb(0,128,128)">59</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> TODO 自动生成方法存根</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">60</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">61</span> <span style="COLOR: rgb(0,0,0)">    }<br /></span><span style="COLOR: rgb(0,128,128)">62</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">63</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)"> ejbPassivate() </span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)"> EJBException, RemoteException {<br /></span><span style="COLOR: rgb(0,128,128)">64</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> TODO 自动生成方法存根</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">65</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">66</span> <span style="COLOR: rgb(0,0,0)">    }<br /></span><span style="COLOR: rgb(0,128,128)">67</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">68</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">69</span> <span style="COLOR: rgb(0,128,0)">     * An example business method<br /></span><span style="COLOR: rgb(0,128,128)">70</span> <span style="COLOR: rgb(0,128,0)">     *<br /></span><span style="COLOR: rgb(0,128,128)">71</span> <span style="COLOR: rgb(0,128,0)">     * @ejb.interface-method view-type = "remote"<br /></span><span style="COLOR: rgb(0,128,128)">72</span> <span style="COLOR: rgb(0,128,0)">     * <br /></span><span style="COLOR: rgb(0,128,128)">73</span> <span style="COLOR: rgb(0,128,0)">     * </span><span style="COLOR: rgb(128,128,128)">@throws</span><span style="COLOR: rgb(0,128,0)"> EJBException Thrown if method fails due to system-level error.<br /></span><span style="COLOR: rgb(0,128,128)">74</span> <span style="COLOR: rgb(0,128,0)">     </span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">75</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> String hello() </span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)"> EJBException {<br /></span><span style="COLOR: rgb(0,128,128)">76</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> rename and start putting your business logic here</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">77</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)"> String(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">HelloEJBWorld!</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /></span><span style="COLOR: rgb(0,128,128)">78</span> <span style="COLOR: rgb(0,0,0)">    }<br /></span><span style="COLOR: rgb(0,128,128)">79</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">80</span> <span style="COLOR: rgb(0,0,0)">}<br /></span><span style="COLOR: rgb(0,128,128)">81</span> <span style="COLOR: rgb(0,0,0)"></span></span></div><br />其实就是修改了其中的一个方法： 
<div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: rgb(0,128,128)"> 1</span> <span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)"> 2</span> <span style="COLOR: rgb(0,128,0)">     * An example business method<br /></span><span style="COLOR: rgb(0,128,128)"> 3</span> <span style="COLOR: rgb(0,128,0)">     *<br /></span><span style="COLOR: rgb(0,128,128)"> 4</span> <span style="COLOR: rgb(0,128,0)">     * @ejb.interface-method view-type = "remote"<br /></span><span style="COLOR: rgb(0,128,128)"> 5</span> <span style="COLOR: rgb(0,128,0)">     * <br /></span><span style="COLOR: rgb(0,128,128)"> 6</span> <span style="COLOR: rgb(0,128,0)">     * </span><span style="COLOR: rgb(128,128,128)">@throws</span><span style="COLOR: rgb(0,128,0)"> EJBException Thrown if method fails due to system-level error.<br /></span><span style="COLOR: rgb(0,128,128)"> 7</span> <span style="COLOR: rgb(0,128,0)">     </span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)"> 8</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> String hello() </span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)"> EJBException {<br /></span><span style="COLOR: rgb(0,128,128)"> 9</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> rename and start putting your business logic here</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">10</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)"> String(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">HelloEJBWorld!</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /></span><span style="COLOR: rgb(0,128,128)">11</span> <span style="COLOR: rgb(0,0,0)">    }</span></div><font color="#ff1493"><u>注意：代码中的解释文字不要删除，因为XDoclet需要。</u></font><br /><br />配置属性<br /><img height="488" alt="ejb6.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb6.jpg" width="334" border="0" /><br /><br />添加weblogic.jar。我的路径是：bea\weblogic90\server\lib\weblogic.jar<br /><img height="524" alt="ejb16.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb16.jpg" width="726" border="0" /><br /><br /><img height="548" alt="ejb7.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb7.jpg" width="719" border="0" /><br /><br /><img height="171" alt="ejb8.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb8.jpg" width="220" border="0" /><br /><br /><img height="548" alt="ejb9.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb9.jpg" width="719" border="0" /><br /><br /><img height="548" alt="ejb10.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb10.jpg" width="719" border="0" /><br /><br /><img height="591" alt="ejb11.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb11.jpg" width="220" border="0" /><br /><br /><img height="548" alt="ejb12.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb12.jpg" width="719" border="0" /><br /><br /><img height="546" alt="ejb13.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb13.jpg" width="718" border="0" /><br /><br /><img height="622" alt="ejb14.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb14.jpg" width="600" border="0" /><br /><br /><img height="348" alt="ejb15.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb15.jpg" width="217" border="0" /><br /><br />就下来写EJBTest类：<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: rgb(0,128,128)"> 1</span> <span style="COLOR: rgb(0,0,255)">package</span><span style="COLOR: rgb(0,0,0)"> com;<br /></span><span style="COLOR: rgb(0,128,128)"> 2</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)"> 3</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> java.rmi.RemoteException;<br /></span><span style="COLOR: rgb(0,128,128)"> 4</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> java.util.Properties;<br /></span><span style="COLOR: rgb(0,128,128)"> 5</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)"> 6</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> javax.ejb.CreateException;<br /></span><span style="COLOR: rgb(0,128,128)"> 7</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> javax.naming.Context;<br /></span><span style="COLOR: rgb(0,128,128)"> 8</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> javax.naming.InitialContext;<br /></span><span style="COLOR: rgb(0,128,128)"> 9</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> javax.naming.NamingException;<br /></span><span style="COLOR: rgb(0,128,128)">10</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">11</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> com.interfaces.HelloWorld;<br /></span><span style="COLOR: rgb(0,128,128)">12</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)"> com.interfaces.HelloWorldHome;<br /></span><span style="COLOR: rgb(0,128,128)">13</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">14</span> <span style="COLOR: rgb(0,0,0)"></span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">class</span><span style="COLOR: rgb(0,0,0)"> EJBTest {<br /></span><span style="COLOR: rgb(0,128,128)">15</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">16</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">17</span> <span style="COLOR: rgb(0,128,0)">     * </span><span style="COLOR: rgb(128,128,128)">@param</span><span style="COLOR: rgb(0,128,0)"> args<br /></span><span style="COLOR: rgb(0,128,128)">18</span> <span style="COLOR: rgb(0,128,0)">     </span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">19</span> <span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">static</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)"> main(String[] args) {<br /></span><span style="COLOR: rgb(0,128,128)">20</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> TODO 自动生成方法存根</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">21</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)">        Properties properties</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)"> Properties();<br /></span><span style="COLOR: rgb(0,128,128)">22</span> <span style="COLOR: rgb(0,0,0)">        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">weblogic.jndi.WLInitialContextFactory</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /></span><span style="COLOR: rgb(0,128,128)">23</span> <span style="COLOR: rgb(0,0,0)">        properties.setProperty(Context.PROVIDER_URL,</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">t3://localhost:7001</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /></span><span style="COLOR: rgb(0,128,128)">24</span> <span style="COLOR: rgb(0,0,0)">        <br /></span><span style="COLOR: rgb(0,128,128)">25</span> <span style="COLOR: rgb(0,0,0)">        Context context;<br /></span><span style="COLOR: rgb(0,128,128)">26</span> <span style="COLOR: rgb(0,0,0)">        </span><span style="COLOR: rgb(0,0,255)">try</span><span style="COLOR: rgb(0,0,0)"> {<br /></span><span style="COLOR: rgb(0,128,128)">27</span> <span style="COLOR: rgb(0,0,0)">            context </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)"> InitialContext(properties);<br /></span><span style="COLOR: rgb(0,128,128)">28</span> <span style="COLOR: rgb(0,0,0)">            HelloWorldHome hwh</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">(HelloWorldHome)context.lookup(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">ejb/HelloWorld</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /></span><span style="COLOR: rgb(0,128,128)">29</span> <span style="COLOR: rgb(0,0,0)">            HelloWorld hw</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">hwh.create();<br /></span><span style="COLOR: rgb(0,128,128)">30</span> <span style="COLOR: rgb(0,0,0)">            String s</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">hw.hello();<br /></span><span style="COLOR: rgb(0,128,128)">31</span> <span style="COLOR: rgb(0,0,0)">            System.out.println(s);<br /></span><span style="COLOR: rgb(0,128,128)">32</span> <span style="COLOR: rgb(0,0,0)">        } </span><span style="COLOR: rgb(0,0,255)">catch</span><span style="COLOR: rgb(0,0,0)"> (NamingException e) {<br /></span><span style="COLOR: rgb(0,128,128)">33</span> <span style="COLOR: rgb(0,0,0)">            </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> TODO 自动生成 catch 块</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">34</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)">            e.printStackTrace();<br /></span><span style="COLOR: rgb(0,128,128)">35</span> <span style="COLOR: rgb(0,0,0)">        } </span><span style="COLOR: rgb(0,0,255)">catch</span><span style="COLOR: rgb(0,0,0)"> (RemoteException e) {<br /></span><span style="COLOR: rgb(0,128,128)">36</span> <span style="COLOR: rgb(0,0,0)">            </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> TODO 自动生成 catch 块</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">37</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)">            e.printStackTrace();<br /></span><span style="COLOR: rgb(0,128,128)">38</span> <span style="COLOR: rgb(0,0,0)">        } </span><span style="COLOR: rgb(0,0,255)">catch</span><span style="COLOR: rgb(0,0,0)"> (CreateException e) {<br /></span><span style="COLOR: rgb(0,128,128)">39</span> <span style="COLOR: rgb(0,0,0)">            </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> TODO 自动生成 catch 块</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,128,128)">40</span> <span style="COLOR: rgb(0,128,0)"></span><span style="COLOR: rgb(0,0,0)">            e.printStackTrace();<br /></span><span style="COLOR: rgb(0,128,128)">41</span> <span style="COLOR: rgb(0,0,0)">        }<br /></span><span style="COLOR: rgb(0,128,128)">42</span> <span style="COLOR: rgb(0,0,0)">        <br /></span><span style="COLOR: rgb(0,128,128)">43</span> <span style="COLOR: rgb(0,0,0)">    }<br /></span><span style="COLOR: rgb(0,128,128)">44</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">45</span> <span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,128,128)">46</span> <span style="COLOR: rgb(0,0,0)">}<br /></span><span style="COLOR: rgb(0,128,128)">47</span> <span style="COLOR: rgb(0,0,0)"></span></div><br /><hr width="100%" size="2" />
最后就是看结果了，先启动weblogic，然后运行EJBTest程序。<br /><br /><img height="203" alt="ejb17.jpg" src="http://www.blogjava.net/images/blogjava_net/rickhunter/ejb_myeclipse/ejb17.jpg" width="790" border="0" /><br /><img src ="http://www.blogjava.net/xzclog/aggbug/63403.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xzclog/" target="_blank">xzc</a> 2006-08-14 10:13 <a href="http://www.blogjava.net/xzclog/archive/2006/08/14/63403.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>