Friday, 24 May 2013

Remote debugging in eclipse: Failed to connect to remote VM. Connection refused. Connection refused: connect

Remote debugging in eclipse:
     Failed to connect to remote VM. Connection refused.
     Connection refused: connect

For using remote debugging in eclipse with Tomcat 7 follow the steps below.

Step 1:

    Set up the project in eclipse.

Step 2:

     Deploy the project to Tomcat 7.

Step 3: 

     Start the application in Tomcat.

Step 4:

      Set the debug points in eclipse.
      In Eclipse go to Run --> Debug Configurations
      In the left pane right  click on Remote Java Application and select New

     
Step 5:

      Give a Name and select the project to be debugged.
      Set
  •  host: ip address of computer on which Tomcat 7 is running, if it is on same machine you can use
          "localhost".
  • port: 8000
     

  • Then in source tab add the necessary projects and click "Apply".
 Step 6:
  
     Click on "Debug" and debug your application.

               There is chance that you should end up with a
                           "Failed to connect to remote VM. Connection refused."
                           "Connection refused: connect"
               error. To solve this download the zip version of Tomcat 7 and copy the files in the bin folder  
               (except bootstrap, Tomcat7, Tomcat7w and tomcat-juli) to the bin folder of Tomcat 7 you are 
               using. Then edit the startup.bat file in bin folder (with notepad or any editor) so that replace the 
               "start" command at the end of the file with "jpda start" and save the file. Then stop the 
               Tomcat  7 and start it by double clicking "startup.bat" file that you are edited, now Tomcat will 
               run in remote  debugging mode.


Saturday, 16 February 2013

AttributeError: 'NoneType' object has no attribute '_orm_template__view_look_dom_arc

Log:

Traceback (most recent call last):
  File "/opt/hnferp/server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/hnferp/server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/hnferp/server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/hnferp/server/bin/osv/orm.py", line 1645, in fields_view_get
    xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
  File "/opt/hnferp/server/bin/osv/orm.py", line 1314, in __view_look_dom_arch
    fields_def = self.__view_look_dom(cr, user, node, view_id, context=context)
  File "/opt/hnferp/server/bin/osv/orm.py", line 1285, in __view_look_dom
    fields.update(self.__view_look_dom(cr, user, f, view_id, context))
  File "/opt/hnferp/server/bin/osv/orm.py", line 1285, in __view_look_dom
    fields.update(self.__view_look_dom(cr, user, f, view_id, context))
  File "/opt/hnferp/server/bin/osv/orm.py", line 1285, in __view_look_dom
    fields.update(self.__view_look_dom(cr, user, f, view_id, context))
  File "/opt/hnferp/server/bin/osv/orm.py", line 1223, in __view_look_dom
    xarch, xfields = relation.__view_look_dom_arch(cr, user, f, view_id, ctx)
AttributeError: 'NoneType' object has no attribute '_orm_template__view_look_dom_arch'


This error occurs when you specify the class name as follows

      class sample_class(osv.osv):
                _name="sample_class"
                 _columns= {
                            'name': fields.char('Name', size=128),
                 }
      sample_class()

This can be solved by replacing the class name as sample.class as follows
 
    class sample_class(osv.osv):
                _name="sample.class"
                 _columns= {
                            'name': fields.char('Name', size=128),
                 }
      sample_class()
    

Thursday, 31 January 2013

ProgrammingError: can't adapt type 'browse_record'

OpenERP Programming error.

Error:
ProgrammingError: can't adapt type 'browse_record'

Solution:

For example, if you have provided 

            'product_id': line.product_id,
in _columns, the above error will occur. All you have to do is to provide the id of product_id as follows

            'product_id': line.product_id.id,

and it will solve the error.

socket.error: [Errno 98] Address already in use in OpenERP

OpenERP installation problem.
Error:

socket.error: [Errno 98] Address already in use


Solution:

Change the port number for openerp, this will resolve the problem.

If you are using two instances of OpenERP, then the following will do the magic:

1. Type          
                       sudo netstat -anpt 

in terminal. This will list the active processes and the port numbers they are using.

2. Find the process which uses the port number of OpenERP and note the pid(process id) of that process.

3. Then type

                    ps aux | grep openerp 

and verify the pid of that process.

4. Kill the process which uses the port number of OpenERP(if any) by the following command in terminal.

                     sudo kill -9 pid 

where pid is the process id. For example if 1234 is the pid you should enter 

                     sudo kill -9 1234

in terminal.

5. Then remove the pid of OpenERP server from /var/run/openerp by the following.
          
                    sudo rm /var/run/openerp-server.pid

6. Restart the openerp-server and it's done.

                    sudo /etc/init.d/openerp-server restart