cancel
Showing results for 
Search instead for 
Did you mean: 

Does anyone know how to include configuration files with an SAP Library?

Former Member
0 Kudos

Hi all,

I am developing a Login Module (using JAAS) for SAP NetWeaver 2004s. I need to have a configuration file available to the Login Module Library (the project is a "J2EE server component", "library" in NW Developer Studio).

The configuration file needs to go in the class path (this is because a third party java jar will look for it there). So my question is, how can I either add this configuration file to the sda file (and get SAP to deploy it and put it or its directory into the class path), or tell SAP to add an extra directory to the class path? I know that for Enterprise Applications, there is a way to add extra entries into the class path, but I can't see a way to do it for a Library.

I tried unpacking the sda, adding my configuration file into the base directory with the other files from the sda and then repackaging it. But SAP just never copied my configuration file out to the disk. I then tried adding the configuration file as a jar file in server/provider.xml (even though it is not a jar), then I got an error from SAP J2EE engine saying that it could not unzip the config file.

Any other ideas? Thanks!

-- Katrina

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Katrina,

Just put the config, file i.e. myconfig.properties, in some folder under src/packages,

i.e. com/some/package of a JavaDC or J2EE DC project as Sergei said.

The file gets automatically copied in the corresponding bin or classes directory.

Build the sda lib or ear app which contains the JavaDC or J2EE DC via an assembly pp.

In some class of the JavaDC or J2EE DC project use code like:

InputStream input = ClassLoader.getSystemResourceAsStream("com/some/package/myconfig.properties");
Properties config = new Properties();
try {
	config.load(input);
} catch (IOException e) {
	
	e.printStackTrace();
}

The config file is now available in the Properties object.

Kind regards

Andreas

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

Refer these links,

https://wiki.sdn.sap.com/wiki/display/EP/PointersforTroubleshootingPortalRuntime+Errors

https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=56766

Regards,

Sunaina Reddy T

Former Member
0 Kudos

I tried sticking the properties file in two different jars from two different SAP libraries (it has the same values, I'm just trying to get all the classes in all the jars to be able to find it). This did not work either. Some of the classes read it, some could not. It doesn't help that each class calls a third party jar to read (and ultimately use the values in) the configuration file; so I can't see what is going on.

-- Katrina

Former Member
0 Kudos

Hi,

Unfortunately, the problem of only some of the classes being able to find the configuration file persists and I don't know how to fix it. I don't open the properties file myself, a third party library opens it (i.e. commons-logging from Apache).

I tried putting the properties file in a jar that has classes that are used by all the other classes. I also tried putting it in the commons-logging jar file itself. Neither of those works.

I have several libraries each containing several jar files and will soon have several J2EE applications (right now, i just have one J2EE application). Most of these jars use commons-logging - the ones that don't are third party libraries.

It seems to be random as to which classes are able to find the properties file, though, some are more likely than others. The most confusing part is that some classes are able to find the properties file and are in the same jar file with classes that can't find it.

My best guess as to what is going on is that SAP is not including jars in the class path for jars whose classes are already loaded. I suppose I could try to include the properties file in all of my jars, but that would be a pain. It also probably will not work if SAP loads all of the classes in the jar when a class in the jar is first required... But not sure. It is really confusing to me

Thanks anyways for the clues. Any more ideas?

-- Katrina

Former Member
0 Kudos

Hi all,

The properties file is opened by a third party jar (commons-logging from Apache), so I can't open it. However, I was able to put the properties file in the base directory of one of my jars so that my jar contained:


META-INF/MANIFEST.MF
com/mycompany/netweaver/lib/NetweaverLogger.class
commons-logging.properties

This seemed to work (i.e. commons-logging was able to find the properties file and thus the NetweaverLogger class was used as the Log implementation).

There still seems to be some issue where not all of the messages are getting logged. But it seems to be an issue with the order in which I deploy the libraries. But I am not sure yet.

Thanks to you both for your answers. They really helped!

-- Katrina

Former Member
0 Kudos

Hi Siarhei,

I don't quite understand what you mean... Do you mean that SAP sets the classpath to include some directories that I can dump the config file in? If so, do you know what they are? Or do you mean that I should put the config file in the jar file (with my other classes)? Putting it in the sda file (sort of like a war file, but for libraries) did not work. SAP either didn't copy it out to disk or gave an error because it could not de-archive it - see my previous post for details. Thanks for your reply though!

-- Katrina

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Katrin

Just put your configuration file near other Java classes in your library. I mean, put it within the existing library's class path, do not create a new class path. For example, put it in folder src/packages.

BR, Sergei