cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
cdnadmin
Advisor
Advisor
This document was generated from CDN thread

Created by: Mark Applebee on 14-02-2013 11:59:08 AM
 I am new to Custom Java and trying to learn it by using the templates in the Cisco site.Whats the best way to write custom java classes.
Is it better to use callstudio or some IDE like Eclipse. I feel like IDEs are more helpful for writing and fixing syntax errors.
For example if I want to use Eclipse as an IDE, do I need to add any audium files to it before start using import commands in the java code?
 
 

Subject: RE: New Message from Mark Applebee in Customer Voice Portal (CVP) - General
Replied by: Hemal Mehta on 14-02-2013 12:33:26 PM
Call studio is based off eclipse and has the IDE  built in. So you can same the same studio to write java code.  You can use the java perspective from the studio.  You can write code in separate eclipse too as there are advanced eclipse version with added features and built in plugins.  Since you are just starting, I would just suggest using Studio as it has pretty much everything you need to write your java code.
Hemal

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, February 14, 2013 11:59 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Mark Applebee in Customer Voice Portal (CVP) - General Discussion - All Versions: Custom Java Classes with Call Studio

Mark Applebee has created a new message in the forum "General Discussion - All Versions": --------------------------------------------------------------  I am new to Custom Java and trying to learn it by using the templates in the Cisco site.Whats the best way to write custom java classes.
Is it better to use callstudio or some IDE like Eclipse. I feel like IDEs are more helpful for writing and fixing syntax errors.
For example if I want to use Eclipse as an IDE, do I need to add any audium files to it before start using import commands in the java code?


--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/11939383 or simply reply to this email.

Subject: RE: Custom Java Classes with Call Studio
Replied by: Janine Graves on 14-02-2013 12:38:49 PM
Personally, I feel it's easier to get started by using Studio/Eclipse because, as you say, it'll provide intellisense and suggest corrections. It usually does auto-compile and then to test your java class, you can simply copy the compiled java .class file into your Studio application and put it under appname/deploy/java/application/classes. If the code creates a new element (or say it smart), then close the Studio application from the workspace and re-open it by double-clicking app.callflow and the new element will appear under Elements/Local Elements.
 
To create the Java project, select New/Project/JavaProject/ Enter a name for your Java project and click 'Next'.
Then in the wizard, click on the Libraries tab and click 'Add External Jars' - you'll need to select  'framework.jar', 'servlet.jar' (was called servlet2.3.jar until cvp 9), and if you're extending existing studio elements you'll need 'elements.jar' - do a Search ahead of time, these files are all in the Studio/eclipse/plugins folder somewhere.
Then copy some of the Cisco examples into your Java project. Eclipse will compile. You can then copy the compiled class files into your Studio application and test them (as described above).
 
 
 
 
 
 
 
Mark Applebee:
 I am new to Custom Java and trying to learn it by using the templates in the Cisco site.Whats the best way to write custom java classes.
Is it better to use callstudio or some IDE like Eclipse. I feel like IDEs are more helpful for writing and fixing syntax errors.
For example if I want to use Eclipse as an IDE, do I need to add any audium files to it before start using import commands in the java code?
 
 


Subject: RE: Custom Java Classes with Call Studio
Replied by: Mark Applebee on 15-02-2013 08:42:37 AM
Thanks Janine,this is really helpful!

Subject: RE: Custom Java Classes with Call Studio
Replied by: Mark Applebee on 28-02-2013 12:00:21 PM
Janine..as you descrbied above, I managed to create a class file using one of the template in the developer forum. Then I copied the class file into appname/deploy/java/application/classe folder and restarted the app as you mentioned. But the file is not appearing in local elements. I am using call studio version 8.5 and JDK is 1.7. Do I need to use JDK 1.6 or is it some other issue?

Subject: RE: New Message from Mark Applebee in Customer Voice Portal (CVP) - General
Replied by: Asher Schweigart on 28-02-2013 12:27:03 PM
Do you have anything showing in your Call Studio Error Log? If the element is failing to load, an error or warning should be displayed there.

Subject: RE: New Message from Asher Schweigart in Customer Voice Portal (CVP) - Gene
Replied by: GEOFFREY THOMPSON on 28-02-2013 12:41:19 PM
>>>>Do you have anything showing in your Call Studio Error Log? If the element is failing to load, an error or warning should be displayed there.

In my experience, a much better place to look is in the Tomcat logs.

Regards,
Geoff
.

Subject: RE: New Message from Mark Applebee in Customer Voice Portal (CVP) - General
Replied by: Hemal Mehta on 28-02-2013 12:46:19 PM
Assuming the class is compiled correctly and there are no errors, I would bundle it into  jar and deploy it under the lib dir.   JDK is not an issue.
Hemal

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, February 28, 2013 12:00 PM
To: cdicuser@developer.cisco.com
Subject: New Message from Mark Applebee in Customer Voice Portal (CVP) - General Discussion - All Versions: RE: Custom Java Classes with Call Studio

Mark Applebee has created a new message in the forum "General Discussion - All Versions": -------------------------------------------------------------- Janine..as you descrbied above, I managed to create a class file using one of the template in the developer forum. Then I copied the class file into appname/deploy/java/application/classe folder and restarted the app as you mentioned. But the file is not appearing in local elements. I am using call studio version 8.5 and JDK is 1.7. Do I need to use JDK 1.6 or is it some other issue?
--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/12485582 or simply reply to this email.

Subject: RE: New Message from Mark Applebee in Customer Voice Portal (CVP) - General
Replied by: Hemal Mehta on 28-02-2013 12:48:19 PM
Sorry , not sure if JDK 1.7 is  supported with CVP Studio 8.5. Confirming that.  Use 1.6 and compile with that.
Hemal

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, February 28, 2013 12:00 PM
To: cdicuser@developer.cisco.com
Subject: New Message from Mark Applebee in Customer Voice Portal (CVP) - General Discussion - All Versions: RE: Custom Java Classes with Call Studio

Mark Applebee has created a new message in the forum "General Discussion - All Versions": -------------------------------------------------------------- Janine..as you descrbied above, I managed to create a class file using one of the template in the developer forum. Then I copied the class file into appname/deploy/java/application/classe folder and restarted the app as you mentioned. But the file is not appearing in local elements. I am using call studio version 8.5 and JDK is 1.7. Do I need to use JDK 1.6 or is it some other issue?
--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/12485582 or simply reply to this email.

Subject: RE: New Message from Mark Applebee in Customer Voice Portal (CVP) - General
Replied by: Hemal Mehta on 28-02-2013 12:54:19 PM
The JDK compliance on 8.5 extends to only 6 only.  I would therefore first compile with 1.6 and make sure that there are no errors.
Hemal

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, February 28, 2013 12:00 PM
To: cdicuser@developer.cisco.com
Subject: New Message from Mark Applebee in Customer Voice Portal (CVP) - General Discussion - All Versions: RE: Custom Java Classes with Call Studio

Mark Applebee has created a new message in the forum "General Discussion - All Versions": -------------------------------------------------------------- Janine..as you descrbied above, I managed to create a class file using one of the template in the developer forum. Then I copied the class file into appname/deploy/java/application/classe folder and restarted the app as you mentioned. But the file is not appearing in local elements. I am using call studio version 8.5 and JDK is 1.7. Do I need to use JDK 1.6 or is it some other issue?
--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/12485582 or simply reply to this email.

Subject: Re: New Message from Mark Applebee in Customer Voice Portal (CVP) - General
Replied by: Janine Graves on 28-02-2013 01:19:19 PM
Once you close the app out of the Studio workspace, and then
double-click app.callflow, the element should show up under Local
Elements. If it doesn't then there's usually an array indexing problem
in your java code.

In Studio, look under Window > Show View > Call Studio Error Log.  This
will display at the bottom of the Studio window, near the Studio
Problems tab. You should select the error, and right-click, select
Properties. This will pop up a box and give you an error message and
Java stack trace.

Usually the error is in the method named GetSettings or GetElementData
or GetExitStates. Each of these has an array. You must specify the size
of the array. And then you MUST initialize each row of the array.

If you either fail to initialize one of the array rows, or if you
initialize a row of the array but the array dimension is smaller than
that (indexOutOfBounds) then the element will fail to show up in the
Studio pane.

Feel free to post your java file online and I'll fix it for you.

Subject: RE: Custom Java Classes with Call Studio
Replied by: Mark Applebee on 28-02-2013 02:22:20 PM
This is my first Java code. I was trying to use a template posted by you. Here it is:
 
import com.audium.server.AudiumException;
import com.audium.server.voiceElement.ActionElementBase;
import com.audium.server.session.ActionElementData;
 
public class TEST1 extends ActionElementBase
{
public void doAction(String name, ActionElementData data) throws AudiumException
{
String callid=(String)data.getSessionData("callid");
data.addToLog("callid",callid);
data.setElementData("LANG","ENG");
}
 
}
 
Please let me know whether I am doing it right.

Subject: Re: New Message from Mark Applebee in Customer Voice Portal (CVP) - General
Replied by: Janine Graves on 28-02-2013 03:03:19 PM
This is a 'Standard Action' - it doesn't show up as a new element in
Studio.

To use this code, you drag in the Studio element named 'Action'. You can
then name the element in Studio if you like.

In the right side, configuration pane, enter the Java class name
(without a file extension) -  'TEST1'  (omit the quotes).

That's all.

Janine

Subject: RE: Custom Java Classes with Call Studio
Replied by: Birendra Hansda on 28-02-2013 11:19:28 PM
Mark Applebee:
This is my first Java code. I was trying to use a template posted by you. Here it is:
 
import com.audium.server.AudiumException;
import com.audium.server.voiceElement.ActionElementBase;
import com.audium.server.session.ActionElementData;
 
public class TEST1 extends ActionElementBase
{
public void doAction(String name, ActionElementData data) throws AudiumException
{
String callid=(String)data.getSessionData("callid");
data.addToLog("callid",callid);
data.setElementData("LANG","ENG");
}
 
}
 
Please let me know whether I am doing it right.

 
Hi Mark
For the audium element to show up in the studio, you will have to implement the ElementInterface in your class.  Apart from CVP programming guide, you will also need the javadoc for CVP API. You can download some sample custom elements and the javadocs from http://developer.cisco.com/web/cvp/home 
Regards
Birendra Hansda
 

Subject: RE: Re: New Message from Mark Applebee in Customer Voice Portal (CVP) - Gen
Replied by: Tom Shaw on 15-10-2013 02:39:48 PM
Janine Graves:
Once you close the app out of the Studio workspace, and then
double-click app.callflow, the element should show up under Local
Elements. If it doesn't then there's usually an array indexing problem
in your java code.

In Studio, look under Window > Show View > Call Studio Error Log.  This
will display at the bottom of the Studio window, near the Studio
Problems tab. You should select the error, and right-click, select
Properties. This will pop up a box and give you an error message and
Java stack trace.

Usually the error is in the method named GetSettings or GetElementData
or GetExitStates. Each of these has an array. You must specify the size
of the array. And then you MUST initialize each row of the array.

If you either fail to initialize one of the array rows, or if you
initialize a row of the array but the array dimension is smaller than
that (indexOutOfBounds) then the element will fail to show up in the
Studio pane.

Feel free to post your java file online and I'll fix it for you.

Janine,
We are trying to create a custom element that will call a REST web service and return the results.  We have created the custom element that shows up in builder if we don't have the web service java included but it fails when the web service java is added.  To try to troubleshoot, we created a "scriptlet" with just the web service code but it fails with an error that seems to relate to version.  The code and jar files we used are below...do you have any suggestions?  We have tried to confirm versions are compatible with the jar files we are using but we still receive the error.  Is there a better/simpler way to do this web service post?  Thank you for your assistance!

Error:
java.lang.UnsupportedClassVersionError: Bad version number in .class fileat java.lang.ClassLoader.defineClass1(Native Method)at java.lang.ClassLoader.defineClass(ClassLoader.java:620)at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)at java.net.URLClassLoader.access$100(URLClassLoader.java:56)at java.net.URLClassLoader$1.run(URLClassLoader.java:195)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:188)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)at java.lang.ClassLoader.loadClass(ClassLoader.java:251)at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)Exception in thread "main" 

Java version:
1.5

Jar files:
 framework.jar
jersey-bundle-1.5.jar
json-simple-1.1.jar
jsr311-api-0.11.jar
servlet2.3.jar
JRE System Library

import java.net.URI;
import javax.ws.rs.core.MediaType;import javax.ws.rs.core.UriBuilder;
import org.json.simple.JSONObject;import org.json.simple.parser.JSONParser;
import com.sun.jersey.api.client.Client;import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.representation.Form;

public class ERCTest {     
public static void main(String[] args) {                 
//String json = "{\"status\":203,\"success\":0,\"tokenID\":null,\"message\":\"APP_LOGIN_FAIL\",\"invoice_balance\":0.0,\"account_id\":-1}";     
JSONParser jsonParser = new JSONParser();     
try {             
ClientConfig cnfg1 = new DefaultClientConfig();        
Client client = Client.create(cnfg1);        
ClientResponse response_rest;        
WebResource service_rest = client.resource(getBaseURI());        
Form form = new Form();        
form.add("invoice_number","1234567");        
form.add("trx_number", "789012");        
form.add("timestamp", "1321700334");        
response_rest = service_rest.path("invoice").path("getInvoice").type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class, form); 
String json = response_rest.getEntity(String.class);              
JSONObject jsonObject = (JSONObject) jsonParser.parse(json);
String status = ((Long) jsonObject.get("status")).toString();                               
String success = ((Long) jsonObject.get("success")).toString();                               
String tokenID = (String) jsonObject.get("tokenID");                               
String message = (String) jsonObject.get("message");                               
String invoice_balance = ((Double) jsonObject.get("invoice_balance")).toString();                               
String account_id = ((Long) jsonObject.get("account_id")).toString();                                                           
System.out.println("XML: " + json);                                                                
System.out.println("Status: "+ status);                               
System.out.println("success: "+ success);                               
System.out.println("tokenID: "+ tokenID);                               
System.out.println("message: "+ message);                               
System.out.println("invoice_balance: "+ invoice_balance);                               
System.out.println("account_id: "+ account_id);     
}     
catch (Exception e) {                 
e.printStackTrace();     
}               
}                           
private static URI getBaseURI() {            
return UriBuilder.fromUri("http://10.10.100.211:9080/ivr/api").build();            
}
}    

Subject: Re: New Message from Tom Shaw in Customer Voice Portal (CVP) - General Disc
Replied by: Janine Graves on 15-10-2013 03:06:37 PM
What version of Studio/Vxml Server are you using? CVP9 requires Java Version 1.6 On 10/15/2013 3:39 PM, Cisco Developer Community Forums wrote: Tom Shaw has created a new message in the forum "General Discussion - All Versions": -------------------------------------------------------------- Janine Graves: Once you close the app out of the Studio workspace, and then double-click app.callflow, the element should show up under Local Elements. If it doesn't then there's usually an array indexing problem in your java code. In Studio, look under Window > Show View > Call Studio Error Log. This will display at the bottom of the Studio window, near the Studio Problems tab. You should select the error, and right-click, select Properties. This will pop up a box and give you an error message and Java stack trace. Usually the error is in the method named GetSettings or GetElementData or GetExitStates. Each of these has an array. You must specify the size of the array. And then you MUST initialize each row of the array. If you either fail to initialize one of the array rows, or if you initialize a row of the array but the array dimension is smaller than that (indexOutOfBounds) then the element will fail to show up in the Studio pane. Feel free to post your java file online and I'll fix it for you. Janine, We are trying to create a custom element that will call a REST web service and return the results.  We have created the custom element that shows up in builder if we don't have the web service java included but it fails when the web service java is added.  To try to troubleshoot, we created a "scriptlet" with just the web service code but it fails with an error that seems to relate to version.  The code and jar files we used are below...do you have any suggestions?  We have tried to confirm versions are compatible with the jar files we are using but we still receive the error.  Is there a better/simpler way to do this web service post?  Thank you for your assistance! Error: java.lang.UnsupportedClassVersionError: Bad version number in .class fileat java.lang.ClassLoader.defineClass1(Native Method)at java.lang.ClassLoader.defineClass(ClassLoader.java:620)at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)at java.net.URLClassLoader.access$100(URLClassLoader.java:56)at java.net.URLClassLoader$1.run(URLClassLoader.java:195)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:188)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)at java.lang.ClassLoader.loadClass(ClassLoader.java:251)at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)Exception in thread "main"  Java version: 1.5 Jar files:  framework.jar jersey-bundle-1.5.jar json-simple-1.1.jar jsr311-api-0.11.jar servlet2.3.jar JRE System Library import java.net.URI; import javax.ws.rs.core.MediaType;import javax.ws.rs.core.UriBuilder; import org.json.simple.JSONObject;import org.json.simple.parser.JSONParser; import com.sun.jersey.api.client.Client;import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.representation.Form; public class ERCTest {      public static void main(String[] args) {                  //String json = "{\"status\":203,\"success\":0,\"tokenID\":null,\"message\":\"APP_LOGIN_FAIL\",\"invoice_balance\":0.0,\"account_id\":-1}";      JSONParser jsonParser = new JSONParser();      try {             ClientConfig cnfg1 = new DefaultClientConfig();         Client client = Client.create(cnfg1);         ClientResponse response_rest;         WebResource service_rest = client.resource(getBaseURI());         Form form = new Form();         form.add("invoice_number","1234567");         form.add("trx_number", "789012");         form.add("timestamp", "1321700334");         response_rest = service_rest.path("invoice").path("getInvoice").type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class, form);  String json = response_rest.getEntity(String.class);               JSONObject jsonObject = (JSONObject) jsonParser.parse(json); String status = ((Long) jsonObject.get("status")).toString();                                String success = ((Long) jsonObject.get("success")).toString();                                String tokenID = (String) jsonObject.get("tokenID");                                String message = (String) jsonObject.get("message");                                String invoice_balance = ((Double) jsonObject.get("invoice_balance")).toString();                                String account_id = ((Long) jsonObject.get("account_id")).toString();                                                            System.out.println("XML: " + json);                                                                 System.out.println("Status: "+ status);                                System.out.println("success: "+ success);                                System.out.println("tokenID: "+ tokenID);                                System.out.println("message: "+ message);                                System.out.println("invoice_balance: "+ invoice_balance);                                System.out.println("account_id: "+ account_id);      }      catch (Exception e) {                  e.printStackTrace();      }                }                            private static URI getBaseURI() {             return UriBuilder.fromUri("http://10.10.100.211:9080/ivr/api").build();             } }     -- To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/20245622 or simply reply to this email. -- Janine Graves

Subject: RE: Re: New Message from Tom Shaw in Customer Voice Portal (CVP) - General
Replied by: Tom Shaw on 15-10-2013 03:14:52 PM
Call studio 8.0 and when we check the java version, it is 1.5.

Subject: RE: Re: New Message from Tom Shaw in Customer Voice Portal (CVP) - General
Replied by: Janine Graves on 15-10-2013 03:23:55 PM
Sorry that's beyond my knowledge. Perhaps someone else can help out here.

Subject: RE: Re: New Message from Tom Shaw in Customer Voice Portal (CVP) - General
Replied by: Janine Graves on 15-10-2013 03:26:47 PM
Which directories did you install your jar files into:
jersey-bundle-1.5.jar
json-simple-1.1.jar
jsr311-api-0.11.jar

Subject: RE: Re: New Message from Tom Shaw in Customer Voice Portal (CVP) - General
Replied by: Tom Shaw on 15-10-2013 03:34:06 PM
C:\Cisco\CallStudio\eclipse\plugins\com.audiumcorp.studio.library.framework_8.0.1

Once we added these external jars, it resolve the errors with the imports but even though the project does not have any errors or warnings, it still gives us the UnsupportedClassVersionError.

Thanks again for your help, Janine.


Subject: RE: Re: New Message from Tom Shaw in Customer Voice Portal (CVP) - General
Replied by: Edward Umansky on 15-10-2013 03:40:21 PM
Jersey 1.5 requires Java 6 by default, so it won't work in CVP versions prior to 9.0, which introduced Java 6 support. You can try rolling back to Jersey 1.2, which supports Java 5, or try recompiling the Jersey source code in Java 5. You should also confirm that the other libraries support Java 5. Alternatively you can skip Jersey altogether and do your REST lookup with basic HTTP client code.

Subject: RE: Re: New Message from Tom Shaw in Customer Voice Portal (CVP) - General
Replied by: Tom Shaw on 15-10-2013 05:47:24 PM
Thanks Ed!  That solved the unsupported version error but now the element won't load.  We get the below error in the audium.log after restarting CallStudio:

!MESSAGE An error was encountered while attempting to load the element "MyCustomActionElement". The exception was: java.lang.NoClassDefFoundError: com/sun/jersey/api/client/config/ClientConfig!STACK 0java.lang.NoClassDefFoundError: com/sun/jersey/api/client/config/ClientConfig

In googling, we have found several suggested jar files but none of them have solved the issue.  

We can run the java and get results back in the console, but when we implement the code in the custom element, we receive the above error.  

Has anyone seen this error or have any suggestions?

Subject: RE: Custom Java Classes with Call Studio
Replied by: Edward Umansky on 17-10-2013 12:55:39 AM
That class should be in the Jersey jar files. Open up the jar files and see if it's in there. If not something is wrong with the library you downloaded, or you are missing a required Jersey library. If it's there, make sure it's loaded where CVP can see it (in the project lib folder or the common lib folder) and reopen the script or restart Call Studio as necessary to make sure it's loaded.

Subject: RE: Re: New Message from Mark Applebee in Customer Voice Portal (CVP) - Gen
Replied by: Tom Shaw on 24-10-2013 02:17:24 PM
Janine Graves:
Once you close the app out of the Studio workspace, and then
double-click app.callflow, the element should show up under Local
Elements. If it doesn't then there's usually an array indexing problem
in your java code.

In Studio, look under Window > Show View > Call Studio Error Log.  This
will display at the bottom of the Studio window, near the Studio
Problems tab. You should select the error, and right-click, select
Properties. This will pop up a box and give you an error message and
Java stack trace.

Usually the error is in the method named GetSettings or GetElementData
or GetExitStates. Each of these has an array. You must specify the size
of the array. And then you MUST initialize each row of the array.

If you either fail to initialize one of the array rows, or if you
initialize a row of the array but the array dimension is smaller than
that (indexOutOfBounds) then the element will fail to show up in the
Studio pane.

Feel free to post your java file online and I'll fix it for you.

Janine,
We are trying to create a custom element that will call a REST web service and return the results.  We have created the custom element that shows up in builder if we don't have the web service java included but it fails when the web service java is added.  To try to troubleshoot, we created a "scriptlet" with just the web service code but it fails with an error that seems to relate to version.  The code and jar files we used are below...do you have any suggestions?  We have tried to confirm versions are compatible with the jar files we are using but we still receive the error.  Is there a better/simpler way to do this web service post?  Thank you for your assistance!

Error:
java.lang.UnsupportedClassVersionError: Bad version number in .class fileat java.lang.ClassLoader.defineClass1(Native Method)at java.lang.ClassLoader.defineClass(ClassLoader.java:620)at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)at java.net.URLClassLoader.access$100(URLClassLoader.java:56)at java.net.URLClassLoader$1.run(URLClassLoader.java:195)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:188)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)at java.lang.ClassLoader.loadClass(ClassLoader.java:251)at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)Exception in thread "main" 

Java version:
1.5

Jar files:
 framework.jar
jersey-bundle-1.5.jar
json-simple-1.1.jar
jsr311-api-0.11.jar
servlet2.3.jar
JRE System Library

import java.net.URI;
import javax.ws.rs.core.MediaType;import javax.ws.rs.core.UriBuilder;
import org.json.simple.JSONObject;import org.json.simple.parser.JSONParser;
import com.sun.jersey.api.client.Client;import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.representation.Form;

public class ERCTest {     
public static void main(String[] args) {                 
//String json = "{\"status\":203,\"success\":0,\"tokenID\":null,\"message\":\"APP_LOGIN_FAIL\",\"invoice_balance\":0.0,\"account_id\":-1}";     
JSONParser jsonParser = new JSONParser();     
try {             
ClientConfig cnfg1 = new DefaultClientConfig();        
Client client = Client.create(cnfg1);        
ClientResponse response_rest;        
WebResource service_rest = client.resource(getBaseURI());        
Form form = new Form();        
form.add("invoice_number","1234567");        
form.add("trx_number", "789012");        
form.add("timestamp", "1321700334");        
response_rest = service_rest.path("invoice").path("getInvoice").type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class, form); 
String json = response_rest.getEntity(String.class);              
JSONObject jsonObject = (JSONObject) jsonParser.parse(json);
String status = ((Long) jsonObject.get("status")).toString();                               
String success = ((Long) jsonObject.get("success")).toString();                               
String tokenID = (String) jsonObject.get("tokenID");                               
String message = (String) jsonObject.get("message");                               
String invoice_balance = ((Double) jsonObject.get("invoice_balance")).toString();                               
String account_id = ((Long) jsonObject.get("account_id")).toString();                                                           
System.out.println("XML: " + json);                                                                
System.out.println("Status: "+ status);                               
System.out.println("success: "+ success);                               
System.out.println("tokenID: "+ tokenID);                               
System.out.println("message: "+ message);                               
System.out.println("invoice_balance: "+ invoice_balance);                               
System.out.println("account_id: "+ account_id);     
}     
catch (Exception e) {                 
e.printStackTrace();     
}               
}                           
private static URI getBaseURI() {            
return UriBuilder.fromUri("http://10.10.100.211:9080/ivr/api").build();            
}
}    

Subject: RE: Re: New Message from Mark Applebee in Customer Voice Portal (CVP) - Gen
Replied by: Edward Umansky on 24-10-2013 02:37:34 PM
You can't run jersey 1.5 in CVP 8x, Jersey requires Java 6 which is only supported as of CVP 9. The simpler method would be to ditch Jersey and just use the standard Java API (http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/) to make your HTTP requests. You can still use a JSON parser to parse the results; that library should be easier to get working than a full web service library.
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links