[EJB 3.0 Users] - Re: How to load external parameters in ejb?
by mnenchev
Hi, PLEASE ignore my previous posts.
Here is my last config:
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
| <ejb-jar>
| <enterprise-beans>
| <session>
| <ejb-name>QueueSenderBean</ejb-name>
|
| <resource-env-ref>
| <resource-env-ref-name>AS.1.BFT_ORDERS</resource-env-ref-name>
| <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
| </resource-env-ref>
|
| <resource-ref>
| <description>JMS Connection Factory</description>
| <res-ref-name>CF.1</res-ref-name>
| <res-type>javax.jms.QueueConnectionFactory</res-type>
| <res-auth>Container</res-auth>
| <res-sharing-scope>Shareable</res-sharing-scope>
| </resource-ref>
| </session>
| </enterprise-beans>
| </ejb-jar>
|
jboss.xml
<?xml version="1.0" encoding="UTF-8"?>
| <jboss>
| <enterprise-beans>
| <session>
| <ejb-name>IGBetQueueSenderBean</ejb-name>
|
| <resource-env-ref>
| <resource-env-ref-name>AS.1.BFT_ORDERS</resource-env-ref-name>
| <jndi-name>AS.1.BFT_ORDERS</jndi-name>
| </resource-env-ref>
| <resource-ref>
| <res-ref-name>CF.1</res-ref-name>
| <jndi-name>java:/CF.1</jndi-name>
| </resource-ref>
| </session>
| </enterprise-beans>
| </jboss>
I try to send message like this:
| bean.send(xml, "java:comp/env/AS.1.BFT_ORDERS", "java:comp/env/CF.1");
And here is my send method implementation:
|
| @Stateless
| public class QueueSenderBean implements ISenderLocal {
|
| private static final Logger log = Logger.getLogger(QueueSenderBean.class);
|
| public void sendToQueue(Serializable obj, String queueName, String cf) {
| Connection queueConnection = null;
| Session queueSession = null;
| Queue queue = null;
| MessageProducer sender = null;
| try {
| final Context initCtx = new InitialContext();
| final ConnectionFactory qFactory = (ConnectionFactory) initCtx.lookup(cf);
| queueConnection = qFactory.createConnection();
| queueSession = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| queue = (Queue) initCtx.lookup(queueName);
| sender = queueSession.createProducer(queue);
| log.debug("Sending message to " + queue);
| final Message msg = queueSession.createTextMessage((String) obj);
| sender.send(msg);
| } catch (final javax.jms.JMSException e) {
| log.error("send() -> JMS Error: ", e);
| } catch (final NamingException e) {
| log.error("sendToQueue() -> JNI Error: ", e);
| } catch (final Exception e) {
| log.error("sendToQueue() -> Error: ", e);
| } finally {
| try {
| if (queueConnection != null) {
| queueConnection.close();
| }
| if (queueSession != null) {
| queueSession.close();
| }
| queue = null;
| if (sender != null) {
| sender.close();
| }
| } catch (final Exception e) {
| log.error("sendToQueue() -> Error while closing resources: ", e);
| }
| }
| }
|
| }
| I got NamingException that says that CF.1 is not bound
javax.naming.NameNotFoundException: CF.1 not bound
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
| at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:399)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:833)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
| at javax.naming.InitialContext.lookup(InitialContext.java:392)
| at claire.ejb.logic.msg.beans.IGBetQueueSenderBean.sendToQueue(IGBetQueueSenderBean.java:40)
| at claire.ejb.logic.msg.beans.IGBetQueueSenderBean.send(IGBetQueueSenderBean.java:29)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
| at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
| at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
| at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
| at sun.reflect.GeneratedMethodAccessor428.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
| at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_12384824.invoke(InvocationContextInterceptor_z_fillMethod_12384824.java)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
| at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_12384824.invoke(InvocationContextInterceptor_z_setup_12384824.java)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.aspects.tx.TxPolicy.invokeInNoTx(TxPolicy.java:66)
| at org.jboss.ejb3.tx.TxInterceptor$NotSupported.invoke(TxInterceptor.java:114)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:176)
| at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:216)
| at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
| at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
|
Here is my jndi view:java: Namespace
|
| +- CF.3 (class: com.ibm.mq.connector.outbound.ConnectionFactoryImpl)
| +- securityManagement (class: org.jboss.security.integration.JNDIBasedSecurityManagement)
| +- comp (class: javax.namingMain.Context)
| +- ClaireBLogicDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
| +- DeploymentManager (class: org.jboss.aop.generatedproxies.AOPProxy$4)
| +- CF.2 (class: com.ibm.mq.connector.outbound.ConnectionFactoryImpl)
| +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
| +- JBossCorbaInterfaceRepositoryPOA (class: org.omg.PortableServer.POA)
| +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
| +- CF.1 (class: com.ibm.mq.connector.outbound.ConnectionFactoryImpl)
| ...........
| Global JNDI Namespace
|
| +- UserTransactionSessionFactory (proxy: $Proxy358 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
| +- AS.2.BFT_ORDERS (class: com.ibm.mq.jms.MQQueue)
| ........
|
Please ignore CF.2 and CF.3. I can't see any thing in the java:comp namespaces about my resources. I think that ejb can't lookup the res-ref-name CF.1.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4265522#4265522
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4265522
16 years, 6 months
[jBPM Users] - HELP ME with process Java Hello World
by cmjhingeniero
Hi
I'm using jBPM-4.2 with Tomcat and PostgreSQL. I have the following process, that the only thing it does is print a message Hello World. When I run an instance of the process I get the following error, and I want to know if some configuration or covered
| URL: 'http://localhost:8080/gwt-console-server/rs/process/definition/Java-1/new...'
| Action: 'org.jboss.bpm.console.client.process.StartNewInstanceAction'
| Exception: 'class com.google.gwt.http.client.RequestException'
| HTTP 500: Unknown error
|
Proceso:
| <?xml version="1.0" encoding="UTF-8"?>
| <process name="HolaMundo" xmlns="http://jbpm.org/4.2/jpdl">
| <start name="start1" g="81,123,48,48">
| <transition name="to java1" to="java1" g="-45,-18"/>
| </start>
| <java name="java1"
| class="com.procesos.holamundo.Mensaje"
| method="hola"
| g="170,122,92,52">
| <field name="mensaje"><string value="HOLA MUNDO"/></field>
| <arg><string value="jBPM"/></arg>
| <transition name="to end1" to="end1" g="-42,-18"/>
| </java>
| <end name="end1" g="304,123,48,48"/>
| </process>
|
Thanks you
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4265512#4265512
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4265512
16 years, 6 months
[JBoss AOP Users] - Re: JBoss Microcontainer with JBoss AOP in a standalone app.
by kabir.khan@jboss.com
I take it you're mixing aop and mc bean stuff in one file. Unfortunately that is not possible in plain aop. Although, patching aop for your needs should be trivial
| private void deployTopElements(Element top)
| throws Exception
| {
| NodeList children = top.getChildNodes();
| for (int i = 0; i < children.getLength(); i++)
| {
| if (children.item(i).getNodeType() == Node.ELEMENT_NODE)
| {
| Element element = (Element) children.item(i);
| String tag = element.getTagName();
| if (tag.equals("interceptor"))
| {
| deployInterceptor(element);
| }
| ....
| else if (tag.equals("arraybind"))
| {
| deployArrayBinding(element);
| }
| else
| {
| throw new IllegalArgumentException("Unknown AOP tag: " + tag);
| }
| }
| }
| }
|
Just comment out the throw. I'm not 100% sure how that would work with the maven plugin, I'll ask Ståle
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4265511#4265511
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4265511
16 years, 6 months
[jBPM Users] - Re: Problem moving from 4.1 to 4.2 using Spring configuratio
by hrworx
Santanu,
Thanks much for your continued support on this. I will not have time to thoroughly investigate your latest suggestions since I am traveling today, but I will do so over the weekend. I quick try of everything did not yet yield positive results.
Putting this
<hibernate-configuration>
| <cfg resource="jbpm.hibernate.cfg.xml" />
| </hibernate-configuration>
in jbpm.cfg.xml, but outside the jbpm-configuration block gives
Could not instantiate bean class [org.jbpm.pvm.internal.cfg.SpringConfiguration]: Constructor threw exception; nested exception is org.jbpm.api.JbpmException:
| xml validation error: The markup in the document following the root element must be well-formed.
Putting it inside the jbpm-configuration block has no effect.
The second suggestion is a little confusing to me in several ways. First there is other important configuration in jbpm.hibernate.cfg.xml besides the imports of the other configuration files, and second, when I try to add mappingLocations to my session factory, it does not know about a mappingLocations property. Third, this was working fine in 4.0 and 4.1 without telling the session factory about jbpm.hibernate.cfg.xml. Somehow it was getting picked up.
First, here is my test jbpm.hibernate.cfg.xml for reference:
<hibernate-configuration>
| <session-factory>
| <!--
| TODO refactor this, along with persistence.xml so that the
| following lines only appear in one place
| -->
| <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
| <property name="hibernate.show_sql">true</property>
| <property name="hibernate.format_sql">false</property>
| <property name="hibernate.archive.autodetection">class</property>
| <property name="hibernate.connection.url">jdbc:hsqldb:target/test-hibernate</property>
| <property name="hibernate.connection.username">sa</property>
| <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
|
|
| <property name="hibernate.connection.password"></property>
| <property name="hibernate.hbm2ddl.auto">create-drop</property>
|
|
| <mapping resource="jbpm.repository.hbm.xml" />
| <mapping resource="jbpm.execution.hbm.xml" />
| <mapping resource="jbpm.history.hbm.xml" />
| <mapping resource="jbpm.task.hbm.xml" />
| <mapping resource="jbpm.identity.hbm.xml" />
|
| </session-factory>
| </hibernate-configuration>
Then the error when I try to add the mappingsLocations:
<bean id="entityManagerFactory"
| class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
| <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
| <property name="persistenceUnitManager" ref="persistenceUnitManager" />
| </bean>
|
| <!-- Publishing session factory for use in jBPM -->
| <bean id="sessionFactory" factory-bean="entityManagerFactory"
| factory-method="getSessionFactory">
| <property name="mappingLocations">
| <list>
| <value>classpath:jbpm.execution.hbm.xml</value>
| <value>classpath:jbpm.repository.hbm.xml</value>
| <value>classpath:jbpm.task.hbm.xml</value>
| <value>classpath:jbpm.history.hbm.xml</value>
| </list>
| </property>
| </bean>
Error creating bean with name 'sessionFactory' defined in class path resource [context/core/spring-dbContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mappingLocations' of bean class [org.hibernate.impl.SessionFactoryImpl]: Bean property 'mappingLocations' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Any further suggestions you may have, I will try to look at over the weekend.
Thanks again.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4265498#4265498
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4265498
16 years, 6 months
[EJB 3.0 Users] - Re: How to load external parameters in ejb?
by mnenchev
Hi, thanks for the response.
I looked at the tutorials and the code examples, and i did the following:
1) In my ear meta-inf i created jboss.xml :
<?xml version="1.0" encoding="UTF-8"?>
|
| <jboss>
| <enterprise-beans>
| <session>
| <ejb-name>QueueSenderBean</ejb-name>
|
| <resource-ref>
| <res-ref-name>CF.1</res-ref-name>
| <jndi-name>CF.1</jndi-name>
| </resource-ref>
|
| <resource-ref>
| <res-ref-name>CF.2</res-ref-name>
| <jndi-name>CF.2</jndi-name>
| </resource-ref>
|
| <resource-ref>
| <res-ref-name>CF.3</res-ref-name>
| <jndi-name>CF.3</jndi-name>
| </resource-ref>
|
| <resource-ref>
| <res-ref-name>QUEUE1</res-ref-name>
| <jndi-name>QUEUE1</jndi-name>
| </resource-ref>
|
| <resource-ref>
| <res-ref-name>QUEUE2</res-ref-name>
| <jndi-name>QUEUE2</jndi-name>
| </resource-ref>
|
| <resource-ref>
| <res-ref-name>QUEUE3</res-ref-name>
| <jndi-name>QUEUE3</jndi-name>
| </resource-ref>
| </session>
| </enterprise-beans>
| </jboss>
2) After that i created ejb-jar.xml :
<?xml version="1.0" encoding="UTF-8"?>
| <ejb-jar>
| <enterprise-beans>
| <session>
| <ejb-name>QueueSenderBean</ejb-name>
| <ejb-class>x.y.x.QueueSenderBean</ejb-class>
| <home>x.y.z.IQueueSenderLocal</home>
| <session-type>Stateless</session-type>
| <transaction-type>Container</transaction-type>
|
| <resource-ref>
| <description>Websphere Connection Factory</description>
| <res-ref-name>CF.1</res-ref-name>
| <res-type>javax.jms.QueueConnectionFactory</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
|
| <resource-ref>
| <description>Websphere Connection Factory</description>
| <res-ref-name>CF.2</res-ref-name>
| <res-type>javax.jms.QueueConnectionFactory</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
|
| <resource-ref>
| <description>Websphere Connection Factory</description>
| <res-ref-name>CF.3</res-ref-name>
| <res-type>javax.jms.QueueConnectionFactory</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
|
| <resource-ref>
| <description>Websphere Queue</description>
| <res-ref-name>Queue1</res-ref-name>
| <res-type>javax.jms.Queue</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
|
| <resource-ref>
| <description>Websphere Queue</description>
| <res-ref-name>Queue2</res-ref-name>
| <res-type>javax.jms.Queue</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
|
| <resource-ref>
| <description>Websphere Queue</description>
| <res-ref-name>Queue3</res-ref-name>
| <res-type>javax.jms.Queue</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
| </session>
| </enterprise-beans>
| </ejb-jar>
|
3) Simple send method:
| // The method is in statless ejb :QueueSenderBean.java
| public void sendToQueue(Serializable obj, String queueName, String cf) {
| Connection queueConnection = null;
| Session queueSession = null;
| Queue queue = null;
| MessageProducer sender = null;
| try {
| final Context initCtx = new InitialContext();
| final ConnectionFactory qFactory = (ConnectionFactory) initCtx.lookup(queueName);
| queueConnection = qFactory.createConnection();
| queueSession = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| queue = (Queue) initCtx.lookup(cf);
| sender = queueSession.createProducer(queue);
| log.debug("Sending message to " + queue);
| final Message msg = queueSession.createTextMessage((String) obj);
| sender.send(msg);
| } catch (final javax.jms.JMSException e) {
| log.error("send() -> JMS Error: ", e);
| } catch (final NamingException e) {
| log.error("sendToQueue() -> JNI Error: ", e);
| } catch (final Exception e) {
| log.error("sendToQueue() -> Error: ", e);
| } finally {
| try {
| if (queueConnection != null) {
| queueConnection.close();
| }
| if (queueSession != null) {
| queueSession.close();
| }
| queue = null;
| if (sender != null) {
| sender.close();
| }
| } catch (final Exception e) {
| log.error("sendToQueue() -> Error while closing resources: ", e);
| }
| }
| }
And i call it like this:
sender.sendToQueue(xml, "java:comp/env/QUEUE1", "java:comp/env/CF.1");
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4265489#4265489
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4265489
16 years, 6 months