Servlet not working in EJB Project in Intellij IDEA -
i'm new in intellij idea , created test java ee project in it. first of in new project selected java enterprise (java jdk 7) , added additional libraries:
- web application (3.1)
- ejb: enterprise java beans (3.2 without ejb-jar.xml)
- java ee application (java ee 7)
the app created successfully. created stateless java class:
package test.server; import javax.ejb.localbean; import javax.ejb.stateless; @stateless(name = "testclientejb") @localbean public class testclientbean { public testclientbean() { } public string gethello() { return "hello ejb intellij"; } }
and after created servlet:
package test.client; import test.server.testclientbean; import javax.ejb.ejb; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import java.io.ioexception; import java.io.printwriter; @webservlet(name = "clientservlet") public class clientservlet extends httpservlet { @ejb testclientbean testclientbean; protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { printwriter out = response.getwriter(); out.print(testclientbean.gethello()); } }
as application server use wildfly 8.1 final. setup ear artifact , give url as:
http://localhost:8080/ejbtestweb/
when run in browser, show me write in index.jsp. when write type
http://localhost:8080/ejbtestweb/clientservlet
it show me not found message. problem? needed jars downloaded
it's worked when in servlet changed
@webservlet(name = "clientservlet")
to
@webservlet("/clientservlet")
Comments
Post a Comment