cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing files in library from adapter module

Former Member
0 Kudos

Hello everyone!

We are using XI with Netweaver 2004 and have programmed our own adapter for message transformations.

After the transformation we want to validate the generated XML file with the validator from SAP XML Toolkit.


Validator validator = new Validator();
String[] xsdFileNames = new String[]{
     "???/de/nordakademie/ext/gen/" + ediStandard + "/" + parser.getEdiVersion().toLowerCase() + "/xsd/" + parser.getEdiMessageName().toLowerCase() + ".xsd",
     "???/de/nordakademie/ext/gen/" + ediStandard + "/" + parser.getEdiVersion().toLowerCase() + "/xsd/segments.xsd"
};
boolean isValid = validator.validate(byteIn, xsdFileNames);

But we don't know how to address the necessary xsdFiles for the transformation. At the moment we get thw following error: [location : null] ERROR : E:\...\de\nordakademie\ext\gen\edifact\d96a\xsd\orders.xsd (The system cannot find the path specified)

The xsd files are located in the following package: de.nordakademie.ext.gen.edifact.d96a.xsd.

This package is part of a jar file which was deployed to the J2EE-Engine in a Libary.

But how can we access these files in the code example above?

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Did you assign a reference to the library in the deployment descriptor of your adapter?

Former Member
0 Kudos

Yes the references are working. We are using Java classes from that package successfully.

The only problem is to locate the xsd files.

stefan_grube
Active Contributor
0 Kudos

Now I see the point:

ERROR : E:\...\de\nordakademie

The Java program assumes that you want to read from file system.

You need to change the Java program to make it read from library.

Stefan

Former Member
0 Kudos

Yes that's my problem. I don't know how.

Is it possible to adress the package and file over the ClassLoader?

Answers (3)

Answers (3)

Former Member
0 Kudos

This problem was due to a deployment problem on our server....

Edited by: Stefan Tanck on Apr 30, 2008 5:44 PM

Former Member
0 Kudos

Unfortunately this solution only worked until I deployed the library containing the xsds another time.

Now I'm getting this error:

SchemaException: [location : null] ERROR : JAR entry de/nordakademie/ext/gen/abc.xsd not found in E:\usr\sap\CX1\DVEBMGS00\j2ee\cluster\server0\bin\ext\de.nordakademie~MyLibrary\MyJar.jar

But when I take a look on the server the determined directory and jar file exists and contains exactly that folder structure and xsd files. What's wrong?

henrique_pinto
Active Contributor
0 Kudos

Use standard validation from SAX/DOM parsers:

http://help.sap.com/saphelp_nw70/helpdata/EN/c4/e1343e8c7f6329e10000000a114084/frameset.htm

For how to access the .xsds inside .jar file, check Franz Forsthofer's reply in this thread:

If your .xsds refer to other .xsds (in import or include statements), check my last message on the same topic.

Regards,

Henrique.

Former Member
0 Kudos

Hey!

Thanks for your help. I ha´ve now solved the problem. The following code works:

String xsdMessagePath = "de/nordakademie/ext/gen/.../abc.xsd";		
String xsdSegmentsPath = "de/nordakademie/ext/gen/.../xyz.xsd";

Validator validator = new Validator();
						
URL xsdMessageUrl = getClass().getClassLoader().getResource(xsdMessagePath);
URL xsdSegmentsUrl = getClass().getClassLoader().getResource(xsdSegmentsPath);							
String[] xsdFileNames = new String[]{
	xsdMessageUrl.toString(),
	xsdSegmentsUrl.toString()
};
boolean isValid = validator.validate(byteIn, xsdFileNames);