[JBoss Messaging] - Re: Not able to connect to remote Queue through Bridge
by jbossInduser
Not fully about the issue listed above. But I had an issue a bit similar.
My messaging setup was working locally.
But over a network , my client wasn't able to establish a connection
with my server.
With lots of googling, trial and error and with help from a friend ,
I got it working by following these steps :
* In jboss-5.0.0\server\default\conf\jndi.properties
added : java.naming.provider.url=192.168.0.116:1099
* Changes to
jboss-5.0.0\server\default\deploy\messaging\jms-ds.xml
Avoided using ${jboss.bind.address} : The value substitution wasn't appearing in this file.
DefaultJMSProvider2
org.jboss.jms.jndi.JNDIProviderAdapter
<!-- The combined connection factory -->
java:/XAConnectionFactory
<!-- The queue connection factory -->
java:/XAConnectionFactory
<!-- The topic factory -->
java:/XAConnectionFactory
<!-- Uncomment to use HAJNDI to access JMS-->
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=192.168.0.116:1099
<tx-connection-factory>
<jndi-name>JmsXA2</jndi-name>
<xa-transaction/>
<rar-name>jms-ra.rar</rar-name>
<connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
<adapter-display-name>JMS Adapter</adapter-display-name>
<config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
<config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider2</config-property>
<security-domain-and-application>JmsXARealm2</security-domain-and-application>
jboss.messaging:service=ServerPeer
</tx-connection-factory>
Corresponding changes to jboss-5.0.0\server\default\conf\login-config.xml:
<application-policy name="JmsXARealm2">
<login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule"
flag="required">
<module-option name="principal">guest</module-option>
<module-option name="userName">guest</module-option>
<module-option name="password">guest</module-option>
<module-option name="managedConnectionFactoryName">jboss.jca:service=TxCM,name=JmsXA2</module-option>
</login-module>
</application-policy>
* Bound the address during jboss's startup
run.bat -b 192.168.0.116
* Changed the firewall settings on my XP machine to allow my client to interact with my server.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4227469#4227469
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4227469
15 years, 7 months
[Installation, Configuration & DEPLOYMENT] - CMP Entity bean is not saving to mysql database
by manjeshk
Hi,
I am trying to create CMP entity bean using JBOSS Server 4 and mysql
1.CMPRemoteI
package com.remote.interfaces;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface CMPRemoteI extends EJBObject {
public String getKey() throws RemoteException;
public String getName() throws RemoteException;
public void setName (String s) throws RemoteException;
public String getPlace() throws RemoteException;
public void setPlace(String s) throws RemoteException;
}
2. CMPHomeI
package com.home.interfaces;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
import javax.ejb.FinderException;
import com.remote.interfaces.CMPRemoteI;
public interface CMPHomeI extends EJBHome {
public CMPRemoteI create(String a,String b, String c) throws RemoteException, CreateException;
public CMPRemoteI findByPrimaryKey (String a) throws RemoteException, FinderException;
}
3. ejb-jar.xml in META-INF folder
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" 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">
<display-name>EJB2App</display-name>
<enterprise-beans>
<!-- CMP Entity Bean Mapping Start -->
<ejb-name>EntityBeanCMP</ejb-name>
com.home.interfaces.CMPHomeI
com.remote.interfaces.CMPRemoteI
<ejb-class>com.beans.CMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
false
<cmp-version>2.x</cmp-version>
<abstract-schema-name>table1</abstract-schema-name>
<cmp-field>
<field-name>key</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>place</field-name>
</cmp-field>
<primkey-field>key</primkey-field>
<!-- CMP Entity Bean Mapping End -->
</enterprise-beans>
<!-- Assembly-Descriptor Mapping Start -->
<assembly-descriptor>
<container-transaction>
<ejb-name>EntityBeanCMP</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
<!-- Assembly-Descriptor Mapping End -->
</ejb-jar>
4. jboss.xml in META-INF folder
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 3.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
<enterprise-beans>
<!-- CMP EntityBean Mapping -->
<ejb-name>EntityBeanCMP</ejb-name>
<jndi-name>EntityBean/CMP</jndi-name>
<!-- End -->
</enterprise-beans>
<resource-managers />
5. jbosscmp-jdbc.xml in META-INF folder
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc>
<jbosscmp-jdbc>
java:/DefaultDS
<!--<datasource-mapping>mysql</datasource-mapping>
--><create-table>true</create-table>
<remove-table>false</remove-table>
<pk-constraint>true</pk-constraint>
<preferred-relation-mapping>
foreign-key
</preferred-relation-mapping>
<enterprise-beans>
<ejb-name>EntityBeanCMP</ejb-name>
<table-name>table1</table-name>
<cmp-field>
<field-name>key</field-name>
<column-name>key</column-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>name</column-name>
</cmp-field>
<cmp-field>
<field-name>place</field-name>
<column-name>place</column-name>
</cmp-field>
</enterprise-beans>
</jbosscmp-jdbc>
6. mysql-ds.xml in D:\Installations\jboss-4.0.3SP1\server\default\deploy location
<?xml version="1.0" encoding="UTF-8"?>
<!-- ========================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ========================================================== -->
<!-- $Id: mysql-ds.xml,v 1.1 2002/07/22 22:57:24 d_jencks Exp $ -->
<!-- ========================================================== -->
<!-- Datasource config for MySQL using 2.0.11 driver -->
<!-- ========================================================== -->
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost/test
</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
mysql
</local-tx-datasource>
7. CallCMPEntityBean client file
package com.clients;
import java.util.Properties;
import java.util.ResourceBundle;
import javax.naming.Context;
import javax.naming.InitialContext;
import com.home.interfaces.CMPHomeI;
import com.remote.interfaces.CMPRemoteI;
import com.statics.StaticsClass;
public class CallCMPEntityBean {
/**
* @param args
*/
public static void main(String[] args) {
try{
Properties props = new Properties();
ResourceBundle rb = ResourceBundle
.getBundle(StaticsClass.COM_PROPERTIES_MESSAGERESOURCE);
String contextProviderUrl = rb.getString(StaticsClass.PROVIDER_URL);
String contextInitialFactory = rb
.getString(StaticsClass.INITIAL_CONTEXT_FACTORY);
if (contextProviderUrl != null && contextInitialFactory != null) {
props.put(Context.PROVIDER_URL, contextProviderUrl);
props.put(Context.INITIAL_CONTEXT_FACTORY,
contextInitialFactory);
props.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
System.out.println("Properties ok");
} else {
System.out.println("Context PROVER_URL =" + contextProviderUrl
+ " Context INITIAL_FACTORY =" + contextInitialFactory);
}
Context ctx = new InitialContext(props);
CMPHomeI home = (CMPHomeI) ctx.lookup("EntityBean/CMP");
System.out.println("home located");
System.out.println("Add record");
home.create("4","Manjesh","Kumar");
System.out.println("record created");
System.out.println("Find record");
CMPRemoteI remote= home.findByPrimaryKey("3");
System.out.println("Name:..."+remote.getName());
System.out.println("Place:..."+remote.getPlace());
/*
System.out.println("Update record");
System.out.println("update name");
remote.setName("Manoj");
String name = remote.getName();
System.out.println("Name updated");
System.out.println(name);
System.out.println("update place");
remote.setPlace("Lucknow");
String place=remote.getPlace();
System.out.println("place updated");
System.out.println(place);*/
/*System.out.println("Delete record");
remote.remove();
System.out.println("record removed"); */
}catch(Exception e1){
System.out.println(" "+e1);
}
}
}
when i am running the CallCMPEntityBean file the code is executing properly without any exception or error but data is not populated to "test" database.
actually the basic problem is that table is not creating in test database.
Kindly help me and let me know where i did mistake.
please provide the solution.
Manjesh K
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4227466#4227466
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4227466
15 years, 7 months