@Ejb is not allowed in this location

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

@Ejb is not allowed in this location

Karen Goh
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 ?




Reply | Threaded
Open this post in threaded view
|

Re: @Ejb is not allowed in this location

Roberto Cortez
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 <[hidden email]> 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 ?
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: @Ejb is not allowed in this location

Karen Goh
In reply to this post by Karen Goh
Sorry for the late reply.

Thanks Roberto and Bruno.

The thing is that I have been trying to fix MYSQL server timezone problem till now so I really can't test out what you guys have suggested.

I am hoping this email I can get to know if there is any light weight database I can try out with Eclipse Oxygen so that  I can test the CDI stuff and TomEE.

Tks & regards,
Karen
--------------------------------------------
On Mon, 12/17/18, Roberto Cortez <[hidden email]> wrote:

 Subject: Re: @Ejb is not allowed in this location
 To: [hidden email], "Karen Goh" <[hidden email]>
 Date: Monday, December 17, 2018, 6:50 PM
 
 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 <[hidden email]>
 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 ?
 >
 >
 >
 >
 
Reply | Threaded
Open this post in threaded view
|

Re: @Ejb is not allowed in this location

Roberto Cortez
You can always use HSQLDB which is an in memory database that ships with TomEE. It should be straightforward to use, since the server will create one for you by default.

Are you trying to use JPA?

> On 17 Dec 2018, at 15:52, Karen Goh <[hidden email]> wrote:
>
> Sorry for the late reply.
>
> Thanks Roberto and Bruno.
>
> The thing is that I have been trying to fix MYSQL server timezone problem till now so I really can't test out what you guys have suggested.
>
> I am hoping this email I can get to know if there is any light weight database I can try out with Eclipse Oxygen so that  I can test the CDI stuff and TomEE.
>
> Tks & regards,
> Karen
> --------------------------------------------
> On Mon, 12/17/18, Roberto Cortez <[hidden email]> wrote:
>
> Subject: Re: @Ejb is not allowed in this location
> To: [hidden email], "Karen Goh" <[hidden email]>
> Date: Monday, December 17, 2018, 6:50 PM
>
> 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 <[hidden email]>
> 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 ?
>>
>>
>>
>>
>