Re: [Resin-interest] small question about entity ejb

2008-03-11 Thread Riccardo Cohen

Hi again,

I tried @TransactionAnnotation but it generated frequent errors like this :

[10:44:42.851] {http--8000-2} error: cannot read: mp/adminservlet.java
[10:44:42.851] {http--8000-2} 1 error

the select still work but no update


I tried then with the UserTransaction method, but there was no update. I 
looked at the amber-basic-field example, and found that even if the 
_uTrans was defined, it was not used, instead I found 
_manager.getTransaction(), so I tried with that, and still no update.


but now I can see in the finer log for sql :

[11:18:22.968] {http--8000-10} mp_db_pool.0:setAutoCommit(false)
[11:18:22.968] {http--8000-10} mp_db_pool.0:commit()
[11:18:22.969] {http--8000-10} mp_db_pool.0:setAutoCommit(true)

Which means that the transaction is being used, but no update when doing 
setTitle()


I must be missing something, because the sample works all right. I 
re-read all conf, and found nothing strange. The only difference seems 
to be that I use jdbc to mysql instead of jdbc/resin embedded db.


Thanks for any info.
Attached some files of my little test.

Scott Ferguson wrote:

On Mar 10, 2008, at 1:29 AM, Riccardo Cohen wrote:


Thanks a lot, I understand that I need a transaction now, while before
it could work without this... I have no idea of how to do that.

I noticed that in the doc of amber
(http://caucho.com/resin/doc/amber.xtp) there was a
@TransactionAnnotation but this makes a syntax error !
Thanks to eclipse I found a @TransactionAnn, I added it at the  
beginning
of my function definition, but this does not change (no update  
generated)


It should be @TransactionAttribute.  I'm fixing the docs.

The @TransactionAttribute is the easiest method.  You need to put it  
on a Resin-IoC-aware object, e.g. a bean or an EJB stateless bean or  
a servlet.  If you put it on an arbitrary class, it won't do anything.


You can also use UserTransaction to do essentially the same thing:

class MyFoo {
   @In UserTransaction _ut;

   void myStuff()
   {
 _ut.begin();
 try {
   ...
 } finally {
   ut.commit();
 }
  }

That's essentially identical to

   @TransactionAttribute void myStuff()
   {
 ...
   }

If you turn logging level=fine, you'll see the transaction begin()/ 
commit().  So you can use the log to make sure the transactions are  
working properly.


-- Scott


Is there any doc about this ?
Thanks

Daniel López wrote:

Hi again,

Some quick tests show that no persist() or merge() should be  
necessary
to update an entity inside a persistent context. I tested with  
Hibernate

and Amber as persistence providers and in both cases, nothing was
necessary. That was using Resin 3.1.5 and RESOURCE_LOCAL as  
transaction
type, which means that the problem might be with the container  
managed

transactions.

S!
D.

Daniel López escribió:
AFAIK, using merge should not be necessary unless the entity has  
been
updated outside a persistent context and then needs to be  
synchronised
back with the DB contents. persist() is just for new entities so  
reading
the docs, updating an entity inside a persistent context should  
require

no action. Unless an exception is thrown, of course ;).

I'm going to do some tests...

S!
D.

Matt Johnston escribió:
I think you will need to use either the persist() or merge()  
methods of
the EntityManager in order to save your data to the database. In  
your
case since you are updating an existing record, you will need to  
use:


m_manager.merge(homeobj)


Matt

Riccardo Cohen wrote:

Hi
I used to play with entity ejb with resin 3.0 with no problem.  
Now in

3.1.5 I have this code :

  @PersistenceContext(name=public) private EntityManager  
m_manager;


  public boolean set_homeinfo(int id_user,String title)
  {
boolean success=false;
Query hqr=m_manager.createQuery(select h from homeinfo h  
where

h.id_user=+id_user);
Listhomeinfo hitems = (Listhomeinfo)hqr.getResultList();
if (hitems.size()==1)
{
  homeinfo homeobj=hitems.get(0);
  System.out.println(title was +homeobj.getTitle());
  homeobj.setTitle(title);
  success=true;
}
return(success);
  }

The select works all right, but the title field is never  
modified. I
added finer info on sql to see database requests in log, and  
there is no

update. Did I miss something ?

I looked at the resin amber tutorials, but there are only select
samples, I did not see insert and update samples... I remember
problems like this with 3.0 when the entity bean was reused, it  
was not

saved, but here it is not the case.

Thanks for any help.



___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest


--
Très cordialement,

Riccardo Cohen
---
Articque
http://www.articque.com
149 av Général de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49



Re: [Resin-interest] More on include()/forward() issue.

2008-03-11 Thread Ilya Kasnacheev
В сообщении от 7 Март 2008 22:12 Mattias Jiderhamn написал(a):

  page - include (forward - forward - forward - forward - page)
 
  ... forward() in included servlet does not mean instead of including
  page but instead of included page
 Ok, now I see where you're coming from.
 Do you have to issue the explicit .flush()
No I don't, but it eventually commits when enough data is printed to out.

 or would increasing the 
 buffer (response.setBufferSize()) prevent the response from being
 comitted until the included forward has been issued???
This way is too like hack. What if we'll fill this buffer prematurely anyway?

  What about my anonymous wrapper? See reply to original post.
 It may work if you are certain there will be no flushing to the client
 before a forward().
Nope, there would be a lot of flushing before forward().
Because, forward() final destination isn't going to print page from scratch. 
Instead it is going to print a fragment of page to be include()d.
After it will return, the rest of page() will be printed.
Also, there can be quite a few such (include() - forward() - forward() - 
print()) sessions.

 Using a buffered dispatch-response is safer. I think I have an
 implementation lying around on my other computer which I could post, but
 you should also be able to easily implement it yourself or find it on
 the net.
Yes, I understand, but for now I've just hacked isCommitted(). I'll know what 
to do if it'll stop working.


___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest


Re: [Resin-interest] small question about entity ejb

2008-03-11 Thread Riccardo Cohen
After some new tests, I found something that works :

if I do :

 homeobj=m_manager.find(homeinfo.class,theid);
 homeobj.setTitle(title);

the object is saved
but if I use the homeobj that comes from

Query hqr=m_manager.createQuery(select h from homeinfo h where 
h.id_user=+id_user);

and I try to call setTitle, then the object is not saved.

I don't understand why, can somebody explain me please ? (or give a link 
to the right doc...)

Thanks a lot.



Riccardo Cohen wrote:
 Hi again,
 
 I tried @TransactionAnnotation but it generated frequent errors like this :
 
 [10:44:42.851] {http--8000-2} error: cannot read: mp/adminservlet.java
 [10:44:42.851] {http--8000-2} 1 error
 
 the select still work but no update
 
 
 I tried then with the UserTransaction method, but there was no update. I 
 looked at the amber-basic-field example, and found that even if the 
 _uTrans was defined, it was not used, instead I found 
 _manager.getTransaction(), so I tried with that, and still no update.
 
 but now I can see in the finer log for sql :
 
 [11:18:22.968] {http--8000-10} mp_db_pool.0:setAutoCommit(false)
 [11:18:22.968] {http--8000-10} mp_db_pool.0:commit()
 [11:18:22.969] {http--8000-10} mp_db_pool.0:setAutoCommit(true)
 
 Which means that the transaction is being used, but no update when doing 
 setTitle()
 
 I must be missing something, because the sample works all right. I 
 re-read all conf, and found nothing strange. The only difference seems 
 to be that I use jdbc to mysql instead of jdbc/resin embedded db.
 
 Thanks for any info.
 Attached some files of my little test.
 
 Scott Ferguson wrote:
 On Mar 10, 2008, at 1:29 AM, Riccardo Cohen wrote:

 Thanks a lot, I understand that I need a transaction now, while before
 it could work without this... I have no idea of how to do that.

 I noticed that in the doc of amber
 (http://caucho.com/resin/doc/amber.xtp) there was a
 @TransactionAnnotation but this makes a syntax error !
 Thanks to eclipse I found a @TransactionAnn, I added it at the  
 beginning
 of my function definition, but this does not change (no update  
 generated)

 It should be @TransactionAttribute.  I'm fixing the docs.

 The @TransactionAttribute is the easiest method.  You need to put it  
 on a Resin-IoC-aware object, e.g. a bean or an EJB stateless bean 
 or  a servlet.  If you put it on an arbitrary class, it won't do 
 anything.

 You can also use UserTransaction to do essentially the same thing:

 class MyFoo {
@In UserTransaction _ut;

void myStuff()
{
  _ut.begin();
  try {
...
  } finally {
ut.commit();
  }
   }

 That's essentially identical to

@TransactionAttribute void myStuff()
{
  ...
}

 If you turn logging level=fine, you'll see the transaction begin()/ 
 commit().  So you can use the log to make sure the transactions are  
 working properly.

 -- Scott

 Is there any doc about this ?
 Thanks

 Daniel López wrote:
 Hi again,

 Some quick tests show that no persist() or merge() should be  necessary
 to update an entity inside a persistent context. I tested with  
 Hibernate
 and Amber as persistence providers and in both cases, nothing was
 necessary. That was using Resin 3.1.5 and RESOURCE_LOCAL as  
 transaction
 type, which means that the problem might be with the container  managed
 transactions.

 S!
 D.

 Daniel López escribió:
 AFAIK, using merge should not be necessary unless the entity has  been
 updated outside a persistent context and then needs to be  
 synchronised
 back with the DB contents. persist() is just for new entities so  
 reading
 the docs, updating an entity inside a persistent context should  
 require
 no action. Unless an exception is thrown, of course ;).

 I'm going to do some tests...

 S!
 D.

 Matt Johnston escribió:
 I think you will need to use either the persist() or merge()  
 methods of
 the EntityManager in order to save your data to the database. In  
 your
 case since you are updating an existing record, you will need to  
 use:

 m_manager.merge(homeobj)


 Matt

 Riccardo Cohen wrote:
 Hi
 I used to play with entity ejb with resin 3.0 with no problem.  
 Now in
 3.1.5 I have this code :

   @PersistenceContext(name=public) private EntityManager  
 m_manager;

   public boolean set_homeinfo(int id_user,String title)
   {
 boolean success=false;
 Query hqr=m_manager.createQuery(select h from homeinfo h  where
 h.id_user=+id_user);
 Listhomeinfo hitems = (Listhomeinfo)hqr.getResultList();
 if (hitems.size()==1)
 {
   homeinfo homeobj=hitems.get(0);
   System.out.println(title was +homeobj.getTitle());
   homeobj.setTitle(title);
   success=true;
 }
 return(success);
   }

 The select works all right, but the title field is never  
 modified. I
 added finer info on sql to see database requests in log, and  
 there is no
 update. Did I miss something ?

 I looked at the resin amber tutorials, but there are only select

Re: [Resin-interest] Managing separate watchdog processes in 3.1.5

2008-03-11 Thread Bill Au
Sorry, I had misread your original question.

Bill

On Tue, Mar 11, 2008 at 9:27 AM, Eric Kreiser [EMAIL PROTECTED] wrote:

  I had found the watchdog-port... my issue with this is that when it
 binds to the IP, it binds to the main IP of the server... so if I have say
 10 sites running on a machine, I would need to keep track of 10 unique port
 numbers to assign to each resin instance.  In my case, each of the 10 resin
 instances are bound to different IP addresses on the server, so I would much
 prefer a way to specify that the watchdog port bind to the same IP the resin
 server is using for the sites themselves.

 Bill Au wrote:

 watchdog-port

 http://www.caucho.com/resin/doc/resin-watchdog.xtp

 I also want to run multiple independent instances on the same machine.
 Scott and company, I think it will be useful to include an example of that
 in the resin 3.1 documentation for the watchdog process.
 This is a big change from Resin 3.0 which took me a while to figure out.

 Bill

 On Mon, Mar 10, 2008 at 5:19 PM, Eric Kreiser [EMAIL PROTECTED] wrote:

   Is there a way to specify what IP the watchdog-port will bind to?
 
  I want to be able to have a number of sites/instances of resin running
  on a machine
  I want all of them to run independent of each other
 
  so to keep them independent, I need to specify a watchdog-port... but if
  I do... it binds to the main ip of the machine... so in my scenario, I would
  need to assign each resin instance a unique port number.
 
  Is there a better way for me to handle this?
 
  Thanks
  Eric Kreiser
 
 
 
  ___
  resin-interest mailing list
  resin-interest@caucho.com
  http://maillist.caucho.com/mailman/listinfo/resin-interest
 
 
 --

 ___
 resin-interest mailing [EMAIL 
 PROTECTED]://maillist.caucho.com/mailman/listinfo/resin-interest


 --

 *Eric S. Kreiser**
 *Senior Software Architect


 *M**z**inga**
 *5095 Ritter Road • Mechanicsburg, PA  17055
 ---
 *Call my office:* 717.790.0400 x4256
 *Fax me:* 717.790.0401
 *Email me:* [EMAIL PROTECTED]
 *Learn more:* http://mzinga.com/v/ekreiser/
 *Toll Free:* 800.869.5763



 ___
 resin-interest mailing list
 resin-interest@caucho.com
 http://maillist.caucho.com/mailman/listinfo/resin-interest


___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest


Re: [Resin-interest] small question about entity ejb

2008-03-11 Thread Scott Ferguson

On Mar 11, 2008, at 6:28 AM, Riccardo Cohen wrote:

 After some new tests, I found something that works :

 if I do :

 homeobj=m_manager.find(homeinfo.class,theid);
 homeobj.setTitle(title);

 the object is saved
 but if I use the homeobj that comes from

 Query hqr=m_manager.createQuery(select h from homeinfo h where
 h.id_user=+id_user);

 and I try to call setTitle, then the object is not saved.

 I don't understand why, can somebody explain me please ? (or give a  
 link
 to the right doc...)

Thanks.  I've filed this as http://bugs.caucho.com/view.php?id=2514

It sounds like an Amber bug.

-- Scott



 Thanks a lot.



 Riccardo Cohen wrote:
 Hi again,

 I tried @TransactionAnnotation but it generated frequent errors  
 like this :

 [10:44:42.851] {http--8000-2} error: cannot read: mp/ 
 adminservlet.java
 [10:44:42.851] {http--8000-2} 1 error

 the select still work but no update


 I tried then with the UserTransaction method, but there was no  
 update. I
 looked at the amber-basic-field example, and found that even if the
 _uTrans was defined, it was not used, instead I found
 _manager.getTransaction(), so I tried with that, and still no update.

 but now I can see in the finer log for sql :

 [11:18:22.968] {http--8000-10} mp_db_pool.0:setAutoCommit(false)
 [11:18:22.968] {http--8000-10} mp_db_pool.0:commit()
 [11:18:22.969] {http--8000-10} mp_db_pool.0:setAutoCommit(true)

 Which means that the transaction is being used, but no update when  
 doing
 setTitle()

 I must be missing something, because the sample works all right. I
 re-read all conf, and found nothing strange. The only difference  
 seems
 to be that I use jdbc to mysql instead of jdbc/resin embedded db.

 Thanks for any info.
 Attached some files of my little test.

 Scott Ferguson wrote:
 On Mar 10, 2008, at 1:29 AM, Riccardo Cohen wrote:

 Thanks a lot, I understand that I need a transaction now, while  
 before
 it could work without this... I have no idea of how to do that.

 I noticed that in the doc of amber
 (http://caucho.com/resin/doc/amber.xtp) there was a
 @TransactionAnnotation but this makes a syntax error !
 Thanks to eclipse I found a @TransactionAnn, I added it at the
 beginning
 of my function definition, but this does not change (no update
 generated)

 It should be @TransactionAttribute.  I'm fixing the docs.

 The @TransactionAttribute is the easiest method.  You need to put it
 on a Resin-IoC-aware object, e.g. a bean or an EJB stateless bean
 or  a servlet.  If you put it on an arbitrary class, it won't do
 anything.

 You can also use UserTransaction to do essentially the same thing:

 class MyFoo {
   @In UserTransaction _ut;

   void myStuff()
   {
 _ut.begin();
 try {
   ...
 } finally {
   ut.commit();
 }
  }

 That's essentially identical to

   @TransactionAttribute void myStuff()
   {
 ...
   }

 If you turn logging level=fine, you'll see the transaction  
 begin()/
 commit().  So you can use the log to make sure the transactions are
 working properly.

 -- Scott

 Is there any doc about this ?
 Thanks

 Daniel López wrote:
 Hi again,

 Some quick tests show that no persist() or merge() should be   
 necessary
 to update an entity inside a persistent context. I tested with
 Hibernate
 and Amber as persistence providers and in both cases, nothing was
 necessary. That was using Resin 3.1.5 and RESOURCE_LOCAL as
 transaction
 type, which means that the problem might be with the container   
 managed
 transactions.

 S!
 D.

 Daniel López escribió:
 AFAIK, using merge should not be necessary unless the entity  
 has  been
 updated outside a persistent context and then needs to be
 synchronised
 back with the DB contents. persist() is just for new entities so
 reading
 the docs, updating an entity inside a persistent context should
 require
 no action. Unless an exception is thrown, of course ;).

 I'm going to do some tests...

 S!
 D.

 Matt Johnston escribió:
 I think you will need to use either the persist() or merge()
 methods of
 the EntityManager in order to save your data to the database. In
 your
 case since you are updating an existing record, you will need to
 use:

 m_manager.merge(homeobj)


 Matt

 Riccardo Cohen wrote:
 Hi
 I used to play with entity ejb with resin 3.0 with no problem.
 Now in
 3.1.5 I have this code :

  @PersistenceContext(name=public) private EntityManager
 m_manager;

  public boolean set_homeinfo(int id_user,String title)
  {
boolean success=false;
Query hqr=m_manager.createQuery(select h from homeinfo h   
 where
 h.id_user=+id_user);
Listhomeinfo hitems = (Listhomeinfo)hqr.getResultList();
if (hitems.size()==1)
{
  homeinfo homeobj=hitems.get(0);
  System.out.println(title was +homeobj.getTitle());
  homeobj.setTitle(title);
  success=true;
}
return(success);
  }

 The select works all right, but the title field is never
 modified. I
 added finer info on sql to see database 

Re: [Resin-interest] Managing separate watchdog processes in 3.1.5

2008-03-11 Thread Scott Ferguson


On Mar 11, 2008, at 6:27 AM, Eric Kreiser wrote:

I had found the watchdog-port... my issue with this is that when  
it binds to the IP, it binds to the main IP of the server... so if I  
have say 10 sites running on a machine, I would need to keep track  
of 10 unique port numbers to assign to each resin instance.  In my  
case, each of the 10 resin instances are bound to different IP  
addresses on the server, so I would much prefer a way to specify  
that the watchdog port bind to the same IP the resin server is using  
for the sites themselves.


Hmm.  It should be only binding to localhost.  The idea being that the  
watchdog should only be accessible on the local machine for security  
reasons.


It would be possible to bind to an external port, but I'm not certain  
if that would really be providing enough benefit to offset the  
security issue.


-- Scott




Bill Au wrote:


watchdog-port

http://www.caucho.com/resin/doc/resin-watchdog.xtp

I also want to run multiple independent instances on the same  
machine.
Scott and company, I think it will be useful to include an example  
of that in the resin 3.1 documentation for the watchdog process.
This is a big change from Resin 3.0 which took me a while to figure  
out.


Bill

On Mon, Mar 10, 2008 at 5:19 PM, Eric Kreiser [EMAIL PROTECTED]  
wrote:

Is there a way to specify what IP the watchdog-port will bind to?

I want to be able to have a number of sites/instances of resin  
running on a machine

I want all of them to run independent of each other

so to keep them independent, I need to specify a watchdog-port...  
but if I do... it binds to the main ip of the machine... so in my  
scenario, I would need to assign each resin instance a unique port  
number.


Is there a better way for me to handle this?

Thanks
Eric Kreiser



___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest


___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest



--

Eric S. Kreiser
Senior Software Architect

Mzinga
5095 Ritter Road • Mechanicsburg, PA  17055
---
Call my office: 717.790.0400 x4256
Fax me: 717.790.0401
Email me: [EMAIL PROTECTED]
Learn more: http://mzinga.com/v/ekreiser/
Toll Free: 800.869.5763

___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest


___
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest