java.lang.ClassCastException: java.lang.Integer

Atlassian JIRA | Matthew Jensen [Atlassian] | 9 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    If use use the confluence XMLRPC interface with perl and try and set a {{parentId}} you get a {{ClassCastException}}: Perl script: {code} #!/opt/local/bin/perl use strict; use XMLRPC::Lite; my $username="admin"; my $password="admin"; my $baseurl="http://localhost:8080"; my $spaceKey="ds"; my $pageTitle="Confluence Overview"; my $confluence = XMLRPC::Lite->proxy("$baseurl/rpc/xmlrpc"); my $token = $confluence->call("confluence1.login", $username, $password)->result(); my $parentPage = $confluence->call("confluence1.getPage", $token, $spaceKey, $pageTitle)->result(); my $newpage = { space => $spaceKey, title => "New Child Page", content => "Content", parentId => $parentPage->{id}, }; my $createdpage = $confluence->call("confluence1.storePage", $token, $newpage)->result(); die "could not create child page" unless $createdpage; {code} The problem is because perl sees the {{parentId}} is an integer and actually passes it to confluence rpc as an integer. Confluence RPC is expecting a string and responds with this error: {noformat} java.lang.ClassCastException: java.lang.Integer at com.atlassian.confluence.rpc.xmlrpc.ConfluenceXmlRpcHandlerImpl.storePage(ConfluenceXmlRpcHandlerImpl.java:352) ... 50 more {noformat} Because the {{ConfluenceXmlRpcHandlerImpl}} expects a string in the {{storePage}} method: {code} public Hashtable storePage(String token, Hashtable pageStruct) throws RemoteException { // ... if (pageStruct.containsKey("parentId")) pageStruct.put("parentId", new Long((String) pageStruct.get("parentId"))); // ... } {code} Fix this by changing the {{storePage}} to handle both {{String}} and {{Integer}} input.

    Atlassian JIRA | 9 years ago | Matthew Jensen [Atlassian]
    java.lang.ClassCastException: java.lang.Integer
  2. 0

    If use use the confluence XMLRPC interface with perl and try and set a {{parentId}} you get a {{ClassCastException}}: Perl script: {code} #!/opt/local/bin/perl use strict; use XMLRPC::Lite; my $username="admin"; my $password="admin"; my $baseurl="http://localhost:8080"; my $spaceKey="ds"; my $pageTitle="Confluence Overview"; my $confluence = XMLRPC::Lite->proxy("$baseurl/rpc/xmlrpc"); my $token = $confluence->call("confluence1.login", $username, $password)->result(); my $parentPage = $confluence->call("confluence1.getPage", $token, $spaceKey, $pageTitle)->result(); my $newpage = { space => $spaceKey, title => "New Child Page", content => "Content", parentId => $parentPage->{id}, }; my $createdpage = $confluence->call("confluence1.storePage", $token, $newpage)->result(); die "could not create child page" unless $createdpage; {code} The problem is because perl sees the {{parentId}} is an integer and actually passes it to confluence rpc as an integer. Confluence RPC is expecting a string and responds with this error: {noformat} java.lang.ClassCastException: java.lang.Integer at com.atlassian.confluence.rpc.xmlrpc.ConfluenceXmlRpcHandlerImpl.storePage(ConfluenceXmlRpcHandlerImpl.java:352) ... 50 more {noformat} Because the {{ConfluenceXmlRpcHandlerImpl}} expects a string in the {{storePage}} method: {code} public Hashtable storePage(String token, Hashtable pageStruct) throws RemoteException { // ... if (pageStruct.containsKey("parentId")) pageStruct.put("parentId", new Long((String) pageStruct.get("parentId"))); // ... } {code} Fix this by changing the {{storePage}} to handle both {{String}} and {{Integer}} input.

    Atlassian JIRA | 9 years ago | Matthew Jensen [Atlassian]
    java.lang.ClassCastException: java.lang.Integer

    Root Cause Analysis

    1. java.lang.ClassCastException

      java.lang.Integer

      at com.atlassian.confluence.rpc.xmlrpc.ConfluenceXmlRpcHandlerImpl.storePage()
    2. com.atlassian.confluence
      ConfluenceXmlRpcHandlerImpl.storePage
      1. com.atlassian.confluence.rpc.xmlrpc.ConfluenceXmlRpcHandlerImpl.storePage(ConfluenceXmlRpcHandlerImpl.java:352)
      1 frame