RE: MDB not invoked

2012-04-12 Thread Johnny Guo
Hi David,

I'm not sure how to see the resources and binding in jmx-console, in fact, I 
don't know how to start jmx-console in openejb.


--
View this message in context: 
http://openejb.979440.n4.nabble.com/MDB-not-invoked-tp4548110p4553890.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MDB not invoked

2012-04-12 Thread David Blevins

On Apr 12, 2012, at 6:19 PM, Johnny Guo wrote:
> 
> I did try to config it in openejb.xml like below as well, but it just didn't 
> work for me.
> 
> 
>  type="javax.jms.ConnectionFactory">

Hi Johnny!

I did take a close look at your logs earlier and can verify this won't do 
anything (these things were being created already automatically).

I think what we need is a log line that says what the server understands is the 
Topic/Queue name of the MDB.  I had thought I added that as I've had this 
problem before as well.  I could be misremembering, though.

Anyway, once we get actual confirmation that the bean is truly tied to the 
queue/topic expected, then it's a simple act of using a JMX Console to see what 
the JMS broker is doing with the messages.  Via JMX you can see how many 
consumers (if any) there are for each Topic and Queue.  There should be at 
least one for the MDB itself.

Regardless of the logging, definitely do grab jconsole and attach to the 
broker's JVM and see what Topics and Queues there are and how many producers 
and consumers for each.

Let us know what you find and we can see what the next step might be.


-David




RE: MDB not invoked

2012-04-12 Thread Johnny Guo
Hi Romain,

I did try to config it in openejb.xml like below as well, but it just didn't 
work for me.





--
View this message in context: 
http://openejb.979440.n4.nabble.com/MDB-not-invoked-tp4548110p4553537.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: can't persist value in TransactionSynchronizationRegistry

2012-04-12 Thread David Blevins
This kind of EntityManager tracking is provided out of the box for you and is a 
standard part of JavaEE.  In fact it's one of the main benefits you get.  
EntityManagers are tracked in a transaction and flushed or discarded on commit 
or rollback, all automatically.

This doc talks about how it works:  

 - http://openejb.apache.org/jpa-concepts.html

Maybe also see the "JPA Integration" section of this answer which describes the 
tracking more tersely:

 - 
http://stackoverflow.com/questions/269186/besides-ear-and-ejb-what-do-i-get-from-a-j2ee-app-server-that-i-dont-get-in-a/9199893#9199893

So the question at hand, if your mechanism for tracking and the container's 
mechanism for tracking are the same, then why doesn't it work?  The answer 
applies to both.

The TransactionSynchronizationRegistry (and therefore the EntityManager tracked 
in it) only live as long as the transaction lives.  That will be for the 
duration of the one method call if the EJB is being called from someplace that 
doesn't already have a transaction in progress.

The only way to keep the TransactionSynchronizationRegistry around is to keep 
the transaction open longer.  There are some things to keep in mind:

   - Transactions are not multi-threaded
   - The transaction must end in the same thread in which it was began

As an FYI, those restrictions are not artificial.  Multi-threaded transactions 
are hard and there aren't any TransactionManagers that support it -- read, 
there's no way to get around it.

Your only option for truly holding an EntityManager for a long period of time 
is to track it between transactions.  The JavaEE standard term for this kind of 
tracking is called an EXTENDED PersistenceContext.  This example isn't really 
documented, but the code works and uses EXTENDED persistence contexts.

  
http://openejb.apache.org/examples-trunk/injection-of-entitymanager/README.html

EXTENDED persistence contexts provide the same transactional exclusivity and 
tracking that a TRANSACTION scoped persistence context provides, but with the 
added benefit that the EntityManager itself will live as long as the @Stateful 
bean that created it.  You can track the @Stateful bean however you want, such 
as by putting it into the HttpSession.

Hope this helps!


-David


On Apr 12, 2012, at 9:15 AM, Alexis KRIER wrote:

> 
> Hello all I have an entityManagerProvider wich creates the entityManager if 
> it does not exist already.
> 
> To do this I store the EntityManager created in 
> TransactionSynchronizationRegistry 
> TransactionSynchronizationRegistry registry = 
> (TransactionSynchronizationRegistry)getContext().lookup(
>  "java:comp/TransactionSynchronizationRegistry");
> (works also with java:openejb)
> 
> then when an other call is done to the EMProvider I look in the registry to 
> get my manager if it exists:
> TransactionSynchronizationRegistry registry = 
> (TransactionSynchronizationRegistry)getContext().lookup(
>  "java:comp/TransactionSynchronizationRegistry");
> registry.getesources("The key")
> 
> The problem is that on each call from a stateless resource, it seem that the 
> registry is always empty...
> 
> By the way the registry.put("My entity") is working well because when I do 
> immediately after a get I can see My value stored.
> 
> Is there a trick to keep the TransactionSynchronizationRegistry Statefull?
> 
> thank you
> 
> Alexis
> 



can't persist value in TransactionSynchronizationRegistry

2012-04-12 Thread Alexis KRIER

Hello all I have an entityManagerProvider wich creates the entityManager if it 
does not exist already.

To do this I store the EntityManager created in 
TransactionSynchronizationRegistry 
 TransactionSynchronizationRegistry registry = 
(TransactionSynchronizationRegistry)getContext().lookup(
  "java:comp/TransactionSynchronizationRegistry");
(works also with java:openejb)

then when an other call is done to the EMProvider I look in the registry to get 
my manager if it exists:
TransactionSynchronizationRegistry registry = 
(TransactionSynchronizationRegistry)getContext().lookup(
  "java:comp/TransactionSynchronizationRegistry");
registry.getesources("The key")

The problem is that on each call from a stateless resource, it seem that the 
registry is always empty...

By the way the registry.put("My entity") is working well because when I do 
immediately after a get I can see My value stored.

Is there a trick to keep the TransactionSynchronizationRegistry Statefull?

thank you

Alexis
  

RE: MDB not invoked

2012-04-12 Thread Johnny Guo
Hi,

I have tried to setup it following the examples, but just not working for me.
Here are some codes:

1) No annotation in mdb , just a onMessage method. The ejb-jar.xml:


  



  StandardReportsBean
  
se.it.newjena.reports.bean.receivers.StandardReportsBean

  javax.jms.MessageListener

  

  
destination
  
ReportStandardJMSQueue


  
destinationType
  
javax.jms.Queue

  

  

jms/tdm-newjena/ReportStandardJMSConnFactory
javax.jms.ConnectionFactory
  

  
ReportStandardJMSQueue
javax.jms.Queue
  


  

2) The resources in the server.xml for tomcat in Eclipse:


   



3) The code to send message:
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueSender queueSender = null;
ObjectMessage message = null;

try {
// check if jndiContext and queueConnectionFactory are set if not
// throw an exception

if (jndiContext == null || queueConnectionFactory == null)
throw new Exception("InitialContext or QueueConnectionFactory 
is not set");

/*
 * Look up queue.
 */
queue = (Queue) jndiContext.lookup("ReportStandardJMSQueue");
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false, 
Session.AUTO_ACKNOWLEDGE);
queueSender = queueSession.createSender(queue);


/*
 * Send message
 */
message = queueSession.createObjectMessage();
message.setObject(wrapper);
queueSender.send(message);

logger.info("Jena reports - a message has been sent");

}

  I also tried the below in ejb-jar.xml, but it will say the queue has 
binded to context, and if I removed the resource for this queue in server.xml, 
then it can't find the queue for sending messages.
  
ReportStandardJMSQueue
javax.jms.Queue
  

Best Regards,

Johnny Guo
VIT Tianjin
Mobile:   +86 13682195826
E-mail:qiang@consultant.volvo.com

From: Romain Manni-Bucau [via OpenEJB] 
[mailto:ml-node+s979440n4548744...@n4.nabble.com]
Sent: Wednesday, April 11, 2012 8:23 PM
To: Guo Qiang (Consultant)
Subject: Re: MDB not invoked

Hi,

how did you configure:
1) the mdb
2) the jmx resources (queue, connection factory, ...)
3) the client
?

it sounds like a config error. If you can share some code we could help you
more efficiently.

Note: some JMS sample are here:
http://openejb.apache.org/examples-trunk/index.html

- Romain


2012/4/11 Johnny Guo <[hidden 
email]>

> Hi,
>
> I'm new to openejb. Now i'm working with openejb integrated with Tomcat in
> Eclipse. Openejb can start successfully. One MDB was setup to listen to a
> jms queue and the start log like this:
> [INFO] Found ejb module EjbModule in war /newjena
> [INFO] Found ejb module EjbModule in war /newjena
> [INFO] Configuring enterprise application:
>
> C:\TDM\workspace\was_migr\newjena2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\newjena
> [INFO] Auto-linking resource-ref
> 'jms/tdm-newjena/ReportStandardJMSConnFactory' in bean StandardReportsBean
> to Resource(id=jms/tdm-newjena/ReportStandardJMSConnFactory)
> [INFO] Auto-linking resource-ref 'jms/tdm-newjena/ReportStandardJMSQueue'
> in
> bean StandardReportsBean to
> Resource(id=jms/tdm-newjena/ReportStandardJMSQueue)
> [INFO] Configuring Service(id=jms/tdm-newjena/ReportStandardJMSQueue,
> type=Resource, provider-id=Default Queue)
> [INFO] Auto-creating a Resource with id
> 'jms/tdm-newjena/ReportStandardJMSQueue' of type 'javax.jms.Queue for
> 'StandardReportsBean'.
> [INFO] Creating Resource(id=jms/tdm-newjena/ReportStandardJMSQueue)
> [INFO] Enterprise application
>
> "C:\TDM\workspace\was_migr\newjena2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\newjena"
> loaded.
> [INFO] Assembling app:
>
> C:\TDM\workspace\was_migr\newjena2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\newjena
> [INFO] Jndi(name=StandardReportsBean) -->
> Ejb(deployment-id=StandardReportsBean)
> [INFO] Created Ejb(deployment-id=StandardReportsBean,
> ejb-name=StandardReportsBean, container=My MDB Container)
>
> But when the message is sent to the queue, the MDB can not be invoked.
>  What
> is the problem and how can i get more detail information if something like
> this happens?
> Thanks
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/MDB-not-invoked-tp4548110p4548110.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>


If you reply to this email, your message will be added to the discussion below:
http://openejb.979440.n4.nabble.com/MDB-not-invoked-tp4548110p4548744.htm

RE: MDB not invoked

2012-04-12 Thread Johnny Guo
Hi,

I have tried to setup it following the examples, but just not working for me.
Here are some codes:

1) No annotation in mdb , just a onMessage method. The ejb-jar.xml:


  



  StandardReportsBean
  
se.it.newjena.reports.bean.receivers.StandardReportsBean

  javax.jms.MessageListener

  

  
destination
  
ReportStandardJMSQueue


  
destinationType
  
javax.jms.Queue

  

  

jms/tdm-newjena/ReportStandardJMSConnFactory
javax.jms.ConnectionFactory
  

  
ReportStandardJMSQueue
javax.jms.Queue
  


  

2) The resources in the server.xml for tomcat in Eclipse:


   



3) The code to send message:
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueSender queueSender = null;
ObjectMessage message = null;

try {
// check if jndiContext and queueConnectionFactory are set if not
// throw an exception

if (jndiContext == null || queueConnectionFactory == null)
throw new Exception("InitialContext or QueueConnectionFactory 
is not set");

/*
 * Look up queue.
 */
queue = (Queue) jndiContext.lookup("ReportStandardJMSQueue");
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false, 
Session.AUTO_ACKNOWLEDGE);
queueSender = queueSession.createSender(queue);


/*
 * Send message
 */
message = queueSession.createObjectMessage();
message.setObject(wrapper);
queueSender.send(message);

logger.info("Jena reports - a message has been sent");

}

  I also tried the below in ejb-jar.xml, but it will say the queue has 
binded to context, and if I removed the resource for this queue in server.xml, 
then it can't find the queue for sending messages.
  
ReportStandardJMSQueue
javax.jms.Queue
  



--
View this message in context: 
http://openejb.979440.n4.nabble.com/MDB-not-invoked-tp4548110p4550743.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEjb cryptography usage

2012-04-12 Thread Romain Manni-Bucau
that's what i think

the usage in openejb is limited,
look: org.apache.openejb.resource.jdbc.StaticDESPasswordCipher

- Romain


2012/4/12 Borislav Kapukaranov 

> Hi Romain,
>
> Thanks for the fast reply!
> I'm actually more interested whether the core OpenEjb
> components(openejb-core, openejb-jee, etc..) use cryptographic software or
> the notice is there because the standalone OpenEjb server includes
> third-parties that do use cryptography.
>
> Thanks,
> Bobby
>
> On Thu, Apr 12, 2012 at 10:03 AM, Romain Manni-Bucau
> wrote:
>
> > Hi,
> >
> > i'm *not totally sure* but i think it is written this way because it
> > concerns dependencies and not directly openejb, so maybe have a look to
> > these dependencies.
> >
> > - Romain
> >
> >
> > 2012/4/12 Borislav Kapukaranov 
> >
> > > Hey folks,
> > >
> > > I saw in the OpenEjb readme file that there is a "Cryptographic
> Software
> > > Notice" section. I understand some countries may have more restrictive
> > > approach but couldn't make sense of the last part of the section.
> > >
> > > The following provides more details on the included cryptographic
> > > software:
> > >  Apache ActiveMQ  Included Binary
> > >  Apache Derby Included Binary
> > >  Apache Geronimo  Included Binary
> > >  Apache TomcatSpecially Designed to Work With
> > >
> > > Can you give more details please?
> > >
> > > Thank you,
> > > Borislav
> > >
> >
>


Re: OpenEjb cryptography usage

2012-04-12 Thread Borislav Kapukaranov
Hi Romain,

Thanks for the fast reply!
I'm actually more interested whether the core OpenEjb
components(openejb-core, openejb-jee, etc..) use cryptographic software or
the notice is there because the standalone OpenEjb server includes
third-parties that do use cryptography.

Thanks,
Bobby

On Thu, Apr 12, 2012 at 10:03 AM, Romain Manni-Bucau
wrote:

> Hi,
>
> i'm *not totally sure* but i think it is written this way because it
> concerns dependencies and not directly openejb, so maybe have a look to
> these dependencies.
>
> - Romain
>
>
> 2012/4/12 Borislav Kapukaranov 
>
> > Hey folks,
> >
> > I saw in the OpenEjb readme file that there is a "Cryptographic Software
> > Notice" section. I understand some countries may have more restrictive
> > approach but couldn't make sense of the last part of the section.
> >
> > The following provides more details on the included cryptographic
> > software:
> >  Apache ActiveMQ  Included Binary
> >  Apache Derby Included Binary
> >  Apache Geronimo  Included Binary
> >  Apache TomcatSpecially Designed to Work With
> >
> > Can you give more details please?
> >
> > Thank you,
> > Borislav
> >
>


Re: OpenEjb cryptography usage

2012-04-12 Thread Romain Manni-Bucau
Hi,

i'm *not totally sure* but i think it is written this way because it
concerns dependencies and not directly openejb, so maybe have a look to
these dependencies.

- Romain


2012/4/12 Borislav Kapukaranov 

> Hey folks,
>
> I saw in the OpenEjb readme file that there is a "Cryptographic Software
> Notice" section. I understand some countries may have more restrictive
> approach but couldn't make sense of the last part of the section.
>
> The following provides more details on the included cryptographic
> software:
>  Apache ActiveMQ  Included Binary
>  Apache Derby Included Binary
>  Apache Geronimo  Included Binary
>  Apache TomcatSpecially Designed to Work With
>
> Can you give more details please?
>
> Thank you,
> Borislav
>