Search This Blog

Showing posts with label eap. Show all posts
Showing posts with label eap. Show all posts

Thursday, December 10, 2015

Jboss - EAP - JPA error

1. X:\jboss-eap-6.2\modules\system\layers\base\javax\persistence\api\main\module.xml 
modifiy :    export="false"

2. X:\jboss-eap-6.2\modules\system\layers\base\javaee\api\main
modify : export="false"

   

3. Open standalone.xml or standalone-full.xml etc..
    go to

    html comment that block to avoid exceptions


Jboss EAP 6+ HornetQ setup



1)      Add this in standalone-full.xml under   
1.1 Change the max size bytes , default 10 MB
                   
                        jms.queue.DLQ
                        jms.queue.ExpiryQueue
                        0
                        20971520
                        BLOCK
                        10
                   
 
1.1 Add the below line after 
tag.


                   
                       
                       
                   
                   
                       
                       
                   
             
                   
                        
                       
                   
                   
                       
                        
                   
              
                   
                       
                       
                   
                       
                       
                   

                   
                       
                       
                   
              
                   
                       
                       
                   
                   
                       
                       
                   
              
                   
                       
                       
                   
                   
                       
                       
                   
                       
                       
                    

               

2)      Add new user for JMS through add-user.bat
X:\> add-user.bat
b
ApplicationRealm
jmsUser
password
yes

                check in mgm-users.properties, application-users.properties like below line [new user with pwd]
jmsUser=aeadcf105686eafa6afc994e86a520db

3)      Add the below line into applicaiton-roles.properties
jmsUser=guest
3.5) Start the server
D:\EAP-6.0.0.GA\jboss-eap-6.0\bin>standalone.bat -b 192.168.7.9 -Djboss.server.default.config=standalone-full.xml
Or
D:\EAP-6.0.0.GA\jboss-eap-6.0\bin>standalone.bat -b 192.168.7.9 –c standalone-full.xml

4)      Sender1.java
/**
 *
 */
package com.test;

import java.util.Hashtable;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

public class Sender1
{
                public static void main ( String [] args )
                {

                                try
                                {

                                                Hashtable env = new Hashtable ();
                                                env.put ( Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory" );
                                                env.put ( Context.PROVIDER_URL, "remote://192.168.7.9:4447" );
                                                env.put ( Context.SECURITY_PRINCIPAL, "jmsUser" );
                                                env.put ( Context.SECURITY_CREDENTIALS, "password" );
                                                Context context = new InitialContext ( env );

                                                ConnectionFactory cf = (ConnectionFactory) context.lookup ( "jms/RemoteConnectionFactory" );
                                                Destination destination = (Destination) context.lookup ( "jms/queue/test" );
                                                Connection connection = cf.createConnection ( "jmsUser", "password" );
                                                Session session = connection.createSession ( false, Session.AUTO_ACKNOWLEDGE );
                                                Queue queue = (javax.jms.Queue) context.lookup ( "jms/queue/test" );

                                                TextMessage textMessage = session.createTextMessage ();
                                                textMessage.setText ( "hello vijay 3" );
                                                javax.jms.MessageProducer producer = session.createProducer ( destination );
                                                producer.send ( textMessage );

                                                System.out.println ( "Sending Done " );

                                                // Close the session and connection resources.
                                                // context.close();
                                                session.close ();
                                                connection.close ();

                                }
                                catch ( Exception ex )
                                {

                                                ex.printStackTrace ();

                                }

                }

}


5)      Add your spring+hornetq+remote+listener application into Jboss-eap-6.0\ Standalone \ deployments folder and change your settings according to your remote IP in applicationContext and start the server to receive.


For ex: D:\works\SdexSOA\MessageQueueSOA\WebContent\WEB-INF\applicationContext.xml



6)      If it is spring, add like below in application-context.xml
For ex:-
<bean id="destinationMail" class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiTemplate" ref="jnditemplate" />
       <property name="jndiName" value="jms/queue/mail" />
</bean>
      
<bean class="org.springframework.jms.listener.SimpleMessageListenerContainer">
       <property name="connectionFactory" ref="credentialsconnectionfactory" />
       <property name="destination" ref="destinationMail" />
       <property name="messageListener" ref="receiverMail" />
</bean>
      
<bean id="receiverMail" class="com.gnax.sdex.soa.service.JMSReceiverService" />



7)      JMSReceiverService.java

package com.gnax.sdex.soa.service;

import java.util.Date;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.Queue;

import com.gnax.sdex.soa.bean.common.EmailBean;
import com.gnax.sdex.soa.utils.ConfigManager;
import com.gnax.sdex.soa.utils.EMail;
import com.gnax.sdex.soa.utils.JMSReceiverHelper;
import com.gnax.sdex.soa.vo.PatientInfoVO;

/**
 * @author Vijay .D.R
 * @version 1.0, 11/1/2013
 * @since 1.0
 */

public class JMSReceiverService implements MessageListener
{

                public JMSReceiverService ()
                {
                }

                public void onMessage ( Message message )
                {
                                try
                                {
                                                // TextMessage text = (TextMessage) message;
                                                ObjectMessage objectMessage = (ObjectMessage) message;
                                                Queue queue = (Queue) message.getJMSDestination ();
                                                // System.out.println ( queue.getQueueName () );

                                                if ( queue.getQueueName ().equals ( ConfigManager.getPropertyValue ( "destination.mail.queueName" ) ) )
                                                {
                                                                System.out.println ( queue.getQueueName () );
                                                                EmailBean emailBean = (EmailBean) objectMessage.getObject ();
                                                                message.acknowledge ();
                                                                // System.out.println ( new Date () + " : received the following message : " + text.getText () );
                                                                EMail.getEmailInstance ().sendEmail ( emailBean.getTo (), emailBean.getCc (), emailBean.getBcc (), emailBean.getSubject (), emailBean.getBodyContent () );
                                                                System.out.println ( new Date () + " : received the following message : " + emailBean.getFrom () );
                                                }
                                                else if ( queue.getQueueName ().equals ( ConfigManager.getPropertyValue ( "destination.sms.queueName" ) ) )
                                                {
                                                                System.out.println ( queue.getQueueName () );
                                                }
                                                else if ( queue.getQueueName ().equals ( ConfigManager.getPropertyValue ( "destination.fax.queueName" ) ) )
                                                {
                                                                System.out.println ( queue.getQueueName () );
                                                }
                                                else if ( queue.getQueueName ().equals ( ConfigManager.getPropertyValue ( "destination.auditTrail.queueName" ) ) )
                                                {
                                                                System.out.println ( queue.getQueueName () );
                                                }
                                                else if ( queue.getQueueName ().equals ( ConfigManager.getPropertyValue ( "destination.hlSeven.queueName" ) ) )
                                                {
                                                                System.out.println ( queue.getQueueName () );
                                                                PatientInfoVO patientInfoVO = (PatientInfoVO) objectMessage.getObject ();
                                                                message.acknowledge ();
                                                                new JMSReceiverHelper ().addOrUpdatePatientDetails ( patientInfoVO );
                                                }
                                }
                                catch ( JMSException e )
                                {
                                                e.printStackTrace ();
                                }
                                catch ( Exception e )
                                {
                                                e.printStackTrace ();
                                }
                }

}



NOTE: QUEUE or TOPIC name should not be contains numeric/special char..  [ like hl7Queue ]

Monday, August 13, 2012

Https in Redhat EAP 6.0 or JBoss 7.0


HTTPS in Redhat EAP 6.0 or JBoss 7.0

Steps 1 : Create a keystore by using Keytool if [HTTP / HTTPS]

D:\drvijay>keytool -genkey -alias tomcat -keyalg RSA -keystore https.keystore
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  abi gnax
What is the name of your organizational unit?
  [Unknown]:  jboss
What is the name of your organization?
  [Unknown]:  abignax
What is the name of your City or Locality?
  [Unknown]:  bangalore
What is the name of your State or Province?
  [Unknown]:  karnataka
What is the two-letter country code for this unit?
  [Unknown]:  IN
Is CN=abi gnax, OU=jboss, O=abignax, L=bangalore, ST=karnataka, C=IN correct?
  [no]:  yes

Enter key password for
        (RETURN if same as keystore password):

Step 2: Add the below line in x:/eap6.0_or_jboss7.0/standalone/configuration/standalone.xml

                <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" enable-lookups="false" secure="true">

                <ssl password="test123" key-alias="tomcat" certificate-key-file="D:/drvijay/https.keystore" protocol="TLSv1" verify-client="false" certificate-file="D:/drvijay/https.keystore"/>

</connector>



               

Note : Give IP instead of localhost in some cases.

Hit Counter


View My Stats