CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Fatal error: Cannot redeclare class Services_JSON
Pages: [1]

Author Topic: Fatal error: Cannot redeclare class Services_JSON  (Read 13109 times)

Lanesa

  • Guest
Fatal error: Cannot redeclare class Services_JSON
December 09, 2008, 11:01:27 am
I tried to import contacts and get this error:

Fatal error: Cannot redeclare class Services_JSON in administrator/components/com_civicrm/civicrm/packages/Services/JSON.php on line 116

I have a copy of CiviCRM on my local machine and wanted to import the contacts from the local machine to the live one.
« Last Edit: January 06, 2009, 08:36:47 am by Lanesa »

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Fatal error: Cannot redeclare class Services_JSON
December 09, 2008, 11:46:54 am
It might be possible that "Services_JSON" is declared in some other component.

Kurund
Found this reply helpful? Support CiviCRM

Lanesa

  • Guest
Re: Fatal error: Cannot redeclare class Services_JSON
December 09, 2008, 12:16:59 pm
Is there a fix for this. I have several components installed. JomComments, Attachments and JCal Pro.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Fatal error: Cannot redeclare class Services_JSON
December 09, 2008, 01:43:18 pm

You'll have to help debug and figure out which component is also including it. We dont know the conflict and hence dont know what/where to fix

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Lanesa

  • Guest
Re: Fatal error: Cannot redeclare class Services_JSON
December 09, 2008, 04:56:42 pm
 ??? I'm not a programmer, I don't know how to debug the program. I'm a designer with basic programming skills, if you give me some guidance, I definitely assist in any way I can.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Fatal error: Cannot redeclare class Services_JSON
December 09, 2008, 05:12:58 pm

sorry, you'll need to lean on one of your programmer friends and/or hire someone from our professional service listing: http://civicrm.org/professional/

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Lanesa

  • Guest
Re: Fatal error: Cannot redeclare class Services_JSON
December 10, 2008, 05:50:42 pm
I'll probably list it on Joomlancer and see what the bids look like. They are pretty reasonable.

Riddick

  • Guest
Re: Fatal error: Cannot redeclare class Services_JSON
December 23, 2008, 06:48:29 pm
Yep I am getting exactly the same problem, however I can't see how this could be a conflict with another program as it is pretty specific.


NilsHenrik

  • Guest
Solution
June 28, 2009, 07:52:25 pm
Here is the work around if you have Azrul products installed on your site:

To temporarily unpublish Components:

From the back-end Joomla Control Panel

Click on Extensions/Components
Disable JomComment, Community, MyBlog

To unpublish Plugins :

Click on Extensions/Plugin Manager
Disable  Azrul Video Mambot  and Azrul.com System Mambot


I wish I could take credits for this fix. Give thanks to my good friend Chris Miller at the www.webtool.com.

Thanks, Henrik

rrosko

  • Guest
Re: Fatal error: Cannot redeclare class Services_JSON
September 03, 2009, 02:30:16 pm
Excellent,

This resolved my inability to import contacts as I was running into the same JSON errors.

Thanks Much!

DirkHartog

  • I’m new here
  • *
  • Posts: 16
  • Karma: 1
Re: Fatal error: Cannot redeclare class Services_JSON
October 11, 2009, 06:30:45 pm
I have had this error too. One of the sites I am developing has K2 handling the layout, so it isn't feasible to turn the conflicting component off.

So I searched for the string 'class Services_JSON' in the two components so I could see what differences they had and how they were implemented.

As far as I could see the code for the two Services_JSON classes were identical. The differences however were that the K2 version of the class Services_JSON was wrapped in;

Code: [Select]
if(!class_exists('Services_JSON')){
class Services_JSON
{...}
}
you can see this at line 127 of administrator/components/com_k2/lib/JSON.php

So I did the same in administrator/components/com_civicrm/civicrm/packages/Services/JSON.php by inserting
Code: [Select]
if(!class_exists('Services_JSON')){at line 115
and
Code: [Select]
}at line 779.
I also needed to insert
Code: [Select]
if(!class_exists('Services_JSON_Error')){at line 782 and
Code: [Select]
}at line 791 because I was getting a similar class-redeclaration error after when testing the first set of inserted code.

With this simple test of class-existence, I have managed to resolve this conflict. I hope something like this is in a future update of CiviCRM.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Fatal error: Cannot redeclare class Services_JSON
October 12, 2009, 10:34:19 am
You might consider submitting this as an issue with a patch on the issue tracker (link above).
Protect your investment in CiviCRM by  becoming a Member!

DirkHartog

  • I’m new here
  • *
  • Posts: 16
  • Karma: 1
Re: Fatal error: Cannot redeclare class Services_JSON
October 19, 2009, 11:23:25 pm
I've just submitted it as a bug an uploaded a corrected copy of JSON.php

I hope I have done all of the right bits - all it should take is for someone to put the file in the right place for the next version.

Cross your fingers.

matthewdnye

  • I’m new here
  • *
  • Posts: 28
  • Karma: 1
Re: Fatal error: Cannot redeclare class Services_JSON
December 04, 2009, 04:11:54 pm
So I am having this same problem because I have JomSocial. I saw this thread and downloaded the corrected JSON.php from here: http://issues.civicrm.org/jira/browse/CRM-5255, which says the issue has been resolved and tested.

I copied it up to my server but I am getting this:
Fatal error: Cannot redeclare class Services_JSON_Error in /home/viri50/public_html/rlcfl.org/administrator/components/com_civicrm/civicrm/packages/Services/JSON.php on line 783, which is basically where I started.

I don't know a thing about php, and don't know how to read/apply a diff file. Can anyone point me in the right direction here?

tajacobson

  • Guest
Re: Fatal error: Cannot redeclare class Services_JSON
January 12, 2010, 11:19:21 am
Encountered the same error.  After reading previous post re: K2, I uninstalled K2.  Problem gone.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Fatal error: Cannot redeclare class Services_JSON

This forum was archived on 2017-11-26.