Weblogic's Ear shared properties file - java

I got an Ear with a war inside, deployed in Weblogic 12c.
The project is a Maven multi-module project.
I'm trying to find a very simple way to accomplish my boss's request to put an unique properties file inside the ear (let's say in src\main\application\config), and access it by any module project.
No file within domain server (so the file got to be located in the ear) and no command input lines are allowed.
I've tried to read how to weblogic handles custom global property file here:
External properties file with Weblogic
...hey what is this mess? Seriously...everything in weblogic got to be so complicated?
Maybe with a maven plugin am I able to copy during build the property file inside any "src\main\resources" folder of the other sub-modules?
Any idea is appreciated...
thanks!

Related

exporting java app as jar which contains other libraries

I have exported my simple java application as normal jar file which contains all the source file and the dependent libraries ie jar files.
Here all the jars I have kept inside the lib folder of my application.
so these things I am able to do but when I am accessing my application as a jar file in other application then I am getting ClassNotFoundException because whatever libraries I have added inside the First application (which I have exported as jar contains all the dependent libraries) are not visible in runtime.
I think I need to give this information about the dependent libraries in MANIFEST.MF file of first application.
but I don't know whether I am thinking right or wrong.
I don't know how to write the MANIFEST.MF file and what would be the directory structure of the of my application if I want to keep the MANIFEST.MF file in my application.
Here for example I have created one jdbc application to create Connection object for that I had to add the ojdbc14.jar in the classpath of my application so for that I have created one lib folder inside the project root directory and I kept that ojdbc14.jar inside that lib folder and then I build the path.
then I exported this application as simple jar which contains that ojdbc14.jar also then I added this jar in my other application but while running my second application I am getting ClassNotFoundException.
Please Help Me On It.

usage and significance of .Classpath in Application EAR

I am currently working on an EAR application which has a WEB project and EJB project in it.
To work on eclipse with local set up i do so many build path setups and all.
All these buildpaths show up in .classpath of the project.
Now when i export the EAR and deploy on Server everything works on server.
My doubt is how does server know about my local system paths which are present in .classpath of my project.
Does it mean .classpath has no significance at runtime?
Please explain.
.classpath file is eclipse specific, it will not be bundled with the EAR. Eclipse uses it to set the classpath for the project.
An EAR has a well defined structure and Servlet container understands that structure, using it's knowledge it prods around in the EAR file and extracts classes to load in the runtime.
Obviously server doesn't have any knowledge of your local environment. An EAR (or WAR or JAR) file is a simple archive file (with some specification or the file order and all). You can unzip it using any utility (something like 7zip). Check the structure of the packed EAR, that will give you a better understanding of what goes to your server.

Deploying spring soap consumer Jaxb generated files on local Tomcat

Good morning,
I'm trying to deploy a spring application on a local tomcat, using generated jaxb classes. The classes are contained in the build directory build/jaxb/archifant/wsdl in a subproject.
When I try to run the application on server, I get the following error:
error reading file D:\eclipse_rio_workspace\rio\06_Development\archifant-communication-for-spring\build\classes\jaxb
D:\eclipse_rio_workspace\rio\06_Development\archifant-communication-for-spring\build\classes\jaxb (access denied)
I followed the getting started guide: https://spring.io/guides/gs/consuming-web-service/ and use gradle as build tool. The subproject is set up as a dependency. How do I solve this? I checked file permissions and classpath of tomcat.
To me this looks like tomcat is trying to read a directory as file?
"Solved" it by moving the generated classes into a package in the source folder.

Replace content of property files when publishing application in Eclipse

We have an .ear project with several dependent .jar projects and we are using Maven. Each project has its own property file, but the properties inside do not have specific values but placeholders, e.g.
database.url=${database.url}
The placeholder ${database.url} is replaced during Maven build process using the resources plugin. So for each stage (local, test, integration, production) we have a different Maven profile defining the filter, so if we build for the test stage we get something like
database.url=url.for.test.db
The application is running on WLS 12, and we want to deploy it on local WLS using the Eclipse server plugin (we are using Eclipse Kepler). However, when we add the application to the server in Eclipse and publish, it is not working since the placeholders in the property files are not replaced with specific values.
AFAIK, the content being deployed is located in the Eclipse workspace:
<workspace>\.metadata\.plugins\org.eclipse.core.resources\.projects\<ear-project-name>\beadep\<WLS domain name>\<ear-project-name>
Of course we could change the property files in that location, but whenever we publish in Eclipse, those changes are overwritten and we get again the original property file
database.url=${database.url}
which is useless when it is deployed to WLS.
Is there any mechanism or possibility to change the property files before they are deployed to WLS from Eclipse?
Thanks for your help.
Ok here is the solution I chose to solve this (I am not sure whether it is the best one, but at least it is working):
I added a new folder to the .ear project named "properties-local". This folder contains only those property files which are relevant for local deployment (without placeholders), e.g.
database.url=url.for.local.db
Wihtin the properties of the Eclipse project, there is a section "Deployment Assembly". I added the new folder "properties-local" to the deploy path APP-INF/classes, so this is the place where they will appear in the .ear which is used for local deployment.
The maven-ear-plugin, which is responsible to build .ear files for remote stages, is not aware of the directory properties-local.
So the drawback of the solution is, there are now two folders with property files: one for local Eclipse deployment, one for .ear files which are deployed on remote servers.

Referring shared Java EE library for EAR application in weblogic

I have created a shared library with some jar files in weblogic server, now I have an EAR application and I want to use the class files from shared library in my web applications present in EAR application. So I have created weblogic-application.xml file inside my ear-app/META-INF/ directory and gave reference to shared library using below tags:
<library-ref>
<library-name>ebs_endeca_artifacts</library-name>
</library-ref>
But when I am trying to access the class files in my application, I am getting exception java.lang.ClassNotFoundException
Also it is required for me to refer to the shared library at ear level instead of declaring in weblogic.xml file of individual war files.
If I directly place the same jar files in my ear-app/APP-INF/lib directory instead of using shared library then my application is working fine without any issues.
Please help me how can I use the shared library in my ear application. I am using weblogic server 10.3.6
My shared library structure will be like this:
shared-web-app/WEB-INF/web.xml
shared-web-app/WEB-INF/lib/*.jar
You need the jars from the shared library in your classpath, because before you deploy the EAR, the application needs to be built. JDeveloper wouldn't know where are those classes stored, so that it need those at compile-time.
When preparing the application for deployment, you can create filters for the files that can be added within the WAR/EAR/<whatever>. Go to Application Properties -> Deployment and select your deployment profile. Click on the Edit button and a screen will be prompted, from where you can filter the files/libraries that can be included when the application is built.
If you don't include the shared library in the archive and have the fragment from the weblogic-application.xml you've posted, the WebLogic server will then use the classes from the shared library.
Hope that helps. Ask anything you don't understand as a comment. :)

Categories