Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Ambily G Nair

Greenhorn
+ Follow
since Aug 21, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ambily G Nair

Hi,

I have a gnupg encrypted file and its passphrase.How can i decrypt it in java. I can't use java Runtime class. How can I use symmetric cyher for decrypting this file.

Thanks,

Ambily
14 years ago
In oracle-ds.xml the jndi name is given as below.
<jndi-name>OracleDS</jndi-name>.

In addition to oracle-ds.xml ,edit standardjaws.xml and standardjbosscmp-jdbc.xml by changing datasource tag to <datasource>java:/OracleDS</datasource>.

I hope this will work.
15 years ago
Hi,

Anybody can suggest a tool for converting xdr files to xsd.We have tried the XmlSpy but it didn't take the <Attribute Type> tag .

Ambily
Hi,

I am using the following code for getting the context and it is working fine for me.

Properties props= new Properties();

props.put(InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
return new InitialContext(props);

-- Ambily
15 years ago
Remove '/'from action ie give <form action="logon" method="post" >.I think it will work.
15 years ago
Hi,
I think your bean is not correctly deployed.Can you look on the server console
and check whether it is showing the message "Deploying StoreAccessBean".If not check the error.

Ambily
15 years ago
Hi,

I have tried jbossmq/jms with the following code and I was able to send and receive messages.

Sender code is

public class QueueSender1 {
private static InitialContext getContext() throws NamingException {
Hashtable props = new Hashtable();

props.put(InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");

// This establishes the security for authorization/authentication
// props.put(InitialContext.SECURITY_PRINCIPAL,"username");
// props.put(InitialContext.SECURITY_CREDENTIALS,"password");

InitialContext initialContext = new InitialContext(props);
return initialContext;
}

public static void main(String[] args) throws Exception {
InitialContext ctx = getContext();
QueueConnectionFactory cf = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
QueueConnection c = cf.createQueueConnection();
QueueSession s = c.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue q = (Queue) ctx.lookup("queue/textQueue");
QueueSender snd = s.createSender(q);
TextMessage msg = s.createTextMessage();
msg.setText("Hello JMS World!");
snd.send(msg);
snd.close();
s.close();
c.close();
}

}


Receiver code is ,

public class QueueReceiver1 implements MessageListener{
public void onMessage(Message msg) {
try {
String msgText = ((TextMessage) msg).getText();
System.out.println("Message Received: "+ msgText );
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception {
InitialContext ctx = getContext();
QueueConnectionFactory cf = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
QueueConnection c = cf.createQueueConnection();
QueueSession s = c.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue q = (Queue) ctx.lookup("queue/textQueue");
QueueReceiver rcv = s.createReceiver(q);
rcv.setMessageListener(new QueueReceiver1());
c.start();
while (true);
}
private static InitialContext getContext() throws NamingException {
Hashtable props = new Hashtable();

props.put(InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");

// This establishes the security for authorization/authentication
// props.put(InitialContext.SECURITY_PRINCIPAL,"username");
// props.put(InitialContext.SECURITY_CREDENTIALS,"password");

InitialContext initialContext = new InitialContext(props);
return initialContext;
}

}


Also you have to edit login-config.xml,jbossmq-destinations-service.xml.
15 years ago
Hi,

Have a look on this tutorial.

http://www.huihoo.com/jboss/online_manual/3.0/ch08s07.html

I think this will help you to get an idea about jbossmq and jms

-- Ambily
15 years ago
The jbossall-client.jar that i am using is from jboss-4.0.1sp1.zip. So how can it be from an older version. Can you send me any link for the same version jar.

Thanks,

Ambily
15 years ago
Hi,

I have an ejb application and and a web application. I have deployed both .jar and .war files in jboss-4.0.1sp1. After restarting the server when I try to access the ejb using a standalone java class Iam getting the following error.

javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.util.id.GUID; local class incompatible: stream classdesc serialVersionUID = 3289509836244263718, local class serialVersionUID = 6926421946503004889]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:649)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:509)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at registration.WebClient.testBean(WebClient.java:45)
at registration.WebClient.main(WebClient.java:74)
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:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.io.InvalidClassException: org.jboss.util.id.GUID; local class incompatible: stream classdesc serialVersionUID = 3289509836244263718, local class serialVersionUID = 6926421946503004889
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at org.jboss.invocation.InvokerInterceptor.readExternal(InvokerInterceptor.java:125)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:66)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:66)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:66)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:111)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:51)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:552)
... 9 more


But when I deploy the same files in jboss-3.2.6 it is working and I could access the ejb from standalone java class.

Can anyone help me please.

Ambily
15 years ago
Hi,

Can you please tell me what is salary scale we can expect in China for a 1+ years of experience in j2ee.
15 years ago
Hi,

I think this query will work for you,

Query q1 = session.createQuery(SELECT eh FROM com.domain.ErrorHist as eh, com.domain.DeviceReadings as dr WHERE eh.deviceReadings.deviceReadingKey=dr.deviceReadingKey AND dr.modelNumber=:mn AND dr.brandName=:bn AND dr.serialNumber=:sn)
q1.setParameter("mn","sefs",Hibernate.STRING); // second field is the value to be substituted and 3rd is the type of the field
q1.setParameter("bn",new Float(4500000f),Hibernate.FLOAT);// second field is the value to be substituted and 3rd is the type of the field
q1.setParameter("sn",new Integer(2),Hibernate.INTEGER);// second field is the value to be substituted and 3rd is the type of the field


When I put hibernate.show_sql=true in hibernate.properties I could see the queries in console
Hi,

I 'm trying to do a sample hibernate code.

I have 2 tables Teams and Players in which primary key of Teams is the foreign key of Players.

My mapping documents are

<hibernate-mapping>
<class name="example.Player" table="players">
<id name="id" column="player_id" type="long" unsaved-value="null">
<generator class="sequence"/>
</id>
<property name="firstName" column="first_name" type="string" length="12" not-null="true"/>
<property name="lastName" column="last_name" type="string" length="15" not-null="true"/>
<property name="draftDate" column="draft_date" type="date"/>
<property name="annualSalary" column="salary" type="float"/>
<property name="jerseyNumber" column="jersey_number" type="integer" length="2" not-null="true"/>
<many-to-one name="team" class="example.Team" column="team_id" />
</class>
</hibernate-mapping>


<hibernate-mapping>
<class name="example.Team" table="teams">
<id name="id" column="team_id" type="long" unsaved-value="null">
<generator class="sequence"/>
</id>
<property name="name" column="team_name" type="string"
length="15" not-null="true"/>
<property name="city" column="city" type="string" length="15" not-null="true"/>
<set name="players" cascade="all" inverse="true" lazy="true">
<key column="team_id"/>
<one-to-many class="example.Player"/>
</set>
</class>
</hibernate-mapping>


My persistence classes are

public class Team implements Serializable {

/** identifier field */
private Long id;

/** persistent field */
private String name;

/** persistent field */
private String city;

/** persistent field */
private Set players;

/** full constructor */
public Team(String name, String city, Set players) {
this.name = name;
this.city = city;
this.players = players;
}

/** default constructor */
public Team() {
}

public Long getId() {
return this.id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public String getCity() {
return this.city;
}

public void setCity(String city) {
this.city = city;
}

public Set getPlayers() {
return this.players;
}

public void setPlayers(Set players) {
this.players = players;
}

public String toString() {
return new ToStringBuilder(this)
.append("id", getId())
.toString();
}

public boolean equals(Object other) {
if ( !(other instanceof Team) ) return false;
Team castOther = (Team) other;
return new EqualsBuilder()
.append(this.getId(), castOther.getId())
.isEquals();
}

public int hashCode() {
return new HashCodeBuilder()
.append(getId())
.toHashCode();
}

}



public class Player implements Serializable {

/** identifier field */
private Long id;

/** persistent field */
private String firstName;

/** persistent field */
private String lastName;

/** nullable persistent field */
private Date draftDate;

/** nullable persistent field */
private float annualSalary;

/** persistent field */
private int jerseyNumber;

/** nullable persistent field */
private example.Team team;

/** full constructor */
public Player(String firstName, String lastName, Date draftDate, float annualSalary, int jerseyNumber, example.Team team) {
this.firstName = firstName;
this.lastName = lastName;
this.draftDate = draftDate;
this.annualSalary = annualSalary;
this.jerseyNumber = jerseyNumber;
this.team = team;
}

/** default constructor */
public Player() {
}

/** minimal constructor */
public Player(String firstName, String lastName, int jerseyNumber) {
this.firstName = firstName;
this.lastName = lastName;
this.jerseyNumber = jerseyNumber;
}

public Long getId() {
return this.id;
}

public void setId(Long id) {
this.id = id;
}

public String getFirstName() {
return this.firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public Date getDraftDate() {
return this.draftDate;
}

public void setDraftDate(Date draftDate) {
this.draftDate = draftDate;
}

public float getAnnualSalary() {
return this.annualSalary;
}

public void setAnnualSalary(float annualSalary) {
this.annualSalary = annualSalary;
}

public int getJerseyNumber() {
return this.jerseyNumber;
}

public void setJerseyNumber(int jerseyNumber) {
this.jerseyNumber = jerseyNumber;
}

public example.Team getTeam() {
return this.team;
}

public void setTeam(example.Team team) {
this.team = team;
}

public String toString() {
return new ToStringBuilder(this)
.append("id", getId())
.toString();
}

public boolean equals(Object other) {
if ( !(other instanceof Player) ) return false;
Player castOther = (Player) other;
return new EqualsBuilder()
.append(this.getId(), castOther.getId())
.isEquals();
}

public int hashCode() {
return new HashCodeBuilder()
.append(getId())
.toHashCode();
}

}

In my code I'm trying to do an insert into 2 tables as below



team.setCity("Detroit");
team.setName("Pistons");
Player player = new Player();
player.setFirstName("Chauncey");
player.setLastName("Billups");
player.setJerseyNumber(1);
player.setAnnualSalary(4000000f);
Set players = new HashSet();
players.add(player);
team.setPlayers(players);
session.save(team);
session.flush();
session.connection().commit(); // not necessary for JTA datasource
session.close();

But after executing this I'm getting a record in TEAMS as expected. But in PLAYERS the foreign key column ie TEAM_ID is null.
Why is it so.Can anyone help me?

Ambily
Can you send me the code to ambilyg@gmail.com. Let me have a look. Action class ,struts-config.xml part,Form class and jsp
15 years ago