wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Compilation problem! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Compilation problem!" Watch "Compilation problem!" New topic
Author

Compilation problem!

Rosaline Hanna
Greenhorn

Joined: Jan 16, 2006
Posts: 24
Dear Friends,
I am new to EJB technology,and i am using HF for EJB.
in the first chapter when i try to compile the 3 java files of the EJB, I got errors in compilation like :
package javax.ejb does not exist
import javax.ejb.*;
^

I use JDK 1.4,
I have tried to put j2ee.jar in the classpath but no use,i have tried to put the jar file in /jre/lib/ext ,it compiled fine,but when i wanted to start the server,i got the following error:
Warning: This J2EE SDK release is designed to run on J2SE 1.3
No local string for j2ee.listenPort
J2EE server listen port: 1050
No local string for j2ee.naming
Naming service started: 1050
No local string for enterprise.log.logging.serverversion.started
No local string for enterprise.log.using.vm.name.version.from
No local string for enterprise.log.vm's.classpath
No local string for enterprise.log.j2ee.homedirectory
No local string for enterprise.log.logging.serverversion.started
No local string for enterprise.log.using.vm.name.version.from
No local string for enterprise.log.vm's.classpath
No local string for enterprise.log.j2ee.homedirectory
No local string for idle_resource_threshold_error
No local string for binding.datasource

No local string for binding.datasource

No local string for binding.datasource

No local string for binding.datasource

No local string for binding.datasource

No local string for binding.datasource

java.lang.ClassNotFoundException: COM.cloudscape.core.RemoteXaDataSource
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at com.sun.enterprise.repository.JdbcXAResource.createDataSource(JdbcXAR
esource.java:69)
and so on...

so what shall i do?
Thanks in advance,
Rose


SCJP 5
JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303
Hi Rose,

This looks like a j2ee version issue. Perhaps, you can try using an earlier version of j2ee. the datasource error looks like ur jndi is nt configured properly.

which app server are u using? plz refer to the attached docs for configuring jdbc datasources.


SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Rajesh Pandey Rajesh Pandey
Greenhorn

Joined: Mar 12, 2006
Posts: 24
Hi Rose
i want to say you that set enviroment then try to compile that java programme .Actually ypu are beginer so i am being explain step by step
suppose your java programme in C drive folder name rajesh then first copy "setEnv" from your Application server & put it in rajesh folder after that open setEnv and add rajesh folder in classpath add C:\rajesh; After that go on command prompt write cd c:/rajesh after that set environment for this setEnv on command prompt now you can use javac to compile your java programme.Now it will not display such error

Regards
Rajesh Pandey
Mob:-+919811903737
email:- rajesh-pandey@hotmail.com
Freelance software Developer
india Delhi
Rajesh Pandey Rajesh Pandey
Greenhorn

Joined: Mar 12, 2006
Posts: 24
Hello Freind

i am expain all the process and i think it will help all those freind which are beginer for ejb that you will not get any problem that i you r beginer..you can deploy programme as below 1) write all java programme like Remote interface home interface Bean class in case entity primary key class etc
2)Make Deployment descriptor which is inside META-INF for this u can use ant command which i have explain below

3)Make jar file & corresponding skeleton for this use command on command prompt

4)After that start Application server and upload skeleton

5) Now your application completed

6)For checking write client code and compile it If you try as i have explain then sure your application will success
Suppose you have deploye a countBean
first copy setEnv and paste in
C:\rajesh <p>all file of ejb in that add rajesh folder in classpath inside setEnv
First CountRemote will be as below <p>
import javax.ejb.*;
import java.rmi.*;
public interface CountRemote extends EJBObject
{public int abc() throws RemoteException;
}<p>
After that write CountHome which is Home interface
import javax.ejb.*;
import java.rmi.*;
public interface CountHome extends EJBHome
{CountRemote create(int p) throws RemoteException,CreateException;
}
After that Bean
import javax.ejb.*;
public class CountBean implements SessionBean
{private SessionContext ctx;
private int p;
public int abc()
{System.out.println("abc(int p)");
return ++p;
}
public void ejbCreate(int p) throws CreateException
{System.out.println("ejbCreate()");
this.p=p;
}
public void ejbRemove()
{System.out.println("ejbRemove()");}
public void ejbActivate()
{System.out.println("ejbActivate()");}
public void ejbPassivate()
{System.out.println("ejbPassivate()");}
public void setSessionContext(SessionContext ctx)
{}
}
After that Client code
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import java.util.*;
public class Count
{public static void main(String args[])
{
try
{Properties p=new Properties();p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ctx=new InitialContext(p);
CountHome CH=(CountHome) ctx.lookup("xyz");
CountRemote A[]=new CountRemote[3];
int abcp=0;
System.out.println("Initializing Bean ........");
for(int i=0;i<3;i++)
{A[i]=CH.create(abcp);
abcp=A[i].abc();
System.out.println(abcp);
Thread.sleep(500);

}
// Calling abc() on each EJB Object
System.out.println("Calling abc() on bean ");
for(int i=0;i<3;i++)
{abcp=A[i].abc();
System.out.println(abcp);
Thread.sleep(500);

}
// Removing object
for(int i=0;i<3;i++)
{
A[i].remove();
}
}catch(Exception e){}
}
}
<p> compile all as <p>
C:\rajesh>javac countRemote.java
C:\rajesh>javac countHome.java
C:\rajesh>javac countBean.java
C:\rajesh>javac count.java
After compile all file
go command prompt suppose all java file in rajesh folder<p>
write ant command as below :--
c\rajesh >java weblogic.ant.taskdefs.ejb.DDInit it create META_INF inside you will get xml equivalent deployment descriptor
c:\rajesh>jar cvf cc.jar *.*
which make jar file as compress file
c:\rajesh>java weblogic.ejbc cc.jar ccc.jar <p> you will get a jar file which you have to upload. and finally
c:\rajesh>java Count
which give result Finnaly i think this example help lot of freind

Regards
Rajesh Pandey
Mob :- +919811903737
email :- rajesh-pandey@hotmail.com
Rajesh Pandey Rajesh Pandey
Greenhorn

Joined: Mar 12, 2006
Posts: 24
Hello Freind <p>
You can try it as below.I think that this eample can help your<p>
import java.rmi.*;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;
public class Rajesh
{public static void main(String args[])
{try
{
Properties ptr=new Properties();
ptr.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ptr.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ct=new InitialContext(ptr);
RajHome rh=(RajHome)ct.lookup("pandey");
RajRemote rr=rh.create();
String snp=rr.pandey();
System.out.print("Result"+snp);
rr.remove();

}catch(Exception e)
{System.out.println("Error : " +e);}

}

}
<p>
Best Regards<p>
Rajesh Pandey <p>
email :--rajesh-pandey@hotmail.com<p>
mobile :--+919811903737<p>
india ,Delhi
info@sixthquadrant.com
info@techraysolutions.com
www.techraysolutions.com
 
Don't get me started about those stupid light bulbs.
 
subject: Compilation problem!
 
Similar Threads
java.lang.NoClassDefFoundError
Illegal UTF8 string in constant pool?
Start j2ee server - NoClassDefFoundError - Please help!
Ant + Weblogic + EJb on Eclipse - UnsupportedClassVersionError
JaxP with Oracle 9i