Palash Sahu

Greenhorn
+ Follow
since Dec 06, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Palash Sahu

Hi,

I am using jdk6 compiler api.Do I need to set tools.jar at the classpath.
Actually when I don't have tools.jar at classpath, I am getting NullPointerException at the bottom line..
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager sjfm = compiler.getStandardFileManager(diagnostics, null, null);

Any help will be highly appreciated.

Regards,
Sabyasachi
18 years ago
Hi,

I am creating ant task "Javac" to compile a java file generated at runtime using ant-1.6.5.jar

A sample code snippet is as follows:-



Javac javac = new Javac();

javac.setProject (ANT_PROJECT);



Path path = new Path (ANT_PROJECT);

path.setPath (libdirPath_); // dependency jar needed for compilation of the generated java file.

......

javac.init ();

javac.setTarget ("1.5");

javac.setIncludejavaruntime (true);

javac.setDestdir (m_options.getClassesDir ());

javac.setEncoding (pnode.getEncoding ());

javac.setClasspath (path);

javac.setDebug (true);

javac.setSrcdir (srcPath);

javac.setOptimize (false);



try {

log. debug ("Compiling java source." + getJavaFile().getAbsolutePath());

javac.execute ();

log.debug ("Compiled java source.");

}



catch (BuildException e) {

}

Java file is compiled succesfully.

After that when I am trying to load the class using custom class loader in the following way:

private _JspTemplate tpl;

.....

ReproClassLoader loader = (ReproClassLoader) Thread.currentThread ().getContextClassLoader ();

Class clazz = loader.loadClass (classQualified);

tpl = (_JspTemplate) clazz.newInstance ();



getting an NoClassDefFoundError.. com.anshinsoft.repro.jsp._JspTemplate



_JspTemplate is an abstract class and the generated java file is subclass of _JspTemplate.

My custom class loader "ReproClassLoader" basically URLClassLoader is used to load jar files at runtime.



when I am writing custom implementation of findClass () method in ReproClassLoader and Inside of the findClass ()

the class loader fetches the byte codes from local file system, then it is succesfully executed.

My concern is whether this is the only solution or not?

Can I do it in a better way? Please suggest.

Any help is highly appreciated



Thanks and Regards,

Sabyasachi
18 years ago
Hi,
I am not confident how DefaultMessageListenerContainer use TransactionManager to work upon MessageDrivenPOJO. If I configure JtaTransactionManger with DefaultMessageListenerContainer. Does DefaultMessageListenerContainer perform actions like ( commit , rollback etc.)
internally ?
Does Spring provide any solution for bulk message commit. ( Consider a scenario if commit action is to be performed after receving 50 messages and processing those messages.) ?

Can I write custom MessageDrivenPOJO using MessageListenerAdapter and
inject TansactionManger into it ?

Could some one please provide me sample code how to use TransactionManager with MessageDrivenPOJo ??
Any help will be highly appreciated.

Regards,
Sabyasachi
Hi,
I am using JMS provider as IBM Websphere MQ5.3.1.
Message sending and receiving is working fine with jmsTemplate.
But when I am writing MessageDrivenPOJO class using DefaultMessageListenerContainer or MessageListenerAdapter,then I am getting error.
I have set up websphre MQ correctly.Added all required jars to the classpath.I have created QManager and Queue.Then inialized jndi. After that I binded instance of QueueConnectonFactory and Queue. My bean configuration file is as follows:-

<!-- description of the suite context -->
<description>This file defines beans of Message driven POJO and Message Listener Container</description>

<!-- this is the Message Driven POJO (MDP) -->
<bean id="msgDrivenPOJOId" class="com.anshinsoft.pi.messaging.MessageDrivenPOJOImpl"/>

<!-- and this is the message listener container -->
<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="concurrentConsumers" value="5"/>
<property name="connectionFactory" ref="jmsQueueConnectionFactory" />
<property name="destination" ref="jmsDestination" />
<property name="messageListener" ref="msgDrivenPOJOId" />
</bean>

<!-- JNDI Environment Template -->
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</prop>
<prop key="java.naming.provider.url">file:/C:/JNDI-Directory</prop>
</props>
</property>
</bean>


<!-- JMS Queue Connection Factory -->
<bean id="internalJmsQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>jmsQCF1</value>
</property>
</bean>

<!-- Spring JMS Queue Connection Factory -->
<bean id="jmsQueueConnectionFactory"
class="org.springframework.jms.connection.SingleConnectionFactory102">
<property name="targetConnectionFactory">
<ref bean="internalJmsQueueConnectionFactory"/>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
</bean>

<!-- Destination -->
<bean id="jmsDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>jmsspringQueue1</value>
</property>
</bean>

<!-- JMS Template -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate102">
<property name="connectionFactory">
<ref bean="jmsQueueConnectionFactory"/>
</property>
<property name="defaultDestination">
<ref bean="jmsDestination"/>
</property>
<property name="receiveTimeout">
<value>30000</value>
</property>
</bean>

<!-- JMS Sender -->
<bean id="messageSender" class="com.anshinsoft.pi.MessageSender">
<property name="jmsTemplate">
<ref bean="jmsTemplate"/>
</property>
</bean>

I think websphre mq(version 5.3.1) does support spring's new feature like DefaultMessageListenerContainer or MessageListenerAdapter.
I will be oblized for any kind of help and active participation to this topic.
Hi,
Can I send java objects (that are not serializable) to a Topic or Queue
using JMS API ??

Any help will be highly appreciated.

Thanks & Regards,
Sabyasachi
I am framework developer.I am developing some APIs.I want to put
an option of configuration file(i.e .properties file) for application developer.Application developer will configure some parameters in the configuration file.My API will fetch data from that configuration file
using JNDI and do some processing for the application developer.
Any help will be highly appreciated.

Originally posted by Ilja Preuss:


What exactly do you mean by "a lot"? How big are they? And how long will they live?

Java is very good at managing a lot of small, short lived objects. I would worry that the use of a object pool could be premature, unnecessarily complicating the design. Could you reproduce a memory issue in tests?


A approprite message processor is related to a particular message.
So for every message I have to create new instance of message processor.
That's why I was thinking of Object Pool concept.
I think maximum Pool size of 10 or 15 will suffice my requirement.

Originally posted by akilan irudaya raja:
Your are not going to implement message processor. But you need to
design the intelligence which selects the appropriate MessageProcessor, Is it so?



You pick the right point discussing over here.
For the appropriate MessageProcessor some input (such as msgProcessorClassName) is required with message from the application developed
by appliocation developer.But the challenge is this data(msgProcessorClassName)can be passed to getMessageProcessor() Method in a suitable way.
I have a AbstractMessageProcessor class which has some methods like
process,reprocess,postprocess etc.
Application developer will override these methods in the actual message
processing impplementation.My job is to provide a facade to build a sub class object of AbstractMessageProcessor (i.e actual message
processing impplementation) through some input(msgProcessorClassName)
with message from a application developed by apllication developer.
Thanks again all of you guys.
I am encounter problem after this message reception..i.e message processing
But as I am framework developer,not a application developer.I can't do
the actual implementation of message processing.It will be done by application
developer.So I need to build sub class object of message processor
depending data provided with message by application developer.
A point to be noted, some data(i.e msgprocessorClassName) is to be arrived with
the message which is needed to make message processor.
Here is the right challenge.How this data (i.e msgprocessorClassName)
is to be passed to getMessageProcessor() Method.
How can I design message processing infrustructure.
Any help will be highly apprecited.

Originally posted by Chris Nappin:
Can you elaborate on your requirements?

Do you have to consider threading? Does the pool need to be dynamic?

If threading is not an issue then the best way to minimise memory use is to use the singleton pattern. However whatever solution you decide to use can be hidden behind a factory method so you can change it in the future if needed.



Thanks a ton for your reply.
Actualy scenario is number of message processors will be invoked by Message Driven POJO(MDP), a spring's solution.
Can any body help me regarding object pooling.
I want to create a pool of message processor so that i need not create a new
new instance of processor to process every message.Bcoz in that lot of instance will be created and memory issue will be big concern.

Originally posted by Paul Sturrock:
"Message Driven POJO"?

Are you saying you need to implement something using JMS? If so, what?



Thanks for active participation to my topic.
I have tried to write Message Driven POJO(MDP) implementing javax.jms.MessageListener. you can also use org.springframework.jms.listener.SessionAwareMessageListener.I have studied MDP & decided to follow some steps to introduce support of MDP in a framework.
Steps are written below:-

* In a fashion similar to a Message-Driven Bean (MDB) in the EJB world, the Message-Driven POJO
(MDP) acts as a receiver for JMS messages.
* ListenerContainer is to be added.
* ListenerContainer is responsible for all threading of message reception and dispatch into "Message
Driven POJO" for processing.
* A message Listener Container is the intermediary between "Message Driven POJO" and a mesaging
provider. It takes care of registering to receive messages,participating in transactions,resource
aquisition and release etc.
* This allows an application developer to write complex business logic associated with receiving
messages.

But I am stuck at a point.
I have written Abstract Message processor class.As i am framework developer,
not a application developer.so application developer will write sub class of
Abstract Message processor.MDP will invoke process methods(eith no operation) of Abstract Message processor class.
if i load subclass object by :
Thread.currentThread().getContextClassLoader().loadClass(msgProcessorClassName);
it will become memory issue.bcoz for every message sub class of Abstract Message processor will be loaded.
what will be perfect design.
can any body give idea of Object pooling related to this issue.
I have to introduce support of Message Driven POJO to Messaging Service in a
framework.
Any help is highly appreciated.