dev@glassfish.java.net

Re: Is bean class required in the appClient.jar?

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Wed, 13 Aug 2008 15:58:09 -0400

On Aug 13, 2008, at 3:17 PM, Tom Shi wrote:

> Thanks, Ken.
>
> I removed the converter-ejb.jar from the appClient.jar, add the
> Converter.class and remove <ejb-link>converter-
> ejb.jar#ConverterBean</ejb-link> in the application-client.xml. It
> works with appclient.bat now
>
> Now, my questions is:
>
> Is there any command/utility that can be used to create a 'clean'
> appclient jar file for application container, without the ejb jar or
> the ejb-link?
>

If the application client module is packaged in the same .ear as the
ejb-jar it's a known bug that
the deployment code adds superfluous classes to the generated
client.jar. I don't know of any
workaround in that case. One alternative is to deploy the
application client module on its own.

>
>
> --- On Wed, 8/13/08, Kenneth Saks <Kenneth.Saks_at_Sun.COM> wrote:
> From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
> Subject: Re: Is bean class is required in the appClient.jar?
> To: dev_at_glassfish.dev.java.net
> Date: Wednesday, August 13, 2008, 1:59 PM
>
>
> On Aug 13, 2008, at 1:35 PM, Tom Shi wrote:
>
>> In the javaeetutorial5\examples\ejb\converter example from Sun J2EE
>> tutorial, the ConverterBean class is in the appClient.jar. Is the
>> bean class real needed in the appClient.jar?
>
> No. The bean class plays no role in the client programming model.
>
>> I though the interface Converter should be enough for the appclient.
>>
>> In the stand-alone Java client, it works fine without bean class,
>> just need the interface.
>>
>> ConvertClient.java
>>
>> /*
>> * Copyright 2007 Sun Microsystems, Inc.
>> * All rights reserved. You may not modify, use,
>> * reproduce, or distribute this software except in
>> * compliance with the terms of the License at:
>> * http://developer.sun.com/berkeley_license.html
>> */
>>
>> package converter.client;
>> import converter.ejb.Converter;
>> import java.math.BigDecimal;
>> import javax.ejb.EJB;
>>
>> /**
>> *
>> * @author ian
>> */
>> public class ConverterClient {
>> @EJB
>> private static Converter converter;
>> /** Creates a new instance of Client */
>> public ConverterClient(String[] args) {
>> }
>> /**
>> * @param args the command line arguments
>> */
>> public static void main(String[] args) {
>> ConverterClient client = new ConverterClient(args);
>> client.doConversion();
>> }
>> public void doConversion() {
>> try {
>> BigDecimal param = new BigDecimal("100.00");
>> BigDecimal yenAmount = converter.dollarToYen(param);
>> System.out.println("$" + param + " is " + yenAmount + "
>> Yen.");
>> BigDecimal euroAmount = converter.yenToEuro(yenAmount);
>> System.out.println(yenAmount + " Yen is " + euroAmount
>> + " Euro.");
>> System.exit(0);
>> } catch (Exception ex) {
>> System.err.println("Caught an unexpected exception!");
>> ex.printStackTrace();
>> }
>> }
>> }
>> ----------------------------------------------------------
>> Converter.java
>> /*
>> * Copyright 2007 Sun Microsystems, Inc.
>> * All rights reserved. You may not modify, use,
>> * reproduce, or distribute this software except in
>> * compliance with the terms of the License at:
>> * http://developer.sun.com/berkeley_license.html
>> */
>>
>> package converter.ejb;
>> import java.math.BigDecimal;
>> import javax.ejb.Remote;
>>
>> @Remote
>> public interface Converter {
>> public BigDecimal dollarToYen(BigDecimal dollars);
>> public BigDecimal yenToEuro(BigDecimal yen);
>> }
>>
>> -----------------------------------------------
>> ConverterBean.java
>> /*
>> * Copyright 2007 Sun Microsystems, Inc.
>> * All rights reserved. You may not modify, use,
>> * reproduce, or distribute this software except in
>> * compliance with the terms of the License at:
>> * http://developer.sun.com/berkeley_license.html
>> */
>>
>> package converter.ejb;
>> import java.math.BigDecimal;
>> import javax.ejb.Stateless;
>>
>> /**
>> * This is the bean class for the ConverterBean enterprise bean.
>> * Created Jan 20, 2006 1:14:27 PM
>> * @author ian
>> */
>> @Stateless
>> public class ConverterBean implements converter.ejb.Converter {
>> private BigDecimal euroRate = new BigDecimal("0.0070");
>> private BigDecimal yenRate = new BigDecimal("112.58");
>> public BigDecimal dollarToYen(BigDecimal dollars) {
>> BigDecimal result = dollars.multiply(yenRate);
>> return result.setScale(2, BigDecimal.ROUND_UP);
>> }
>> public BigDecimal yenToEuro(BigDecimal yen) {
>> BigDecimal result = yen.multiply(euroRate);
>> return result.setScale(2, BigDecimal.ROUND_UP);
>> }
>> }
>>
>>
>>
>
>