You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Karen Goh <ka...@yahoo.com.INVALID> on 2018/12/16 02:12:55 UTC
@Ejb is not allowed in this location
Hi,
I am trying to use this example below a a guide but it says @Ejb is not allowed in this location
http://tomee.apache.org/examples-trunk/cdi-application-scope/
The place where I put @EJB is at a method and it is inside a tutorSubjectDAOImpl class:
public void insertTutor_Subject(int tutor_id, List<String> subjNames)throws MyDataException {
openConnection();
if(connection != null)
try {
stmt3 = connection.createStatement();
PreparedStatement ps3 = connection.prepareStatement("INSERT INTO xxx.tutor_subject1(tutor_id, subject_Name) VALUES (?, ?);");
//stmt3 = (Statement) connection.createStatement();
@Ejb
Tutor m;
tutor_id = m.getTutor_id();
If @EJB is not allowed here, what is the right annotation to use in order for the Tutor Id to be used here in this method ?
Re: @Ejb is not allowed in this location
Posted by Roberto Cortez <ra...@yahoo.com.INVALID>.
Hi Karen,
Can you please try to place the Tutor definition as a field variable of the class and annotate it with the @EJB?
Cheers,
Roberto
> On 16 Dec 2018, at 02:12, Karen Goh <ka...@yahoo.com.INVALID> wrote:
>
> Hi,
>
> I am trying to use this example below a a guide but it says @Ejb is not allowed in this location
>
> http://tomee.apache.org/examples-trunk/cdi-application-scope/
>
> The place where I put @EJB is at a method and it is inside a tutorSubjectDAOImpl class:
>
> public void insertTutor_Subject(int tutor_id, List<String> subjNames)throws MyDataException {
>
> openConnection();
> if(connection != null)
> try {
> stmt3 = connection.createStatement();
> PreparedStatement ps3 = connection.prepareStatement("INSERT INTO xxx.tutor_subject1(tutor_id, subject_Name) VALUES (?, ?);");
> //stmt3 = (Statement) connection.createStatement();
>
> @Ejb
> Tutor m;
> tutor_id = m.getTutor_id();
>
> If @EJB is not allowed here, what is the right annotation to use in order for the Tutor Id to be used here in this method ?
>
>
>
>