[JBoss Messaging] - having problems getting started with JMS in JBoss 5 Beta 4
by rexer
Hi,
I'm a newbie trying to get messaging to work in the jboss 5 beta 4. Having some problems which I tried to google-up and getting nowhere. Any hints from you folks are much appreciated.
I modified destinations-service.xml to include my test queue definition.
| <mbean code="org.jboss.jms.server.destination.QueueService"
| name="jboss.messaging.destination:service=Queue,name=testQueue"
| xmbean-dd="xmdesc/Queue-xmbean.xml">
| <depends optional-attribute-name="ServerPeer">
| jboss.messaging:service=ServerPeer
| </depends>
| <depends>jboss.messaging:service=PostOffice</depends>
| <attribute name="SecurityConfig">
| <security>
| <role name="guest" read="true" write="true"/>
| <role name="publisher" read="true" write="true" create="false"/>
| <role name="noacc" read="false" write="false" create="false"/>
| </security>
| </attribute>
| </mbean>
|
When I start jboss I see correctly that the queue is created:
| 13:59:48,548 INFO [QueueService] Queue[/queue/testQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000
|
I used NetBeans 6.0.1 to create EJB app. I added an MDB using the wizard and connected to to queue 'queue/testQueue'.
My jboss.xml is:
| <jboss>
| <enterprise-beans>
| <message-driven>
| <ejb-name>NewMessageBean</ejb-name>
| <jndi-name>NewMessageBean</jndi-name>
| <destination-jndi-name>queue/testQueue</destination-jndi-name>
| </message-driven>
| </enterprise-beans>
| </jboss>
|
the ejb-jar.xml is:
| <ejb-jar version="2.1" 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/ejb-jar_2_1.xsd">
| <enterprise-beans>
| <message-driven>
| <display-name>NewMessageMDB</display-name>
| <ejb-name>NewMessageBean</ejb-name>
| <ejb-class>org.rex.NewMessageBean</ejb-class>
| <transaction-type>Container</transaction-type>
| <message-destination-type>javax.jms.Queue</message-destination-type>
| <message-destination-link>testQueue</message-destination-link>
| <activation-config>
| <activation-config-property>
| <activation-config-property-name>acknowledgeMode</activation-config-property-name>
| <activation-config-property-value>Auto-acknowledge</activation-config-property-value>
| </activation-config-property>
| <activation-config-property>
| <activation-config-property-name>destinationType</activation-config-property-name>
| <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
| </activation-config-property>
| </activation-config>
| </message-driven>
| </enterprise-beans>
| <assembly-descriptor>
| <container-transaction>
| <method>
| <ejb-name>NewMessageBean</ejb-name>
| <method-name>*</method-name>
| </method>
| <trans-attribute>Required</trans-attribute>
| </container-transaction>
| <message-destination>
| <display-name>Destination for NewMessageMDB</display-name>
| <message-destination-name>testQueue</message-destination-name>
| </message-destination>
| </assembly-descriptor>
| </ejb-jar>
|
Looks like NetBeans is not yet compatible with jboss 5: you can't register servers (domain drop-down ends up being empty) and so you can't do deployments from NetBeans. So here is what I did to manually deploy my test app: I build the .jar and put it under server/default/deploy and I see the server starting the deployment. I see the exception shown below and that's where I am getting stuck:
exception: jndi-name not found as a child of message-driven
details:
| 15:19:51,173 ERROR [AbstractKernelController] Error installing to Parse: name=vfsfile:/usr/local/jboss-5.0.0.Beta4/server/default/deploy/Test1-ejb.jar state=Not Installed m
| ode=Manual requiredState=Parse
| org.jboss.deployers.spi.DeploymentException: Error creating managed object for vfsfile:/usr/local/jboss-5.0.0.Beta4/server/default/deploy/Test1-ejb.jar
| .........
| 15:19:51,242 WARN [HDScanner] Failed to process changes
| org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
|
| *** CONTEXTS IN ERROR: Name -> Error
|
| vfsfile:/usr/local/jboss-5.0.0.Beta4/server/default/deploy/Test1-ejb.jar -> org.jboss.xb.binding.JBossXBRuntimeException: jndi-name not found as a child of message-driven
|
|
| at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:576)
| at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:559)
| at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:291)
| at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:221)
| at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
| at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
| at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
| at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
| at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
| at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
| at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
| at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
| at java.lang.Thread.run(Thread.java:619)
|
If I remove jndi-name element from jboss.xml (I added it after NetBeans MDB wizard), I get following error during deployment:
| jboss.j2ee:binding=message-driven-bean,jndiName=local/NewMessageBean@24490290,plugin=invoker,service=EJB -> org.jboss.deployment.DeploymentException: The message-destination 'testQueue' has no jndi-name in jboss.xml
|
So it seems I'm providing wrong jndi-name which for some reason is a required param in Jboss 5. Perhaps the jndi-name is correct but my NewMessageBean class is somenow not compliant with something. I wonder if this has anything to do with differences between JBoss MQ and Jboss Messaging. I suspect NetBeans generated the code and config files targeted for JBoss MQ.
My MDB class head is:
public class NewMessageBean implements MessageDrivenBean, MessageListener { ...
I'm new to enterprise beans in general so I'm sorry if I'm missing something obvious.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133504#4133504
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133504
18 years, 1 month
[JBoss jBPM] - Message Driven Bean not working with jBPM
by chrisrjcox
Hi,
I have an issue where I send a simple test text message to a queue. Then the MDB is supposed to pick this message up and display the text. I can't see any issues with my coding, and I have tested to ensure that the message does get stored in the queue, by retrieving it straight after adding to the queue.
Here is the action handler sending the text to the queue.
| package com.distributed.action;
|
| import org.jbpm.graph.def.ActionHandler;
| import org.jbpm.graph.exe.ExecutionContext;
|
| import javax.jms.ConnectionFactory;
| import javax.jms.Connection;
| import javax.jms.MessageProducer;
| import javax.jms.Queue;
| import javax.jms.Session;
| import javax.jms.TextMessage;
| import javax.naming.InitialContext;
| /**
| import javax.jms.MessageConsumer;
| */
|
| public class SendMessageToQueueForPartTwo implements ActionHandler
| {
|
| private static final long serialVersionUID = 1L;
|
| InitialContext jndi = null;
| ConnectionFactory conFactory = null;
| Connection connection = null;
| Session session = null;
| MessageProducer producer = null;
| TextMessage textMessage = null;
| TextMessage receivedMessage = null;
|
| public void execute(ExecutionContext context) throws Exception
| {
| try
| {
| jndi = new InitialContext();
| System.out.println("SendMessageToQueueForPartTwo: jndi Initial Context created");
|
| conFactory = (ConnectionFactory)jndi.lookup("ConnectionFactory");
| System.out.println("SendMessageToQueueForPartTwo: ConnectionFactory created");
|
|
| connection = conFactory.createConnection();
| System.out.println("SendMessageToQueueForPartTwo: Connection created");
| session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| System.out.println("SendMessageToQueueForPartTwo: Session created");
| Queue queue = (Queue) jndi.lookup("queue/jbpmQueue");
| System.out.println("SendMessageToQueueForPartTwo: Looked up jbpmQueue");
| if (queue == null)
| {
| System.out.println("SendMessageToQueueForPartTwo: Queue Not Found...Creating Queue");
| queue = session.createQueue("queue/jbpmQueue");
| }
| producer = session.createProducer(queue);
| System.out.println("SendMessageToQueueForPartTwo: Producer Created");
|
| textMessage = session.createTextMessage("Hello, has this worked?");
| System.out.println("SendMessageToQueueForPartTwo: textMessage Created");
| producer.send(textMessage);
| System.out.println("SendMessageToQueueForPartTwo: textMessage sent to " + queue.getQueueName() + " queue");
|
| /** The following code was to check that the message was passed to the Queue
| MessageConsumer consumer = session.createConsumer(queue);
| System.out.println("MessageConsumer created");
|
| connection.start();
| System.out.println("Connection started");
|
| receivedMessage = (TextMessage) consumer.receive();
| System.out.println("The Message "+ receivedMessage.getText());
| */
|
| }
| finally
| {
| if(jndi != null)
| {
| try
| {
| jndi.close();
| }
| catch(Exception e)
| {
| throw e;
| }
| }
| }
| }
| }
Here is the Message Driven Bean.
| package com.distributed.action;
|
| import javax.ejb.EJB;
| import javax.ejb.MessageDriven;
| import javax.ejb.ActivationConfigProperty;
| import javax.jms.JMSException;
| import javax.jms.Message;
| import javax.jms.MessageListener;
| import javax.jms.TextMessage;
|
| @MessageDriven(mappedName = "jms/PartTwoMDB", activationConfig =
| {
| @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue = "Auto-acknowledge"),
| @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
| @ActivationConfigProperty(propertyName="destination", propertyValue="/queue/jbpmQueue")
| })
|
| public class PartTwoMDB implements MessageListener
| {
| @EJB
| private static final long serialVersionUID = 1L;
|
| public void onMessage(Message inMessage)
| {
| TextMessage textMessage = null;
| try
| {
| if(inMessage instanceof TextMessage)
| {
| textMessage = (TextMessage) inMessage;
| System.out.println("PartTwoMDB: Message received: "+ textMessage.getText());
| }
| else
| {
| System.out.println("PartTwoMDB: MEssage of wrong type: " + inMessage.getClass().getName());
| }
| }
| catch (JMSException e)
| {
| e.printStackTrace();
| }
| catch (Throwable t)
| {
| t.printStackTrace();
| }
|
| }
| }
|
I would expect it to print the message text message but nothing happens.
Would anyone be able to assist?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133497#4133497
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133497
18 years, 1 month
[JBossCache] - Re: JBossCache, POJO Cache, Hibernate, field replication - h
by bstansberry@jboss.com
That's 3 questions. :-) Answered in order:
1) Yes, that's PojoCache's primary benefit.
2) No, it isn't.
3) A bit of both. Hibernate stores an entity in the 2nd level cache as an Object[], one element per field. To deal with such a representation, PojoCache would need to be able to handle detecting changes in elements in an array, which it currently cannot do. Jason is working to resolve that (perhaps in PojoCache 2.2). But even if that were solved the Hibernate folks would have to ensure that the same Object[] instance is consistently used throughout the Hibernate code (i.e. no creating a new Object[] with the same elements). I don't know how difficult that would be, but I imagine it would be very fragile.
In most cases you're better off using JBC invalidation for entity caching anyway, which in terms of intra-cluster message traffic is lighter than any replication-based strategy, including PojoCache.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133496#4133496
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133496
18 years, 1 month
[Beginners Corner] - error on accessing a web-service
by Fugee47
Hello, i have an ejb which contains following java-class "JBossEJBWS.java"
package org.me.ejbwss;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.ejb.Stateless;
@Stateless
@WebService
public class JBossEJBWS {
private String message = new String("Hello, ");
@WebMethod
public String greet(String name) {
return message + name + ".";
}
}
when i deploy it, i can access the wsdl-file:
http://localhost:8080/WSEJBModule/JBossEJBWS?wsdl
Now i want to create a war-file which contains a jsp-file, which executes the method "greet"
For this i created web.xml in WEB-INF:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
version="2.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>webclient</display-name>
<display-name>greeting</display-name>
<servlet-name>greeting</servlet-name>
<jsp-file>/index.jsp</jsp-file>
<servlet-mapping>
<servlet-name>greeting</servlet-name>
<url-pattern>/greeting</url-pattern>
</servlet-mapping>
<service-ref>
<service-ref-name>services/JBossEJBWS</service-ref-name>
<service-interface>javax.xml.ws.Service</service-interface>
<wsdl-file>WEB-INF/wsdl/JBossEJBWS.wsdl</wsdl-file>
<port-component-ref>
<service-endpoint-interface>org.me.ejbwss.JBossEJBWS</service-endpoint-interface>
</port-component-ref>
</service-ref>
</web-app>
And this is the jsp-file:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.io.*,javax.naming.InitialContext,javax.xml.ws.Service,org.me.ejbwss.JBossEJBWS"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
JSP Page
<h1>JSP Page</h1>
<%
try {out.println("ole");
InitialContext ctx = new InitialContext();
Service service = (Service)ctx.lookup("java:comp/env/services/JBossEJBWS");
JBossEJBWS port = (JBossEJBWS) service.getPort(JBossEJBWS.class);
} catch (Exception e) {
out.println("Error: " + e.getMessage());
}
String text = port.greet("Fugee");
out.println(text);
%>
The Problem is, when i open the URL (http://localhost:8080/WSCWebModule/) in a webbrowser, i get the following error:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 23 in the jsp file: /index.jsp
port cannot be resolved
20: } catch (Exception e) {
21: out.println("Error: " + e.getMessage());
22: }
23: String text = port.greet("Fugee");
24: out.println(text);
25: %>
26:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:316)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
can someone tell me what i have done wrong ??
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133492#4133492
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133492
18 years, 1 month