Vous êtes sur la page 1sur 3

First application in EJB 3.0 and JBoss...

Piotr Lizurek 13 posts since


Oct 27, 2006
Hi!
I am brand new to EJB 3.0 programming and I need some help.
I have simple bean class (StatelessTekst1.java):

import org.jboss.annotation.ejb.LocalBinding;
import javax.ejb.*;

@Stateless
public class StatelessTekst1 implements tekst1
{
public String podajTekst(int numer)
{
if(numer==1)
return "Hej, udalo sie!";
}
}

And interface (tekst1.java):


public interface tekst1
{
public String podajTekst(int numer);
}

I put this files to <JAVA_HOME>/bin directory. But, when I want to compile the StatelessTekst1.java file, I get an
errors:
-------------------------------------------------------------------------------------
C:\Program Files\Java\jdk1.5.0_05\bin>javac StatelessTekst1.java
StatelessTekst1.java:1: package org.jboss.annotation.ejb does not exist
import org.jboss.annotation.ejb.LocalBinding;
^
StatelessTekst1.java:2: package javax.ejb does not exist
import javax.ejb.*;
^
StatelessTekst1.java:4: cannot find symbol
symbol: class Stateless
@Stateless
^

Generated by Jive SBS on 2010-07-17-04:00


1
First application in EJB 3.0 and JBoss...

3 errors
-------------------------------------------------------------------------------------
So, I add the classpath to the javac:

C:\Program Files\Java\jdk1.5.0_05\bin>javac -classpath .;c:/"program files"/jboss/client/jboss-ejb3-


client.jar;c:/"program files"/jboss/client/jboss-j2ee.jar StatelessTekst1.java

But again I have an error:

StatelessTekst1.java:1: package org.jboss.annotation.ejb does not exist


import org.jboss.annotation.ejb.LocalBinding;
^
1 error

What should I do to compile this files? Please, help me!


Thanks and best regards!

jaikiran pai 7,360 posts since


May 18, 2005 Reply 1. Re: First application in EJB 3.0 and JBoss 4.0.5GA Oct 28, 2006 8:43 AM

You will have to include the jar containing the org.jboss.annotation.ejb.LocalBinding class, in
your classpath. I dont exactly remember the name of that jar but i guess it is something like
jboss-annotations.jar.

jaikiran pai 7,360 posts since


May 18, 2005 Reply 2. Re: First application in EJB 3.0 and JBoss 4.0.5GA Oct 28, 2006 8:46 AM

import org.jboss.annotation.ejb.LocalBinding;
import javax.ejb.*;

@Stateless
public class StatelessTekst1 implements tekst1
{
public String podajTekst(int numer)
{
if(numer==1)
return "Hej, udalo sie!";
}
}

On second thoughts, i dont see the need of the following import statement in your code:

import org.jboss.annotation.ejb.LocalBinding;

Generated by Jive SBS on 2010-07-17-04:00


2
First application in EJB 3.0 and JBoss...

Remove this import statement and your code should compile fine.

Piotr Lizurek 13 posts since


Oct 27, 2006 Reply 3. Re: First application in EJB 3.0 and JBoss 4.0.5GA Oct 29, 2006 12:03 AM

Yes, You are right! I remowe this import and everything goes OK.
Thanks!

Generated by Jive SBS on 2010-07-17-04:00


3

Vous aimerez peut-être aussi