Importing data from an XML file

Hello folks,

I’m having a first look at OpenGamma. I’d like to import a portfolio with a test trade – an OTC swap seems like it would be a fairly simple. As I don’t have Bloomberg data I’m using the examples-simulated configuration. Also, as the download version seems somewhat out of date, I’m trying the version from Github; 2.2.0-M10p07-SNAPSHOT looked like a good snapshot to try. I started out doing the maven steps described in the README.txt.

I’m running into issues. H’ere’s the script I’m using

IMPORT_TOOL=./target/scripts/portfolio-loader-tool.sh
OG_HOME=/home/cpm/src/OG-Platform/examples/examples-simulated/
OG_CONFIG=target/classes/toolcontext/toolcontext-examplessimulated.properties

cd $OG_HOME
$IMPORT_TOOL -c $OG_CONFIG -f $@

I get this stacktrace:

java.lang.ExceptionInInitializerError
	at com.opengamma.integration.tool.portfolio.xml.SchemaRegister.<clinit>(SchemaRegister.java:15)
	at com.opengamma.integration.tool.portfolio.PortfolioLoader.constructPortfolioReaders(PortfolioLoader.java:200)
	at com.opengamma.integration.tool.portfolio.PortfolioLoader.execute(PortfolioLoader.java:129)
	at com.opengamma.integration.tool.portfolio.PortfolioLoaderTool.doRun(PortfolioLoaderTool.java:66)
	at com.opengamma.component.tool.AbstractTool.run(AbstractTool.java:296)
	at com.opengamma.component.tool.AbstractTool.run(AbstractTool.java:250)
	at com.opengamma.component.tool.AbstractTool.initAndRun(AbstractTool.java:213)
	at com.opengamma.component.tool.AbstractTool.invokeAndTerminate(AbstractTool.java:150)
	at com.opengamma.component.tool.AbstractTool.invokeAndTerminate(AbstractTool.java:106)
	at com.opengamma.integration.tool.portfolio.PortfolioLoaderTool.main(PortfolioLoaderTool.java:47)
Caused by: java.lang.IllegalArgumentException: File file:/home/cmurphy/bigsrc/OG-Platform/examples/examples-simulated/target/server-dir/lib/og-integration-2.2.0-M10p07-SNAPSHOT.jar!/portfolio-schemas could not be found
	at com.opengamma.util.ArgumentChecker.isTrue(ArgumentChecker.java:54)
	at com.opengamma.integration.tool.portfolio.xml.FilesystemPortfolioSchemaLocator.<init>(FilesystemPortfolioSchemaLocator.java:30)
	at com.opengamma.integration.tool.portfolio.xml.PortfolioConversion.<clinit>(PortfolioConversion.java:46)
	... 10 more

Note in particular the “Caused by” line. There is a “portfolio-schemas” directory in the jar file, however it looks like the FilesystemPortfolioSchemaLocator does not handle jar files.

Hopefully it’s clear what I’m trying to do and how I’m trying to do it. Now for my question… Where am I going wrong? Is there some additional detail I should post to help figure it out?

Hello and Welcome. There is unfortunately a known problem with the example server beyond version 2.1. A change to handling of conventions caused the examples to break and we haven’t yet fixed this. We’d advise using v2.1 on master branch for a more reliable first look.

That said, your error is occurring because the file that it is trying to access is inside a jar file, and the java.io.File class cannot access that. I think you need to have the directory “portfolio-schemas” on your classpath as a regular filing system folder (and ahead of the jar files in the classpath order).

Thank you very much for your help. I’ve had some more time to work on this and made some more progress.

I checked out 2.1.8 in git and copied the examples-simulated subtree over to a new repo. I found a way to persuade Maven to add OG-Integration as a dependency and unpack the schema files to a target directory. I didn’t find a way to make Maven add that directory to a classpath so I wrote a small script to use instead of the provided scripts.

Now I’m working on generating portfolio files that conform to the schema. I’ll probably be back in due course with more questions.

Hi - I’ve hit the same issue, however I am using the master 2.1 branch. Do you have any suggestions on how exactly to sort this out as I am not a maven expert?..
Thanks a lot!

macbook-pro:server-dir ikasou$ pwd
/Users/ikasou/Documents/OG-Platform/examples/examples-bloomberg/target/server-dir
macbook-pro:server-dir ikasou$ ./scripts/load-portfolio.sh -f ~/Documents/OG-Platform/Portfolio.xml -n "Test Portfolio 4" -w -v
Write option specified, will persist to portfolio 'Test'
Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.opengamma.integration.tool.portfolio.xml.SchemaRegister.<clinit>(SchemaRegister.java:16)
	at com.opengamma.integration.tool.portfolio.PortfolioLoader.constructPortfolioReaders(PortfolioLoader.java:200)
	at com.opengamma.integration.tool.portfolio.PortfolioLoader.execute(PortfolioLoader.java:129)
	at com.opengamma.integration.tool.portfolio.PortfolioLoaderTool.doRun(PortfolioLoaderTool.java:76)
	at com.opengamma.component.tool.AbstractTool.run(AbstractTool.java:221)
	at com.opengamma.component.tool.AbstractTool.run(AbstractTool.java:175)
	at com.opengamma.component.tool.AbstractTool.initAndRun(AbstractTool.java:138)
	at com.opengamma.component.tool.AbstractTool.initAndRun(AbstractTool.java:97)
	at com.opengamma.integration.tool.portfolio.PortfolioLoaderTool.main(PortfolioLoaderTool.java:47)
Caused by: java.lang.IllegalArgumentException: File file:/Users/ikasou/Documents/OG-Platform/examples/examples-bloomberg/target/server-dir/lib/og-integration-2.1.0.jar!/portfolio-schemas could not be found
	at com.opengamma.util.ArgumentChecker.isTrue(ArgumentChecker.java:49)
	at com.opengamma.integration.tool.portfolio.xml.FilesystemPortfolioSchemaLocator.<init>(FilesystemPortfolioSchemaLocator.java:30)
	at com.opengamma.integration.tool.portfolio.xml.PortfolioConversion.<clinit>(PortfolioConversion.java:47)
	... 9 more