• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

EJB Application dev process

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to EJB and I am not sure of the development process that has to be followed.
I recently installed weblogic8.1 and was able to create a test domain for sample application.
I just thought of writing a small stateless bean.
Here is my code and xml files.
------
package agency;
import java.rmi.*;
import javax.ejb.*;
public interface AgencyHome extends EJBHome
{
Agency create() throws RemoteException, CreateException;
}
---
package agency;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface Agency extends EJBObject
{
String getAgencyName() throws RemoteException;
}
---
package agency;
import java.rmi.RemoteException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ejb.*;
import java.util.*;
public class AgencyBean implements SessionBean
{
String name="";
private SessionContext cxt;
public String getAgencyName(){
return name;
}
public void ejbCreate() throws CreateException,NamingException{
InitialContext ic = new InitialContext();
name=(String) ic.lookup("java:comp/env/AgencyName");
}
public void ejbActivate(){
}
public void ejbRemove(){
}
public void ejbPassivate(){
}
public void setSessionContext(SessionContext cxt){
this.cxt = cxt;
}
};
---
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Agency</ejb-name>
<home>agency.AgencyHome</home>
<remote>agency.Agency</remote>
<ejb-class>agency.AgencyBean</ejb-class>

<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>

<env-entry>
<env-entry-name>AgencyName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Saritha</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
</ejb-jar>
---
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN" "http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd">
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Agency</ejb-name>
<jndi-name>Agency</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
----

I compiled by java file.
Created a META-INF directory and placed .xml files in this directory.
Then i jared agency package with class files and META-INF dir into a Agency.jar file.
then i tried to generate skels and stubs using appc tool. This is the command which i have used.
java weblogic.appc Agency.jar
when I run this command, I am getting few warning and exceptions.
I am not sure where i went wrong.
Even I am sure if the process i have followed is correct or not.
What would be output of appc command.
Can anyone please detail me the whole process.
and provide me links where i can find info on this.
Thank you very much in advance.
Saritha
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
coul'd u pls post the appc warning and error messages, it'll be easier to help if u do so. Also take a look at http://edocs.bea.com/wls/docs81/ejb/appc_ejbc.html#1107234 you'll find some information on appc tool there.
 
Saritha Penumudi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are the warnings and exceptions which i got when i run appc
<Apr 22, 2004 1:02:59 PM EDT> <Warning> <EJB> <BEA-010054> <EJB Deployment: Agen
cy has a class agency.AgencyBean that is in the classpath. This class should onl
y be located in the ejb-jar file.>
<Apr 22, 2004 1:03:03 PM EDT> <Warning> <EJB> <BEA-010054> <EJB Deployment: Agen
cy has a class agency.AgencyHome that is in the classpath. This class should onl
y be located in the ejb-jar file.>
<Apr 22, 2004 1:03:03 PM EDT> <Warning> <EJB> <BEA-010054> <EJB Deployment: Agen
cy has a class agency.Agency that is in the classpath. This class should only be
located in the ejb-jar file.>
[J2EE:160119]Appc is unable to process the file 'C:\saritha\EJBSamples\agency\Ag
ency.jar'. The following error occurred:
In EJB Agency, the throws clause for ejbCreate method ejbCreate() contains excep
tions that are NOT in the throws clause of the corresponding home interface meth
od.
at weblogic.ejb20.compliance.EJBComplianceChecker.check(EJBComplianceChe
cker.java:268)
at weblogic.ejb20.compliance.EJBComplianceChecker.checkDeploymentInfo(EJ
BComplianceChecker.java:232)
at weblogic.ejb20.ejbc.EJBCompiler.complianceCheckJar(EJBCompiler.java:8
10)
at weblogic.ejb20.ejbc.EJBCompiler.checkCompliance(EJBCompiler.java:766)
at weblogic.ejb20.ejbc.EJBCompiler.doCompile(EJBCompiler.java:200)
at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:476)
at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:387)
at weblogic.appc.compileEJB(appc.java:802)
at weblogic.appc.compileEJB(appc.java:776)
at weblogic.appc.compileInput(appc.java:463)
at weblogic.appc.runBody(appc.java:184)
at weblogic.utils.compiler.Tool.run(Tool.java:146)
at weblogic.utils.compiler.Tool.run(Tool.java:103)
at weblogic.appc.main(appc.java:1028)
weblogic.ejb20.compliance.ComplianceException: In EJB Agency, the throws clause
for ejbCreate method ejbCreate() contains exceptions that are NOT in the throws
clause of the corresponding home interface method.
at weblogic.ejb20.compliance.HomeInterfaceChecker.checkCreateMethodsMatc
hBeanCreates(HomeInterfaceChecker.java:320)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at weblogic.ejb20.compliance.EJBComplianceChecker.check(EJBComplianceChe
cker.java:278)
at weblogic.ejb20.compliance.EJBComplianceChecker.checkDeploymentInfo(EJ
BComplianceChecker.java:232)
at weblogic.ejb20.ejbc.EJBCompiler.complianceCheckJar(EJBCompiler.java:8
10)
at weblogic.ejb20.ejbc.EJBCompiler.checkCompliance(EJBCompiler.java:766)
at weblogic.ejb20.ejbc.EJBCompiler.doCompile(EJBCompiler.java:200)
at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:476)
at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:387)
at weblogic.appc.compileEJB(appc.java:802)
at weblogic.appc.compileEJB(appc.java:776)
at weblogic.appc.compileInput(appc.java:463)
at weblogic.appc.runBody(appc.java:184)
at weblogic.utils.compiler.Tool.run(Tool.java:146)
at weblogic.utils.compiler.Tool.run(Tool.java:103)
at weblogic.appc.main(appc.java:1028)
--------------- nested within: ------------------
weblogic.utils.compiler.ToolFailureException: [J2EE:160121]Errors encountered wh
ile compiling module 'C:\saritha\EJBSamples\agency\Agency.jar':
In EJB Agency, the throws clause for ejbCreate method ejbCreate() contains excep
tions that are NOT in the throws clause of the corresponding home interface meth
od.
- with nested exception:
[
In EJB Agency, the throws clause for ejbCreate method ejbCreate() contains excep
tions that are NOT in the throws clause of the corresponding home interface meth
od.
]
at weblogic.appc.compileEJB(appc.java:781)
at weblogic.appc.compileInput(appc.java:463)
at weblogic.appc.runBody(appc.java:184)
at weblogic.utils.compiler.Tool.run(Tool.java:146)
at weblogic.utils.compiler.Tool.run(Tool.java:103)
at weblogic.appc.main(appc.java:1028)
Thank u very much
Saritha
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Saritha ventrapragada:
These are the warnings and exceptions which i got when i run appc
[J2EE:160119]Appc is unable to process the file 'C:\saritha\EJBSamples\agency\Ag
ency.jar'. The following error occurred:
In EJB Agency, the throws clause for ejbCreate method ejbCreate() contains excep
tions that are NOT in the throws clause of the corresponding home interface meth
od.
Saritha


Hi,
weblogic is so good in it's error messages. You see the error is because you 're trying to throw NamingExceptin from the ejbCreate method from your bean and you didn't do it from the create method on the home interface create method. Take out the NamingException from the ejbCreate(use try/catch instead) and it should work.
 
Saritha Penumudi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
thnak u very much.
i was able to deploy and run my example successfuly.
but my client was just an simple java code.
but i want to use jsp as my front end and use my enterprise bean as middleware.
For this i have converted my java client program into a java bean class.
Jsp would communicate with this Javabean which would inturn delegates request to the enterprise bean.
To run this I have use web.xml and weblogic.xml deployment descriptors along with ejb-jar.xml and weblogic-ejb-jar.xml.
But I am not sure how to should i go about generating web.xml,weblogic.xml and how to configure these.
I tried generating these files with utilities provided my weblogic. but i could not find context setting in web.xml and weblogic.xml was almost null except with start and end tags.
If u can provide some samples of these and let me know if my approach is correct would be great help to me.
thank u
saritha
P.s: I did not use struts till now and intially i wanted to try this example without using struts.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may find WebLogic Builder tool helpful in configuring your web.xml and weblogic.xml files. You can run this by executing:
weblogic81\server\bin\startWLBuilder.cmd (or startWLBuilder.sh on unix).
It asks for the exploded or jar-ed file in the File->Open menu. After that it allows you to do the configuration and save it. It will create the files for you if they are not already there.
For more on WLBuilder, refer online docs:
http://e-docs.bea.com/wls/docs81/wlbuilder/
 
Saritha Penumudi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much
I was able to run a sample jap page using weblogic8.1
Now i wanted to try same application using struts.
But I am not able to configure struts in weblogic8.1
Can anyone please help me out in using struts with weblogic8.1.
I would appreciate if anyone detail me the process step-by-step.
I was working on this since souple of days and no progress..
Hope to see ur replies soon
saritha
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic