[EJB/JBoss] - Can someone look at this application? help understanding why
by rickcr
I'm trying to use the @EJB annotation on a stateless session bean in a servlet and having troubles getting it to work. I've read some other posts on the issue and supposedly it 'should' work, so I'd love some help trying to figure out what I'm doing wrong.
I posted the simple source code here:
http://dl-client.getdropbox.com/u/86998/learntechnology-maven-jee.zip
If you run "mvn install" it will build a user-adminstration.ear in the lt-ear/target directory. When deployed to JBoss .. try to access the URL:
http://localhost:8080/sample/hello
The Stateless session bean never gets set. (You end up with a NPE.)
I'll post some of the relevant code. ..
//lt-ejb-jar:
| @Local
| public interface UserService {
| public String helloWorld(String s);
| }
|
| @Stateless
| public class UserServiceBean implements UserService {
|
| public String helloWorld(String s) {
| return "Hello World: "+s;
| }
| }
|
//lt-web.war...
| public class SayHelloServlet extends HttpServlet {
| private static final long serialVersionUID = 1L;
|
| //not working: @EJB(mappedName="user-administration/UserServiceBean/local")
| //works: private UserService userService = (UserService) ServiceLocator.getEJB("user-administration/UserServiceBean/local");
|
| //not working:
| @EJB
| private UserService userService;
|
| public void init() throws ServletException {
| super.init();
| }
|
| protected void doGet(HttpServletRequest req, HttpServletResponse resp)
| throws ServletException, IOException {
| doPost(req, resp);
| }
|
| protected void doPost(HttpServletRequest req, HttpServletResponse response)
| throws ServletException, IOException {
| System.out.println("userService = " + userService);
| response.setContentType("text/plain");
| response.getOutputStream().println("Servlet Test: ");
| response.getOutputStream().println(userService.helloWorld("My test"));
| }
| }
|
web.xml
| <?xml version="1.0" encoding="UTF-8"?>
|
| <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
| http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
| version="2.4">
|
| <servlet>
| <servlet-name>SayHelloServlet</servlet-name>
| <servlet-class>
| net.learntechnology.web.SayHelloServlet
| </servlet-class>
| <load-on-startup>0</load-on-startup>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>SayHelloServlet</servlet-name>
| <url-pattern>/hello</url-pattern>
| </servlet-mapping>
|
| </web-app>
|
Thanks for any help with this.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4179690#4179690
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4179690
16 years, 6 months
[JBoss Messaging] - Takes much time to Startup - 1.4.0.SP3
by Craig2007
Forgot to add the Code tag for xml elements.
Please have this modified one. also provide a suitable reply
Hi
I have downloaded latest version of JBoss Messaging(1.4.0.SP3) to replace our older version in Prod Environment.
With previous version, JBoss messaging server takes lot of time to start and we suspect the reason could be SQL scripts(Create and
updates )available in mysql-persistence-service.xml file.
Following are the attributes in mysql-persistence-service.xml, which makes the Queries run .
| <attribute name="CreateTablesOnStartup">true</attribute>
| <attribute name="UsingBatchUpdates">true</attribute>
|
Suppose if we make these atrribute values to be false, will there be any impact.Please provide your suggestion on this
FYI....
We have millions of messages which are pending to be delivered from the JBoss messaging server.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4179685#4179685
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4179685
16 years, 6 months
[EJB 3.0] - Re: Steless Session bean as Webservice
by dasariprasad
i had used wsconsume like this
| >wsconsume ---------------endpoint-address?\WSDL
|
| it has given new classfiles as mentioned in your program
|
| but if i run
| i got
| Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/messaging/saaj/soap/AttachmentPartImpl
| [java] at com.sun.xml.ws.message.AttachmentUnmarshallerImpl.<clinit>(AttachmentUnmarshallerImpl.java:55)
| [java] at com.sun.xml.ws.client.sei.ResponseBuilder$RpcLit$PartBuilder.readResponse(ResponseBuilder.java:635)
| [java] at com.sun.xml.ws.client.sei.ResponseBuilder$RpcLit.readResponse(ResponseBuilder.java:599)
| [java] at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:242)
| [java] at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
| [java] at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
| [java] at $Proxy22.greet(Unknown Source)
| [java] at com.htc.htcws.SimpleWSClient.main(Unknown Source)
| [java] Caused by: java.lang.ClassNotFoundException: com.sun.xml.messaging.saaj.soap.AttachmentPartImpl
| [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
| [java] at java.security.AccessController.doPrivileged(Native Method)
| [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
| [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
| [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
| [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
| [java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
| [java] ... 8 more
|
| my classpath is
|
| <property name="deploydir" value="${JBOSS_HOME}\server\default\deploy" />
| <property name="client.dir" value="${JBOSS_HOME}\client" />
| <property name="extended.dir" value="${JBOSS_HOME}\lib\endorsed" />
| <property name="java-lib.dir" value="c:\jdk1.6.0\lib" />
| <property name="jboss-lib.dir"
| value="${JBOSS_HOME}\lib"/>
|
|
| <path id="cpath" >
|
| <fileset dir="${client.dir}" includes="**/*.jar" />
| <fileset dir="${extended.dir}" includes="**/*.jar" />
| <fileset dir="${java-lib.dir}" includes="tools.jar" />
| <fileset dir="${axis-lib}" includes="saaj.jar" />
|
| <pathelement path="${cls}" />
| <pathelement path="." />
| </path>
|
| which jars i have to put in classpath.
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4179678#4179678
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4179678
16 years, 6 months
[Beginners Corner] - Schedular MBean & Injection
by aslocal
Hello. When my Scheduler mBean starts up it can't find my injected EJB's (it works fine from the jmx-console, when I click the method button) Any ideas?
Code snippet:
<!-- ==================================================================== --> <!-- Scheduler Service -->
| <!-- ==================================================================== -->
| <!--
| | This example shows how to use a target MBean
| -->
| <mbean code="org.jboss.mx.timer.JBossTimer"
| name="jboss:service=Timer">
| </mbean>
|
| <mbean code="com.craneae.t1.schedular.ejb.jmx.TeamCenterADSchedulerBean"
| name=":name=TeamCenterADSchedulerBean">
| </mbean>
| <mbean code="org.jboss.varia.scheduler.Scheduler"
| name=":service=Scheduler,name=TeamCenterADSchedulerBean">
| <attribute name="StartAtStartup">true</attribute>
| <attribute name="SchedulableMBean">:name=TeamCenterADSchedulerBean</attribute>
| <attribute name="SchedulableMBeanMethod">expireAccounts()</attribute>
| <attribute name="InitialStartDate">NOW</attribute>
| <attribute name="SchedulePeriod">10000</attribute>
| <attribute name="InitialRepetitions">1</attribute>
| <attribute name="FixedRate">true</attribute>
| </mbean>
|
|
| // Inject the UserDAO bean
| @EJB (beanName="UserDAOBean") private UserDAOBeanLocal userDAOBean;
|
| // Update email addresses once per night
| @SuppressWarnings("unchecked")
| public void expireAccounts()
| {
| List<User> resultList = userDAOBean.getActiveUsers();
|
The userDAOBean is always null on startup.
Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4179676#4179676
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4179676
16 years, 6 months