java.lang.ClassCastException: java.lang.Integer

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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.
    via by Matthew Jensen [Atlassian],
  • 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.
    via by Matthew Jensen [Atlassian],
    • java.lang.ClassCastException: java.lang.Integer at com.atlassian.confluence.rpc.xmlrpc.ConfluenceXmlRpcHandlerImpl.storePage(ConfluenceXmlRpcHandlerImpl.java:352)
    No Bugmate found.