The Intellij IDEA 95.24 was swearing at @EJB, but it works perfectly on Glassfish 3.x

...
import javax.ejb.EJB; import javax.ejb.Stateful; import javax.enterprise.context.ConversationScoped; import javax.inject.Named; import javax.interceptor.Interceptors; import java.io.Serializable; @Named @Stateful @ConversationScoped @Interceptors(WebInterceptor.class) public class WebBean implements Serializable {     @EJB     private ILocalService localService;

    ...
}



...
import javax.ejb.EJB; import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; import java.util.List; @Stateless @TransactionAttribute public class LocalService implements ILocalService {     @EJB     private ILocalDao localDao;

    ...
}



...
import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; @Stateless public class LocalDao implements ILocalDao {     @PersistenceContext     private EntityManager em;

    ...
}



I use:

<dependency>     <groupId>javax</groupId>     <artifactId>javaee-web-api</artifactId>     <version>6.0</version>     <scope>provided</scope> </dependency>



The Intellij IDEA 95.24 was swearing at @EJB, but it works perfectly on Glassfish 3.x.

@EJB Intellij IDEA error:

EJB '' with component interface 'IQuestionDao' not found less...(Ctrl+F1) Detects the following error-level EJB specification violations: * Injected property invalid type * EJB references consistency with ejb-jar.xml



Is this bug IDE? Or my Bug? :-)
8 comments

EJB '' with component interface 'ILocalDao' not found less...(Ctrl+F1)
Detects the following error-level EJB specification violations:
* Injected property invalid type
* EJB references consistency with ejb-jar.xml
0

I'm unable to reproduce the error with your scenario.
I.e. EJB facet without any ejb-jar.xml & classes with the above code.
Looks like something else in your configuration causes this.



On 23.04.2010 11:55, Dmitriy Arkhipov wrote:

 import javax.ejb.EJB;
> import javax.ejb.Stateful;
> import javax.enterprise.context.ConversationScoped;
> import javax.inject.Named;
> import javax.interceptor.Interceptors;
> import java.io.Serializable;
>
> @Named
> @Stateful
> @ConversationScoped
> @Interceptors(WebInterceptor.class)
> public class WebBean implements Serializable {
>      @EJB
>      private ILocalService localService;
>
>      ...
> }]]>

>

 import javax.ejb.EJB;
> import javax.ejb.Stateless;
> import javax.ejb.TransactionAttribute;
> import java.util.List;
>
> @Stateless
> @TransactionAttribute
> public class LocalService implements ILocalService {
>      @EJB
>      private ILocalDao localDao;
>
>      ...
> }]]>

>

 import javax.ejb.Stateless;
> import javax.persistence.EntityManager;
> import javax.persistence.PersistenceContext;
>
> @Stateless
> public class LocalDao implements ILocalDao {
>      @PersistenceContext
>      private EntityManager em;
>
>      ...
> }]]>

>

I use:

>

>      javax
>      javaee-web-api
>      6.0
>      provided
> ]]>

>

The Intellij IDEA 95.24 was swearing at @EJB, but it works perfectly on Glassfish 3.x.

>

@EJB Intellij IDEA error:

>

 Detects the following error-level EJB specification violations:
> * Injected property invalid type
> * EJB references consistency with ejb-jar.xml]]>

>

Is this bug IDE? Or my Bug? :)

>

---
Original message URL: http://www.jetbrains.net/devnet/message/5261576#5261576


0

I have the same problem. It appeared when I upgraded from IDEA 8 to IDEA 9.
(Also, The class FooEjb is bogously marked as 'Class FooEjb' is never used.)

import javax.ejb.Local;
@Local public interface FooLocal {}


import com.facilitylabs.controlserver.ejbs.local.AdLocal;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@Stateless public class FooEjb implements FooLocal {
   @EJB AdLocal adLocal;
}

I now also get a similar error with other types of injection, such as

@Resource protected SessionContext context;


The message is "Injected resource type 'javax.ejb.Sessioncontext' invalid".
The code compiles and runs just fine on Glassfish.
What's wrong?

0

Hmm... adding a EJB Facet (in project structure > modules) helped.

Strange that this wasn't carried over from my IDEA 8 project.

0

I have the same situation with IDEA 10 IU-103.212. I have a project based on EE6 and Glassfish 3.1 with no-interface EJBs which are bundled in a WAR. There are no EJB deployment descriptors and I do not have an EJB facet. An example of one of my EJBs is:

@Stateless
@Path("/foo")
public class FooResource {

  @EJB
  private FooBean fooBean;

Basically IDEA highlights @EJB with the red squiggle and when I hover over it I see the message "EJB '' with component interface 'FooBean' not found". I have to add @SuppressWarnings({"EjbEnvironmentInspection"}) to it to make IDEA happier. My project builds, deploys and runs fine. Not sure why IDEA isn't happy. I tried adding an EJB facet without a deployment descriptor to the project but that did not solve the problem.

Interestingly, if I change @Stateless to @Named the warning goes away. However, I want to use EJBs not CDI so this isn't a solution.

-Noah

0

http://youtrack.jetbrains.net/issue/IDEA-67032

As a workaround you can disable the inspection.

EJB facet without any descriptors is required by the fix.



On 3/22/11 11:03 PM, nbw-intellijnet wrote:

I have the same situation with IDEA 10 IU-103.212. I have a project
based on EE6 and Glassfish 3.1 with no-interface EJBs which are
bundled in a WAR. There are no EJB deployment descriptors and I do
not have an EJB facet. An example of one of my EJBs is:

>

@Stateless @Path("/foo") public class FooResource {

>

@EJB private FooBean fooBean;

>

Basically IDEA highlights @EJB with the red squiggle and when I hover
over it I see the message "EJB '' with component interface 'FooBean'
not found". I have to add
@SuppressWarnings({"EjbEnvironmentInspection"}) to it to make IDEA
happier. My project builds, deploys and runs fine. Not sure why IDEA
isn't happy. I tried adding an EJB facet without a deployment
descriptor to the project but that did not solve the problem.

>

Interestingly, if I change @Stateless to @Named the warning goes
away. However, I want to use EJBs not CDI so this isn't a solution.

>

-Noah

>

--- Original message URL:
http://devnet.jetbrains.net/message/5298125#5298125



--
Gregory Shrago
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop With Pleasure!"

0

Hi Greg,

Guest wrote:

http://youtrack.jetbrains.net/issue/IDEA-67032

As a workaround you can disable the inspection.

not found". I have to add
@SuppressWarnings({"EjbEnvironmentInspection"}) to it to make IDEA
happier. My project builds, deploys and runs fine. Not sure why IDEA
isn't happy. I tried adding an EJB facet without a deployment
descriptor to the project but that did not solve the problem.

EJB facet without any descriptors is required by the fix.

What build is that fix in? I would like to test it out. I noticed you marked the bug as fixed in 10.x which I assume is not the 10.0.x EAP branch or is it? Thanks,

-Noah

0

Pushed into 10.0.x branch as well.

0

Please sign in to leave a comment.