[Beginner's Corner] - AS 7.1.1 send/receive a JMS message in Servlet question
by Michael Justin
Michael Justin [https://community.jboss.org/people/mjustin] created the discussion
"AS 7.1.1 send/receive a JMS message in Servlet question"
To view the discussion, visit: https://community.jboss.org/message/728702#728702
--------------------------------------------------------------
Hello,
I am trying to build a simple JMS produce / consume example in a Servlet. The full source code is below.
The servlet uses a resource annotation to inject the JMS destination which is configured in standalone-full.xml, and I also can verify that the destination exists (in the admin interface) and user and password are valid. The produce / consume methods complete without any errors, but the web admin interface does not show any messages. I tried to use persistent messages but it did not help. I will also check out the examples in the source distribution, and come back if I found the reason.
package servlet;
import java.io.IOException;
import java.io.Writer;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(name = "My Servlet", urlPatterns = { "/ms" })
public class MyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Resource(mappedName = "java:/ConnectionFactory")
ConnectionFactory factory;
private static final Logger log = Logger.getLogger("");
private static final String username = "guest";
private static final String password = "secret";
private static final String destination = "ExampleTopic";
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
produce();
consume();
}
private void produce() {
try {
Connection conn = factory.createConnection(username, password);
Session session = conn.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = session.createProducer(session
.createTopic(destination));
prod.setDeliveryMode(DeliveryMode.PERSISTENT);
conn.start();
Message msg = session.createTextMessage("hello");
prod.send(msg);
conn.close();
} catch (JMSException e) {
log.info(e.getMessage());
}
}
private void consume() {
try {
Connection conn = factory.createConnection(username, password);
Session session = conn.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageConsumer cons = session.createConsumer(session
.createTopic(destination));
conn.start();
Message msg = cons.receive(1000);
if (msg == null) {
log.info("received no message");
} else {
TextMessage t = (TextMessage) msg;
log.info(t.getText());
}
conn.close();
} catch (JMSException e) {
e.printStackTrace();
}
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/728702#728702]
Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years
[EJB3] - SqlResultMapping not working
by Craig Uss
Craig Uss [https://community.jboss.org/people/craigmuss] created the discussion
"SqlResultMapping not working"
To view the discussion, visit: https://community.jboss.org/message/728678#728678
--------------------------------------------------------------
I am trying to use @SqlResultMapping with one of my queries:
query = this
.getEntityManager()
.createNativeQuery(
"SELECT DISTINCT proj.*, mess.trigger_date"
+ "FROM ci_project as proj LEFT JOIN ci_project_message as mess "
+ "on proj.message_no = mess.message_no "
+ "WHERE proj.survey_contact = :userId",
"surveyManagement").setParameter("userId", userId);
I made a SqlResultMapping for this query:
@SqlResultSetMapping(name = "surveyManagement", entities = {
@EntityResult(entityClass = CiProject.class),
@EntityResult(entityClass = CiProjectMessage.class, discriminatorColumn = "MESSAGE_NO", fields = { @FieldResult(name = "triggerDate", column = "trigger_date") }) })
I am getting the following error when I try to execute this query:
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2236)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
at org.hibernate.loader.Loader.list(Loader.java:2125)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:94)
... 252 more
Caused by: java.sql.SQLException: Column 'MESSAGE1_4_1_' not found.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1144)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2815)
at org.jboss.resource.adapter.jdbc.WrappedResultSet.getInt(WrappedResultSet.java:698)
at org.hibernate.type.IntegerType.get(IntegerType.java:51)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:173)
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1120)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:587)
at org.hibernate.loader.Loader.doQuery(Loader.java:723)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
at org.hibernate.loader.Loader.doList(Loader.java:2233)
... 259 more
10:41:29,794 SEVERE [lifecycle] JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /subViews/surveysList.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1c7728e]
I am new to using SqlResultMapping annotation. Any advice or point in the right direction will be greatly appreciated!
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/728678#728678]
Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years
[jBPM] - How to trigger an external signal event with a web service
by Francois MARTIN
Francois MARTIN [https://community.jboss.org/people/nujib] created the discussion
"How to trigger an external signal event with a web service"
To view the discussion, visit: https://community.jboss.org/message/728668#728668
--------------------------------------------------------------
Hello,
I am really new to Java and Jbpm so my questions may sound stupid. I designed a simple Process which looks like this :
and what I'd like to do is to trigger the signal event using a web service. I have a main function initializing the knowledgeBase and starting my process just like the HelloWorld example. I just moved the initialiation step to another class called ProcessManager which holds a static ksession variable. Here is the aborescence of my project :
My configuration is the following :
- jBPM 5.2
- Eclipse Helios SR2 3.6.2
- Tomcat 6 with Axis 2
I already manage to create a webservice and integrate it into tomcat so that I can use SoapUI to make a call a get the result in the eclipse console.
I tried to trigger the signal event by inserting the following piece of code into the exposed method of my WS :
ProcessManager.ksession.signalEvent("receptionRetourOperat", 1);
The problem is that the ksession that is initialized in my main function is null when making the WS call. I guess the two executions (WS call and main) are done in a different context so that I can't get the initialized ksession variable from my WS call. My questions are the following :
- Is it possible to make the WS access the ksession variable from the main function ?
- Does it make sense to have only one jBPM session and to create a process instance at each WS call ?
Thanks.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/728668#728668]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years
[jBPM] - Re: Designer loading problem in drools-guvnor
by renez
renez [https://community.jboss.org/people/renez] created the discussion
"Re: Designer loading problem in drools-guvnor"
To view the discussion, visit: https://community.jboss.org/message/721414#721414
--------------------------------------------------------------
Hello,
I'm having this problem today, too. I'm using jbpm 5.2 installed by installer on Ubuntu Linux 10.04 with openjdk-6. In Guvnor I can create a BPmn 2.0 process. But when I try to open the File just get a screen "Please wait while loading". In server.log I can find.
18:21:25,182 INFO [stdout] (http--0.0.0.0-8080-5) INFO 04-03 18:21:25,181 (NilAuthenticator.java:authenticate:35)
All users are guests.
18:22:47,125 INFO [stdout] (http--0.0.0.0-8080-6) (null: -1, -1): Premature end of file.
18:22:47,799 INFO [org.jbpm.designer.server.EditorHandler] (http--0.0.0.0-8080-6) The diagram editor is running in development mode. Javascript will be served uncompressed
18:22:47,801 INFO [org.jbpm.designer.server.EditorHandler] (http--0.0.0.0-8080-6) Performing diagram information pre-processing steps.
18:22:48,208 INFO [stdout] (http--0.0.0.0-8080-7) INFO 04-03 18:22:48,206 (NilAuthenticator.java:authenticate:35)
All users are guests.
18:22:48,494 INFO [stdout] (http--0.0.0.0-8080-7) INFO 04-03 18:22:48,493 (NilAuthenticator.java:authenticate:35)
All users are guests.
18:22:48,560 INFO [stdout] (http--0.0.0.0-8080-7) INFO 04-03 18:22:48,559 (NilAuthenticator.java:authenticate:35)
All users are guests.
18:22:48,698 INFO [stdout] (http--0.0.0.0-8080-7) INFO 04-03 18:22:48,697 (NilAuthenticator.java:authenticate:35)
All users are guests.
18:22:48,739 INFO [stdout] (http--0.0.0.0-8080-7) INFO 04-03 18:22:48,738 (NilAuthenticator.java:authenticate:35)
All users are guests.
18:22:48,772 INFO [org.jbpm.designer.web.preprocessing.impl.JbpmPreprocessingUnit] (http--0.0.0.0-8080-6) Successfully deleted file :/opt/jboss/jbpm-5.2/jboss-as-7.0.2.Final/standalone/tmp/vfs/temp5fa1d605b1619162/designer.war-74ced14e8e0c620f/stencilsets/bpmn2.0jbpm/bpmn2.0jbpm.json
18:22:48,773 INFO [org.jbpm.designer.web.preprocessing.impl.JbpmPreprocessingUnit] (http--0.0.0.0-8080-6) Created file:/opt/jboss/jbpm-5.2/jboss-as-7.0.2.Final/standalone/tmp/vfs/temp5fa1d605b1619162/designer.war-74ced14e8e0c620f/stencilsets/bpmn2.0jbpm/bpmn2.0jbpm.json
18:22:48,818 INFO [org.jbpm.designer.web.preprocessing.impl.JbpmPreprocessingUnit] (http--0.0.0.0-8080-6) Created file:/opt/jboss/jbpm-5.2/jboss-as-7.0.2.Final/standalone/tmp/vfs/temp5fa1d605b1619162/designer.war-74ced14e8e0c620f/stencilsets/bpmn2.0jbpm/view/activity/workitems/Log.svg
18:22:48,829 INFO [org.jbpm.designer.web.preprocessing.impl.JbpmPreprocessingUnit] (http--0.0.0.0-8080-6) Created file:/opt/jboss/jbpm-5.2/jboss-as-7.0.2.Final/standalone/tmp/vfs/temp5fa1d605b1619162/designer.war-74ced14e8e0c620f/stencilsets/bpmn2.0jbpm/view/activity/workitems/Email.svg
18:23:10,604 INFO [stdout] (http--0.0.0.0-8080-7) INFO 04-03 18:23:10,603 (NilAuthenticator.java:authenticate:35)
All users are guests.
18:23:10,660 INFO [stdout] (http--0.0.0.0-8080-7) (null: -1, -1): Premature end of file.
Like mika suggested I changed the umlauts and the special charkters. The strang thing is, that everyting works fine on my local developer system with win xp.
Does somebody have a suggestion? Hints a greatly appriciated!
René
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/721414#721414]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years
[EJB3] - EJB is null Please Help
by Manolescu Sebastian
Manolescu Sebastian [https://community.jboss.org/people/mano_seba] created the discussion
"EJB is null Please Help"
To view the discussion, visit: https://community.jboss.org/message/728650#728650
--------------------------------------------------------------
Hello,
I try to use TestNG but the @EJB is null, but it's not a detailed error :(( . I use arquillian but I doubt that this is the problem in this case, I've made other tests just like this whit different services but the EJ is not null, only 4 out 0f 10 services are null. :0
In the surfire reports it shows:
SubscriptionSaveTest(com.project.scr.prj.service.SubscriptionServiceTest) Time elapsed: 0.015 sec <<< FAILURE!
java.lang.NullPointerException
at com.project.scr.prj.service.SubscriptionServiceTest.SubscriptionSaveTest(SubscriptionServiceTest.java:98)
The test looks like
public class SubscriptionServiceTest {
private final String TEST_VALUE = "test";
private final Date TEST_DATE = new Date();
private final Long TEST_LONG = 3l;
@Deployment
public static WebArchive createTestArchive() {
return ShrinkWrap.create( WebArchive.class,"test.war").addPackages(true,"org.joda.time").addPackages(true, "javax.jcr").addClasses(com.mysql.jdbc.log.Log.class,com.project.scr.prj.model.Subscription.class).addPackage("org.slf4j").addPackage("org.slf4j.spi").addPackage("org.slf4j.helpers").addAsWebInfResource("test-persistence.xml", "classes/META-INF/persistence.xml").addAsWebInfResource("beans.xml", "META-INF/beans.xml");
}
@EJB(name ="subscriptionService")
private SubscriptionService subscriptionService;
@BeforeTest
@UsingScript("import.sql")
public void setUp()
{}
public Subscription FillSubscription(){
System.out.println("TEST"+subscriptionService); // in the console shows null
}
Sorry for my bad english :)
Best Regards
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/728650#728650]
Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years