Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

Sagar Bilgi

Ranch Hand
+ Follow
since Apr 26, 2001
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 Sagar Bilgi

Hi All,
I have an application deployed on JBOSS 3.2.5. I wish to make certain classes inside that particular application available as webservices.
I want to use axis for doing this. So I did the following:

a) I copied the axis jars to my WEB-INF/lib directory
b) I modified my web.xml to include the Axis servlet definitions.

I am able to get to the Axis page via my applicaton
i.e http://localhost:8080/myapplication/service
takes me to the axis services page.

So far so good.
Can anyone outline what I need to do to now expose the methods in my classes as web services and how?

I am just looking for high level pointers.

Thanks


P.S: I do not want to use JBOSS.NET or JBOSSWS.
15 years ago
Hi All,
I have an application deployed on JBOSS 3.2.5. I wish to make certain classes inside that particular application available as webservices.
I want to use axis for doing this. So I did the following:

a) I copied the axis jars to my WEB-INF/lib directory
b) I modified my web.xml to include the Axis servlet definitions.

I am able to get to the Axis page via my applicaton
i.e http://localhost:8080/myapplication/service
takes me to the axis services page.

So far so good.
Can anyone outline what I need to do to now expose the methods in my classes as web services and how?

I am just looking for high level pointers.

Thanks


P.S: I do not want to use JBOSS.NET or JBOSSWS.
15 years ago
Hi,
Yes the files do compile. The problem with using reflection as I have mentioned in my post is that the .class file expects any class referenced in the .class file to be also loaded before any methods are called on the loaded class.

for ex: I have a X.class file which is compiled from X.java. X.java contains references to Y.java. Now when we call Class.loadClass on X.class, if you want to do anything meaningful on the Class returned then you have to ensure that Y.class is also loaded else you will get a ClassNotFoundException.

SO -- Is there a different way to use reflection which will ensure that when I load Class X all of the classes that X references are also loaded?

Thanks in advance
15 years ago
Hi All,
What I want to do is pretty simple. I have some java source files. I want to find the public methods in the Java files.

How do I achieve this? I do not want to parse the files and then go line by line and search for the public keyword.

I tried using reflection so that I could just query the .class file. Load it via Class.loadClass() and then get all the methods. However if the class references a file which is in another jar in the project then how do I get that information. If I try to query the class without having loaded the referenced class I get a ClassNotFoundException.

Any other ideas?

Thanks
15 years ago
Hi All,
Acc to what I have read it should not matter whether a consumer receive messages from a queue synchronously or asynchronously, A queue always has one subscriber and once the message is consumed it is removed from the queue.

However I am not sure if what I am seeing under JBOSS is correct or if something in the program is wrong(This program was copied from http://www.coredevelopers.net/library/jboss/jms-dev/dev-applications.jsp)

Even after the message has been received from the queue, the message is still available if I look via JMX on JBOSS- listMessages. Why is that the case? Shouldnt the message be deleted from the queue once it is consumed?

When I try a client with a synchronous receiver the message is deleted from the JBOSS queue and everythings fine.

Could it be that in the MessageListener's onMessage method, I need to do something specific that removes it from the client side.


Code is as follows
=======================================================================

import java.util.Properties;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
* Listens for a TextMessage from a Queue
*/
public class AsynchQueueToMessage
{
InitialContext ctx;
QueueConnectionFactory cf;
QueueConnection connection;
QueueSession session;
Queue destination;
QueueReceiver receiver;

public static void main(String[] args) throws NamingException,
JMSException
{
new AsynchQueueToMessage().run();
}

public void run() throws NamingException, JMSException
{

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "localhost:1099");

ctx = new InitialContext(props);
cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
destination = (Queue)ctx.lookup("queue/testQueue");

connection = cf.createQueueConnection();
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
receiver = session.createReceiver(destination);
receiver.setMessageListener(new MyMessageListener());

System.out.println("Waiting For A Message.");
connection.start();
}

class MyMessageListener implements MessageListener {

public void onMessage(Message msg)
{
try
{
TextMessage message = (TextMessage)msg;
System.out.println("The message was: "+message.getText());
connection.close();
System.out.println("Done.");
}
catch (JMSException e)
{
e.printStackTrace();
}
}
}
}
15 years ago
Hi All,
Acc to what I have read it should not matter whether a consumer receive messages from a queue synchronously or asynchronously, A queue always has one subscriber and once the message is consumed it is removed from the queue.

However I am not sure if what I am seeing under JBOSS is correct or if something in the program is wrong(This program was copied from http://www.coredevelopers.net/library/jboss/jms-dev/dev-applications.jsp)

Even after the message has been received from the queue, the message is still available if I look via JMX on JBOSS- listMessages. Why is that the case? Shouldnt the message be deleted from the queue once it is consumed?

When I try a client with a synchronous receiver the message is deleted from the JBOSS queue and everythings fine.

Could it be that in the MessageListener's onMessage method, I need to do something specific that removes it from the client side.


Code is as follows
=======================================================================

import java.util.Properties;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
* Listens for a TextMessage from a Queue
*/
public class AsynchQueueToMessage
{
InitialContext ctx;
QueueConnectionFactory cf;
QueueConnection connection;
QueueSession session;
Queue destination;
QueueReceiver receiver;

public static void main(String[] args) throws NamingException,
JMSException
{
new AsynchQueueToMessage().run();
}

public void run() throws NamingException, JMSException
{

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "localhost:1099");

ctx = new InitialContext(props);
cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
destination = (Queue)ctx.lookup("queue/testQueue");

connection = cf.createQueueConnection();
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
receiver = session.createReceiver(destination);
receiver.setMessageListener(new MyMessageListener());

System.out.println("Waiting For A Message.");
connection.start();
}

class MyMessageListener implements MessageListener {

public void onMessage(Message msg)
{
try
{
TextMessage message = (TextMessage)msg;
System.out.println("The message was: "+message.getText());
connection.close();
System.out.println("Done.");
}
catch (JMSException e)
{
e.printStackTrace();
}
}
}
}
I'm using hibernate for the first time in a 'real' project. These are 3 of the tables:

Projects
---------
keyproj
projusers(set)
....


ProjUsers
----------
keyproj
keyuser
role


Users
-------
keyuser
username
projusers(set)
....


The relationships are set up correctly (I think), I'm just not sure how to construct the query. What I have to begin with is the users' username. How can I also load all of the projects that user is part of?

Thanks for the help.

-- Should be pretty simple. If the relationships have been properly defined in your mapping files then all you have to do is run the query "from Users where username = :inUserName"

This will give you a list of users(hopefully just one) and since each user Object has a set of projusers object you should be able to iterate over that set. For each item , cast it to ProjUsers . Btw each ProjUser should have a project also,( I think) so you can get it off of that object, else get the keyproj field identifier property from the ProjUsers and load the Project based on that field.


HTH
Hi Folks,
I know Hibernate supports the concept of named queries which allows queries to live in the mapping files.

I am wondering if there is support for having queries in a seperate file altogether.I have many queries which I use in my java APIs and if I put them all in my mapping file it would become huge.

On the other hand if i put the queries in my Java files I have to recompile each time I change the query which I definitely do not like. SO...can I put the queries in a seperate file say queries.xml(probably identify that in my hibernate.cfg.xml file and refer it by some name as in the named queries concept) and refer that in my Java code? Seems like this is something that should be pretty simple and already supported. Does anyone know if its possible and if so how to do that?

Thanks
Hi,
I am using JBOSS 3.2.5 and JBOSS seems to be logging everything in "DEBUG" mode. I have changed the setting in the $JBOSS_HOME/server/servername/conf/log4j.xml to INFO for all of the categories but still JBOSS seems to want to log everything with "DEBUG" priority.

Is there any other place where we need to change some parameters? Any help will be appreciated as log files are Huuuuge
Thanks
15 years ago
Was browsing through this forum and saw my unanswered question and figured I'd post what I did if it might help anyone else.

Since no one replied I figured the easiest way would be to use the middlegen UI and enter the sequence names for the tables I wanted.
Try again by removing the inverse = true.if that doent work then try removing both lazy = true and inverse -"true" from the files. I had the same problem and it worked after I removed the inverse=true from the parent side.
Hi,
I have a classical bidirectional Parent Child relationship in my tables.
Parent has a set of Child Objects and each Child has a reference to the Parent.

This is implemented in the database tables. I used middlegen to automatically read the database schema and generate the mapping files and the POJO's. My problem was that the mappings were generated something like this.

In Parent.hbm.xml :
<set
name="children"
lazy ="true"
inverse="true"
>
<key blah blah>
<one-to-many class blah blah>
</set>

In Child.hbm.xml
<many-to-one
name="parent"
class="ParentClass"
not-null="true"
>
<column name="FOREIGNKEY TO PARENT" />
</many-to-one>

and the POJOs were also generated appropriately. When I called load on the Parent class ( ensuring that the children set was loaded by iterating over the Set - since lazy = true ) I had a live parent object . My assumption was that I should be able to say parent.setChildren(newSetOfChildren) and these changes should be reflected in the database. BUT that did not happen.

Upon reading I found that when you set inverse = true ,those changes are not persisted in the db. The end of the relationship where inverse =false is responsible for persisting it into the database.So I removed the inverse="true" references from the parent and now it seemed to work. Now when I say parent.setChildren(newSetOfChildren) those changes are persisted to the database.

My questions are:
a)There must be a reason why middlegen generated the parent with the inverse=true field.Even in the Hibernate documentation the example that they give has inverse = true for the parent. So Is the change that I did correct? and if not what other repurcussions could it have?

b)What happens if you do not specify inverse =true at any end?

Any clarifications in this will be appreciated.

Thanks
Hi All,
Should be a simple question for all you middlegen-hibernate veterans out there..

I am using the middlegen-hibernate plug in to read an existing schema
and generate the appropriate hbm.xml files. I can specifiy which tables I
want the mapping files for ( by using the <table> element) but in cases where I want the primary key of the table to be generated using a sequence, I cant seem to find the syntax or the construct to specify that in the middlegen ant task.

Any pointers on this?

Thanks in advance
Figured you can change this by providing your own custom type mapper to the hibernate plug in the Ant task.

something like this..

<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
javaTypeMapper="mypackage.MyJavaTypeMapper"
/>
Hi All,
Does anyone know if middlegen supports multiple database schemas? I am currently using an oracle database with tables split across 3 schemas and I plan on using Hibernate to access/modify them. How do I specify that in the middlegen ANT task?

Can any one point out how I can do that? ( or even "IF" it can be done? )

Regards
Sagar

P.S: As with all issues this is rather urgent