Hi Karen,
WELD is CDI implementation, but on TomEE we include Apache OpenWebBeans,
so no need for WELD.
If the bean you are injecting is a simple CDI bean, you don't need the
@EJB annotation. Please use @Inject instead.
You cannot use those annotations in the "middle of the code". Please use
@Inject as a class attribute, like in here:
class MyClass{
@Inject
private Tutor m;
public void someMethod(){
tutor_id = m.getTutor_id();
...
}
}
When the container is creating a MyClass object it will inject a Tutor
object for you.
Hoppe it helps.
Cheers
Bruno Baptista
https://twitter.com/brunobat_
On 16/12/18 02:49, Karen Goh wrote:
I would like to add that I am using WELD for CDI.
Can WELD works with TomEE ?
Thus, I am not sure if this is the cause of the problem.
My webapp is maven based, using Java EE and jsp running on 1.8 JVM on Eclipse
Oxygen.
--- On Sun, 12/16/18, Karen Goh <[email protected]> wrote:
From: Karen Goh <[email protected]>
Subject: @Ejb is not allowed in this location
To: [email protected]
Date: Sunday, December 16, 2018, 10:12 AM
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 ?