Skip to main content

Injecting EJB to Servlet - ClassNotFoundException

4 replies [Last post]
naveensisupalan
Offline
Joined: 2007-11-16
Points: 0

I am getting classnotfound exception for all EJBs when trying to inject EJBs to a servlet.
Both EJBs and servlet are in same EAR file.

org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class com.naveen.samples.jeesample1.servlets.TestServlet.

My EJB:
@Stateless
public class TestService implements TestServiceLocal {

@Override
public String greet(final String name) {
return "Hello " + name;
}

}
EJB Local Interface:
@Local
public interface TestServiceLocal {

String greet(final String name);

}

Servlet:
@WebServlet(name = "TestServlet", urlPatterns = {"/test"})
public class TestServlet extends HttpServlet {

@EJB
private TestServiceLocal local;
}

I haven't changed any configuration files or anything. Is there anything I am missing. I can deploy the same ear file to JBOSS and it works fine.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mvatkina
Offline
Joined: 2005-04-04
Points: 0

How do you package your components?

BTW, exception is from JBOSS.

naveensisupalan
Offline
Joined: 2007-11-16
Points: 0

I am using Netbeans default build and packaging process. I took the final EAR file from dist folder and deployed to jboss. In Jboss I am not getting any exception.

mvatkina
Offline
Joined: 2005-04-04
Points: 0

The exception in your post is a jboss exception - look at its package name

On 12/28/12 10:46 AM, forums@java.net wrote:
> I am using Netbeans default build and packaging process. I took the
> final EAR
> file from dist folder and deployed to jboss. In Jboss I am not getting
> any
> exception.
>
> --
>
> [Message sent by forum member 'naveensisupalan']
>
> View Post: http://forums.java.net/node/893496
>
>

naveensisupalan
Offline
Joined: 2007-11-16
Points: 0

That is the exception I am getting in glassfish console. I think glassfish internally is using jboss weld to do resource injection.