• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to devlop and deploy EJB

 
anubha goel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to EJB,i wrote beans(home,remote and bean)
and created its deployment descriptors using weblogic8.1
then I followed few steps such as:-

create the jar file by the following command;

f:\ejbdemo>jar cf sqlejbpack.jar
demo1\*.class META-INF\*.xml

deploy the jar using the following command
f:\ejbdemo>java weblogic.ejbc sqlejbpack.jar sqlejbpack1.jar


the deploy command didn't worked in my case it displayed the following error:-

ERROR: Error from ejbc: Compiler class: 'com.sun.tools.javac.Main', not found
ERROR: ejbc couldn't invoke compiler

please help me out.
I also wanted to know the purpose of creating jar files.


Thanks & Regards,
Anubha.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Is that possible to send the code snippets.

and DD files too. Seems the problem with the same.

If weblogic.ejbc doesn't work for you use weblogic.appc even it do the same work as our ejbc.

Creating stub checking for the xml and all.

Regards

Jetendra
 
anubha goel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The DD files are as under:
weblogic-ejb-jar.xml
<!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'>


<!-- Generated XML! -->

<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>sqlBean</ejb-name>
<stateless-session-descriptor>
<pool>
</pool>

<stateless-clustering>
</stateless-clustering>

</stateless-session-descriptor>

<transaction-descriptor>
</transaction-descriptor>

<jndi-name>ejbpackJndi</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
----------------------------------------
ejb-jar.xml

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>


<!-- Generated XML! -->

<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>sqlBean</ejb-name>
<home>demo1.sqlHome</home>
<remote>demo1.sqlRemote</remote>
<ejb-class>demo1.sqlBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>

<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>sqlBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>

</ejb-jar>
-----------------------------------------------------
sqlRemote.java

package demo1;
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface sqlRemote extends EJBObject{
public String getresult(String s)throws RemoteException;

}
--------------------------------------------------------
sqlHome.java

package demo1;
import javax.ejb.*;
import java.rmi.*;

public interface sqlHome extends EJBHome
{
public sqlRemote create()throws RemoteException,CreateException;

}
-------------------------------------------------------------------

sqlBean.java

package demo1;
import javax.ejb.*;
import java.util.*;
import java.sql.*;
public class sqlBean implements SessionBean
{

public String getresult(String sql)
{
System.out.println("helllllloooo");
//usual code to be written
return sql;
}
public void ejbCreate(){}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}
public void setSessionContext(SessionContext sc){}

}
------------------------------------------------------------------

ejbCaller.java (client)

package ourpack;
import java.util.*;
import javax.rmi.*;
import javax.ejb.*;
import javax.naming.*;

import demo1.sqlHome;
import demo1.sqlRemote;

import java.io.*;
import java.rmi.*;
public class ejbCaller {
public String callejb(String s)
{
String r;
try
{
System.out.println("Please Wait");
Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL,"t3://127.0.0.1:7001");
Context ctx=new InitialContext(prop);
System.out.println("CONTEXT READY");
demo1.sqlHome home=(demo1.sqlHome)ctx.lookup("ejbpackjndi");
System.out.println("HOME LOCATED");
sqlRemote remote=home.create();
System.out.println("REMOTE READY");
r=remote.getresult(s);
}
catch(Exception e1){
r=""+e1;

}

return r;
}
}
--------------------------------------------------
this is the code and deployment descriptors...

Thanks & Regards,
Anubha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic