Skip to main content

error in generated ejb-jar.xml

4 replies [Last post]
sahlix
Offline
Joined: 2007-02-01

Hi there.

I have a stateless session bean running on GF V2 beta 2 (b41d). It's a simple bean with two methods both of which are exposed in a local and remote interface:

<br />
@Remote<br />
public interface SendMailRemote<br />
{<br />
    void sendMail(String email, String subject, String body);<br />
    void sendMail(String email, String replyTo, String subject, String body);<br />
}</p>
<p>and:</p>
<p>@Local<br />
public interface SendMailLocal<br />
{<br />
    void sendMail(String email, String subject, String body);<br />
    void sendMail(String email, String replyTo, String subject, String body);<br />
}<br />

The bean code itself is:

<br />
@Stateless(mappedName="ejb3/SendMailRemote")<br />
public class SendMailBean implements SendMailRemote, SendMailLocal<br />
{<br />
...<br />
}<br />

Pretty straightforward so far. The bean resides in an ejb jar which is included in an ear.
In sun-ejb-jar.xml I have

</p>
<p>      SendMailBean<br />
      ejb3/SendMailRemote</p>
<p>

under node (even though not really necessary).

Thus the interfaces never show up in the jndi browser. Further investigation reveals the following generated xml:

</p>
<p>SendMailBean<br />
SendMailBean<br />
ejb3/SendMailRemote<br />
com.brodos.ejb3.mail.SendMailLocal<br />
com.brodos.mail.SendMailRemote<br />
com.brodos.ejb3.mail.SendMailBean<br />
Stateless<br />
Container</p>
<p>mail/Brodos<br />
javax.mail.Session<br />
Container<br />
Shareable</p>
<p>com.brodos.ejb3.mail.SendMailBean<br />
mailBrodos</p>
<p>

from the 'generated' directory under domain1 directory.

Note the line com.brodos.mail.SendMailRemote should be business-remote!

Alexander.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sahlix
Offline
Joined: 2007-02-01

I think I got it:

If the SendMailRemote class lies in another java package than the Bean class then the error occurres.

If the java packages of the Remote class and the Bean itself are the same, the generated ejb-jar is correct and the Beans (and it's interfaces) show up in the JNDI Browser even if the Remote class lies in the RIF-jar.

I really consider this as a glassfish bug.

Alexander.

Sahoo

Can you file a bug with a reproducible test case?

Thanks,
Sahoo

glassfish@javadesktop.org wrote:
> I think I got it:
>
> If the SendMailRemote class lies in another java package than the Bean class then the error occurres.
>
> If the java packages of the Remote class and the Bean itself are the same, the generated ejb-jar is correct and the Beans (and it's interfaces) show up in the JNDI Browser even if the Remote class lies in the RIF-jar.
>
> I really consider this as a glassfish bug.
>
> Alexander.
> [Message sent by forum member 'sahlix' (sahlix)]
>
> http://forums.java.net/jive/thread.jspa?messageID=223017
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

I just tried your example with V2 b48-beta3, and it worked. Can you
check your code again? Are there multiple SendMailRemote.class with
different package names?

Another observation about your example:
Although you are using different interface names for remote and local
business interface of your bean, they still have same method signatures
and hence the bean will have the same implementation for both the
interfaces. That's usually dangerous, because the remote and local
interfaces have different semantics for argument passing; pass-by-value
vs. pass-by-reference. It's not a problem in your example now, because
all the arguments are immutable types.

Thanks,
Sahoo
glassfish@javadesktop.org wrote:
> Hi there.
>
> I have a stateless session bean running on GF V2 beta 2 (b41d). It's a simple bean with two methods both of which are exposed in a local and remote interface:
>
> [code]
> @Remote
> public interface SendMailRemote
> {
> void sendMail(String email, String subject, String body);
> void sendMail(String email, String replyTo, String subject, String body);
> }
>
> and:
>
> @Local
> public interface SendMailLocal
> {
> void sendMail(String email, String subject, String body);
> void sendMail(String email, String replyTo, String subject, String body);
> }
> [/code]
>
> The bean code itself is:
> [code]
> @Stateless(mappedName="ejb3/SendMailRemote")
> public class SendMailBean implements SendMailRemote, SendMailLocal
> {
> ...
> }
> [/code]
>
> Pretty straightforward so far. The bean resides in an ejb jar which is included in an ear.
> In sun-ejb-jar.xml I have
> [code]
>
> SendMailBean
> ejb3/SendMailRemote
>

> [/code]
> under [code][/code] node (even though not really necessary).
>
> Thus the interfaces never show up in the jndi browser. Further investigation reveals the following generated xml:
>
> [code]
>
> SendMailBean
> SendMailBean
> ejb3/SendMailRemote
> com.brodos.ejb3.mail.SendMailLocal
> com.brodos.mail.SendMailRemote
> com.brodos.ejb3.mail.SendMailBean
> Stateless
>
Container >
> mail/Brodos
> javax.mail.Session
> Container
> Shareable
>
> com.brodos.ejb3.mail.SendMailBean
> mailBrodos
>

>

>
>
>

>

> [/code]
>
> from the 'generated' directory under domain1 directory.
>
> Note the line [b]com.brodos.mail.SendMailRemote[/b] should be [b]business-remote[/b]!
>
> Alexander.
> [Message sent by forum member 'sahlix' (sahlix)]
>
> http://forums.java.net/jive/thread.jspa?messageID=222866
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

sahlix
Offline
Joined: 2007-02-01

Thanks Sahoo for your quick answer.

I have only one SendMailRemote class in my packages. I investigated further and think that it has to do with the packaging of my project.

The packaging schema is this:
[pre]
EAR contains:
ejb module: SendMailBean.class
web module: references SendMailBean locally
jar-file with SendMailRemote.class
[/pre]

The jar file contains just the Remote interface class. This helps me to reference the bean using the remote interface from other ejb, web and ear modules. The jar file (which i call RIF-jar which stands for [b]R[/b]emote [b]I[/b]nter[b]F[/b]ace) is then packaged in the referencing module so the class loader can successfully load and instantiate the remote interface class. This construction works for some ejb modules in use.

When I move the SendMailRemote class to the EJB-jar everything works fine and I can see the JNDI entries. When the SendMailRemote class resides in the RIF-jar it does not show up and the generated ejb-jar.xml is wrong.

I also took the corresponding part from the generated ejb-jar.xml file, corrected it and put it into the ejb-jar.xml of my EJB module. After that everything is fine.

But I think it's an error in glassfish's generator that generates the deployment descriptor from the annotations.

Alexander.