weblogic 12c not loading application properties file - weblogic12c

We're moving from OC4J to WebLogic and have some properties files that reside outside of the EAR file. In OC4J we simply put them in the "applib" directory. Everything I've read so far about WebLogic says to put the file in the user_projects\domains\mydomain directory, but that's not working.
Is there another directory that I need to use or how do I force WebLogic to look in user_projects\domains\mydomain for the application properties files?

Maybe not the best solution, but at least a workaround. I edited wls12130\oracle_common\common\bin\commEnv.cmd and appended the domain home dir to this line:
set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%PROFILE_CLASSPATH%;%ANT_CONTRIB%\lib\ant-contrib.jar;%CAM_NODEMANAGER_JAR_PATH%;%DOMAIN_HOME%

Related

how to download war files from wildfly 8

Wildfly 8:
Where are the deployed war files located on the server file system?
How do I download them? I tried using the JBoss CLI as well as the Web Interface.
Found the war files to be located here. In this directory I found several subdirectories. The war files were all named content and did not have an extension. I could figure out what they were based on file size and timestamp.
wildfly location\standalone\data\content
You want the files 'after' they have been deployed? This generally isn't a good idea as it isn't guaranteed to be exactly the same as the source archive.
The standard location for the deployment archives is ./standalone/deployments/ although this can be changed in the configuration.
After an archive is deployed you can see the exact location of there the deployed archive came from in the configuration, it will be written to the bottom of the xml file.
There is a download button to download the .war
in the management console localhost:9990
click the view button near your war
on top you will find a download icon
I found it in the %WILDFLY_HOME%\standalone\temp\ directory. If it is not present there then you can perform a search in all the subdirectories of the wildfly.

Problems with relative paths in Eclipse.

I am trying to use relative paths in a Dynamic Web Project in Eclipse. I am NOT using them in the Servlet, but in another class that is called by the Servlet. The file I am trying to access to is a property file located in
MyProject/WebContent/WEB-INF/propertyFile.properties
I have tried almost every relative path...
WebContent/WEB-INF/propertyFile.properties
/WebContent/WEB-INF/propertyFile.properties
./WebContent/WEB-INF/propertyFile.properties
MyProject/WebContent/WEB-INF/propertyFile.properties
/MyProject/WebContent/WEB-INF/propertyFile.properties
WEB-INF/propertyFile.properties
/WEB-INF/propertyFile.properties
./WEB-INF/propertyFile.properties
...and so on...what can I do?
Thanks in advance!
You nee to understand that file IO read files, from the filesystem, and relative to the directory from which the JVM (i.e. your web container) is started.
Remember that, once your app is deployed to production, there won't be any MyProject or WebContent folder. That's what exists on your development machine. The only thing that will exist in production is the war file deployed in the application server.
What you actually want is to load a resource, located in the deployed web application (i.e. which is inside your war file).
To do that, you must use ServletContext.getResourceAsStream():
InputStream in = servletContext.getResourceAsStream("/WEB-INF/propertyFile.properties");

Expand WAR or EAR files in jBoss AS 7

I'm deploying a WebService project into a jBoss AS7, and everything goes OK except that jBoss doesn't expand my WAR or EAR file.
Already tried copying the file to the "jboss-as-7.1.0.Final\standalone\deployments" folder and using the WebConsole, but in both cases the result was the same.
If I deploy from within Eclipse everything runs OK.
I need it to expand my file because in the application initialization I scan the class
directories looking for the correct class to instantiate using reflection.
EDIT : Don't know if this a particular situation with jBoss AS 7 or with the jBoss AS family, because I already used WebSphere and jBoss Web and both of them expanded the files.
EDIT2 : Added a System.out with the execution path
MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath();
and it returns the following path
C:\jboss-as-7.1.0.Final\bin\content\ServerEAR.ear\Server.war\WEB-INF\classes
witch doesn't exist. So I did a search for the class name and fount it at
C:\jboss-as-7.1.0.Final\standalone\tmp\vfs\deployment5a9e98d5c43716c3\Server.war-e31a657d2bc3bd0f\WEB-INF\classes\r30
Isn't it possible to force JBoss to extract the files to the deployment folder? Or how can I get the previous path at run time.
Had forgotten about this question, so this is the way that I solved it:
public String getRealFilePath(String aFilePath) throws Exception
{
org.jboss.vfs.VirtualFile vFile = org.jboss.vfs.VFS.getChild(aFilePath);
URI fileNameDecodedTmp = org.jboss.vfs.VFSUtils.getPhysicalURI(vFile);
path = fileNameDecodedTmp.getPath();
System.out.println(path);
return path;
}
So at runtime I just need to call getRealFilePath() with the original question values, and problem solved ;)
I believe that you cannot force Jboss7 to auto expand the war file when deploying.
You can, however, copy the already expanded war and you shouldn't have any problems.
Actually, if you look closely at the Eclipse deployment, you will notice that it copies the whole directory to the deployment directory, not the war file itself.
Why do you need to deploy exploded, by the way? If you need to access and read some files as resources, you can have a look at classpath resources
Please check you classpath setting. I faced the same problem recently, and solved it by added system environment variables:
CLASSPATH=.;
C:\Program Files\Java\jdk1.6.0_10\lib;
C:\Program Files\Java\jdk1.6.0_10\lib\tools.jar;
C:\Program Files\Java\jdk1.6.0_10\lib\dt.jar; `

Adding server-specific options to an Eclipse-managed Tomcat instance (in server.xml)

How can I make sure that the server.xml which Eclipse produces for every separate project that relies on Tomcat, will always contain a specific option, which I added manually?
I'd like to add a bunch of <Context> mappings to the server.xml file. I tried doing that in the server.xml in the main tomcat dir - didn't work.
Then I saw that Eclipse builds a temporary folder for every project that uses Tomcat. This folder also containes this server.xml file. I edited it, and voila, it worked. However, soon after that the same file got updated by Eclipse, with the original data that it contained.
It is not very efficient to manually copy and paste the code every time before I run/restart tomcat. I hope there is a more permanent way.
Let's assume you have configured tomcat 5.5
If you have configured your tomcat server in eclipse using all default options, you want to edit the server.xml located at WORKSPACE_LOC\Servers\Tomcat v5.5 Server at localhost-config\server.xml

Deploy war file with modifiable properties files

I am building a web service and am packaging it into a war file for deployment. Right now all of my config files (.properties and .xml) are being packaged into my .war file. This isn't going to work as some of these files will need to be modified for each individual installation. I know that some servlet containers will leave the .war files intact which would mean the config files would never be easily modified. My question is this: what is the best practice for deploying a .war file with these external config files? I'm thinking that the config files will need to be shipped separate from the .war file and placed into a directory that is in the classpath. Is there a default directory setup like this in Tomcat that these files can just be dropped into and my web service will be able to find without much trouble?
Maybe I shouldn't be using a war file for this setup? Maybe I should just be providing a zip file (with the same contents as the war file) and the deployment will simply be to extract the zip into the webapps directory?
I do not know any default directory in Tomcat to store configuration, my
attempts to solve the same issue have been :
1 - Move configuration to the DB and provide scripts or webpages to modify values.
2 - Have a script to deploy the war. The script would merge configuration from a user directory into web.xml or other deployed config files.
3 - Have webapps look first in a user directory for configuration and
if not found then look for configuration files deployed by the war.
Least favorite is 3 - it require all webapps to check two places for configuration and
you end up with two different xml files on the server with different values and it is not always clear which one is used.
Next favorite is 2 - the webapps can be written without knowledge of multiple config files, but you run into issue when someone does a deploy from Tomcat manager instead of using your script.
Favorite is 1. This just works in most cases. Problem is when you don't have a DB or
want to configure how you connect to the DB.
If having the file visible from all webapps is not an issue, you could put it $CATALINA_HOME/lib.
One solution is to modify property file after deployment of war file is to use ServletContext.getRealpath() method to get the real path means path of file in the server where it is deployed and then modify that file it will modify file in container only not the original file. So you need to backup it if it is important modification for you. So by this you do not need to redeploy war file as it is already modifying file from deployed container.
This solution can edit a file that is in webpages folder also from the java class.
If you want more description or how to do it then let me know i have did it.