<!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 - SessionScoped
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/sirwayne">Michael Müller</a> in <i>JBoss Remoting Development</i> - <a href="http://community.jboss.org/message/602512#602512">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;"> </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;"> </p><p>Here my example on Serverside:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Interfaces:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code"> @Remote<br/>public interface ContractRemoteService{<br/><br/>     Set<String> getContracts();<br/><br/>}</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code"> @Remote<br/>public interface LoginRemoteService{<br/>     public void login(String name)<br/>}</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Impl:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">@Stateful<br/>public class ContractRemoteServiceImpl implements ContractRemoteService{<br/><br/>@Inject<br/>private UserBean userBean;<br/><br/>@Overide<br/>public Set<String> getContracts(){<br/>     Set<String> contracts = new HashSet<String>();<br/>     contracts.add(&amp;quot;contract1&amp;quot;);<br/>     contracts.add(&amp;quot;contract2&amp;quot;);<br/><br/>     if(userBean.getName().equals(&amp;quot;test&amp;quot;)){<br/>     contracts.add(&amp;quot;contract3&amp;quot;);<br/>     }<br/>     return contracts;<br/>}<br/><br/>}</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">@Stateful<br/>public class LoginRemoteServiceImpl implements LoginRemoteService{<br/><br/>@Inject<br/>private UserBean user;<br/><br/>     @Override<br/>     public void login(String name){<br/>         user.setName(name);<br/>     }<br/>}</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Bean:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">@Stateful<br/>@SessionScoped<br/>public class UserBean{<br/><br/>private String name;<br/><br/>public setName(String name){<br/>     this.name = name;<br/>}<br/><br/>public String getName(){<br/>     return name;<br/>}<br/><br/>}</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The client side:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">public class Client{<br/><br/>public static void main(String [] args) throws Exceptions{<br/>     Context context = new InitialContext();<br/>     LoginRemoteService loginService = (LoginRemoteService) context.lookup(&amp;quot;LoginRemoteServiceImpl/remote&amp;quot;);<br/>     ContractRemoteService contractService = (ContractRemoteService) context.lookup(&amp;quot;ContractRemoteServiceImpl&amp;quot;);<br/>     loginService.login(&amp;quot;Mhm?&amp;quot;);<br/>     contractSerive.getContracts();// autsch<br/>}<br/>}</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Error Message:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>WELD-001303 no active contexts for scope javax.enterprise.context.SessionScoped</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>How can i activate the Context?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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/602512#602512">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Remoting Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2051">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>