<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    JBoss6 - JNDI - Remoting
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/sirwayne">Michael Müller</a> in <i>JNDI and Naming</i> - <a href="http://community.jboss.org/message/602445#602445">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hello community,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>i have some question how i can use RMI and JNDI with SessionScopes?</p><p>I get always a error on the client side the weld context is no active: I use JBoss6.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Here my example on Serverside:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Interfaces:</p><p>{code} </p><p>@Remote</p><p>public interface ContractRemoteService{</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160; Set&lt;String&gt; getContracts();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code}</p><p>@Remote</p><p>public interface LoginRemoteService{</p><p>&#160;&#160;&#160;&#160; public void login(String name)</p><p>}</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Impl</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Stateful</p><p>public class ContractRemoteServiceImpl implements ContractRemoteService{</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Inject</p><p>private UserBean userBean;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Overide</p><p>public Set&lt;String&gt; getContracts(){</p><p>&#160;&#160;&#160;&#160; Set&lt;String&gt; contracts = new HashSet&lt;String&gt;();</p><p>&#160;&#160;&#160;&#160; contracts.add(&amp;quot;contract1&amp;quot;);</p><p>&#160;&#160;&#160;&#160; contracts.add(&amp;quot;contract2&amp;quot;);</p><p></p><p>&#160;&#160;&#160;&#160; if(userBean.getName().equals(&amp;quot;test&amp;quot;)){</p><p>&#160;&#160;&#160;&#160; contracts.add(&amp;quot;contract3&amp;quot;);</p><p>&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160; return contracts;</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>}</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code}</p><p>@Stateful</p><p>public class LoginRemoteServiceImpl implements LoginRemoteService{</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Inject</p><p>private UserBean user;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160; @Override</p><p>&#160;&#160;&#160;&#160; public void login(String name){</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; user.setName(name);</p><p>&#160;&#160;&#160;&#160; }</p><p>}</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Bean</p><p>{code}</p><p>@Stateful</p><p>@SessionScoped</p><p>public class UserBean{</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>private String name;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public setName(String name){</p><p>&#160;&#160;&#160;&#160; this.name = name;</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public String getName(){</p><p>&#160;&#160;&#160;&#160; return name;</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>}</p><p>{code}</p><p></p><p>The client side:</p><p>{code}</p><p>public class Client{</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public static void main(String [] args) throws Exceptions{</p><p>&#160;&#160;&#160;&#160; Context context = new InitialContext();</p><p>&#160;&#160;&#160;&#160; LoginRemoteService loginService = (LoginRemoteService) context.lookup(&amp;quot;LoginRemoteServiceImpl/remote&amp;quot;);</p><p>&#160;&#160;&#160;&#160; ContractRemoteService contractService = (ContractRemoteService) context.lookup(&amp;quot;ContractRemoteServiceImpl&amp;quot;);</p><p>&#160;&#160;&#160;&#160; loginService.login(&amp;quot;Mhm?&amp;quot;);</p><p>&#160;&#160;&#160;&#160; contractSerive.getContracts();// autsch</p><p>}</p><p>}</p><p>{code}</p><p>Error Message:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>WELD-001303 no active contexts for scope javax.enterprise.context.SessionScoped</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>How can i activate the Context?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks =)</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/602445#602445">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JNDI and Naming at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>