Oracle Identity Manager application needs plugins to be deployed as I explained below:
There must be a zip file contains 2 folders and plugin.xml
folder structure is looks like this:
lib folder must contain project itself packaged as jar, META-INF folder must contain pluginPostProcessEventhandler.xml
This folders and file structure needs to be zipped as pluginPostProcessEventhandler.zip to be deployed. Using Jenkins. is there any way creating this folder and file structure as output folder by using pom.xml?
Thanks
With the Maven assembly plugin, it should be possible to create a zip in the way you describe.
I've started working on a spring project, and I'm using Intellij IDEA. I've found that when I run the app it actually compiling the classes to the target/classes directory and running from it.
But, when I've added a beans.xml in the same location of my main class and write necessary codes with ClassPathXmlApplicationContext that beans.xml is not getting placed in the target directories designated location so that many errors are rising.
But when I'm placing the beans.xml in the target directory it's working fine.
What am I doing wrong here? In what structure should beans.xml files be created so that It automatically syncs to target directory?
First I was putting xml file in the src/main/java directory while following a youtube tutorial but he was doing it in eclipse and and it was not working for me in IntelliJ-Idea
If you put xml file directly in the target file, it works because after compilation, result are copied over there.
But for standard procedure you should create an another directory named "resources" in the "src/main/" (final path: "src/main/resrouces" and then create xml file in the directory as soon as you run this project you can see this file also automatically get copied in the target direcoty.
I've a maven project called Project_1. In this project I've a file reader which reads a config file(using relative path) from resources folder(which is sourced) of this project. I've another maven project called Project_2 in which Project_1 is added as dependency. When I'm running the Project_2 now, the relative path for reading config file is not working as ClassPath is set based on Project_2. Could anyone please help me to use proper file path which works in any condition.
NOTE: I don't want to use absolute file path, as I want these projects to be portable. Project_2 alone is customer facing and config file is specific to Project_1 which is not allowed to be configured by customer facing application.
Where in my Eclipse project should I add the log4j.properties file so that it will work as intended?
you can add it any where you want, when you run your project, configure the classpath and add the location of the log4j.properties files by clicking on:
Run->Run Configuration -> [classpath tab] -> click on user Entries -> Advanced -> Select Add Folder -> select the location of your log4j.properties file
and then -> OK -> run
and it should get loaded
The safest way IMO is to point at the file in your run/debug config
-Dlog4j.configuration=file:mylogging.properties
! Be aware: when using the eclipse launch configurations the specification of the file: protocol is mandatory.
In this way the logger will not catch any logging.properties that come before in the classpath nor the default one in the JDK.
Also, consider actually use the log4j.xml which has a richer expression syntax and will allow more things (log4j.xml tahe precedence over log4j.properties.
Add the log4j.properties file to the runtime class path of the project.
Some people add this to the root of the source tree (so that it gets copied to the root of the compiled classes).
Edit:
If your project is a maven project,
you can put the log4j.properties in the src/main/resources folder (and the src/test/resources for your unit tests).
If you have multiple environments (for example development and production),
want different logging for each environment,
and want to deploy the same jar (or war, or ear) file to each environment
(as in one build for all environments)
then store the log4j.properties file outside of the jar file and put it in the class path for each environment (configurable by environment).
Historically, I would include some known directory in each environment in the classpath and deploy environment specific stuff there.
For example,
~tomcat_user/localclasspath where ~tomcat_user is the home directory of the user that will be running the tomcat instance to which my war file will be deployed.
The best way is to create special source folder named resources and use it for all resource including log4j.properties. So, just put it there.
On the Java Resources folder that was automatically created by the Dynamic Web Project, right click and add a new Source Folder and name it 'resources'. Files here will then be exported to the war file to the classes directory
If you have a library and you want to append the log4j:
Create a folder named "resources" in your projet.
Create a .properties file named log4j
Set properties in log4j.properties file
Push right button in the project and go to properties->Java Build Path and, finally, go to the "Source" tab.
Push Add folder and search the "resources" folder created in step 1.
Finish.
(I have assumed that you have the log4j library added.)
PD: Sorry for my english.
This question is already answered here
The classpath never includes specific files. It includes directories and jar files. So, put that file in a directory that is in your classpath.
Log4j properties aren't (normally) used in developing apps (unless you're debugging Eclipse itself!). So what you really want to to build the executable Java app (Application, WAR, EAR or whatever) and include the Log4j properties in the runtime classpath.
Put log4j.properties in the runtime classpath.
This forum shows some posts about possible ways to do it.
I'm finding out that the location of the log4j.properties file depends on the type of Eclipse project.
Specifically, for an Eclipse Dynamic Web Project, most of the answers that involve adding the log4j.properties to the war file do not actually add the properties file in the correct location, especially for Tomcat/Apache.
Here is some of my research and my solution to the issue (again specifically for a Dynamic Web Project running on Tomcat/Apache 6.0)
Please refer to this article around how Tomcat will load classes. It's different than the normal class loader for Java. (https://www.mulesoft.com/tcat/tomcat-classpath) Note that it only looks in two places in the war file, WEB-INF/classes and WEB-INF/lib.
Note that with a Dynamic Web Project, it is not wise to store your .properties file in the build/../classes directory, as this directory is wiped whenever you clean-build your project.
Tomcat does not handle .property files in the WEB-INF/lib location.
You cannot store the log4j.properties file in the src directory, as Eclipse abstracts that directory away from your view.
The one way I have found to resolve this is to alter the build and add an additional directory that will eventually load into the WEB-INF/classes directory in the war file. Specifically....
(1) Right click your project in the project explorer, select 'New'->'Folder'. You can name the folder anything, but the standard in this case is 'resources'. The new folder should appear at the root level of your project.
(2) Move the log4j.properties file into this new folder.
(3) Right click the project again, and select 'Build-Path'->'Configure Build Path'. Select the 'Sources' tab. Click the 'Add Folder' button. Browse to find your new folder you created in step (1) above. Select 'OK'.
(4) Once back to the eclipse Project Explorer view, note that the folder has now moved to the 'Java Resources' area (ie it's no longer at the root due to eclipse presentation abstraction).
(5) Clean build your project.
(6) To validate that the .properties file now exists in WEB-INF/classes in your war file, export a war file to an easy location (right click Project -> Export -> War file) and checkout the contents. Note that the log4j.properties file now appears in the WEB-INF/classes.
(7) Promote your project to Tomcat/Apache and note that log4j now works.
Now that log4j works, start logging, solve world problems, take some time off, and enjoy a tasty adult beverage.
You do not want to have the log4j.properties packaged with your project deployable -- that is a bad idea, as other posters have mentioned.
Find the root Tomcat installation that Eclipse is pointing to when it runs your application, and add the log4j.properties file in the proper place there. For Tomcat 7, the right place is
${TOMCAT_HOME}/lib
In general I put it in a special folder "res" or "resources as already said, but after for the web application, I copy the log4j.properties with the ant task to the WEB-INF/classes directory. It is the same like letting the file at the root of the src/ folder but generally I prefer to see it in a dedicated folder.
With Maven, the usual place to put is in the folder src/main/resources as answered in this other post.
All resources there will go to your build in the root classpath (e.g. target/classes/)
If you want a powerful logger, you can have also a look to slf4j library which is a logger facade and can use the log4j implementation behind.
For a normal (non maven and non web) java project in eclipse.
Create a "source" folder with new options and with any name (as a standard we can name it as resources) under the project directory
push the log4j.properties file to this "source" folder.
Build and run the application.
How can I change default values of "source folders on build path" and "default output folder" in "Dynamic Web Project" wizard in Eclipse, probably in the way as we do for "Java Project" in
Windows > Preferences > Java > Build Path
The purpose is: each time I create new Dynamic Web Project, the wizard should show default source and output folders of my choice.
Since this option is available for Java project so I believe there should be something similar for Web Projects too but I am unable to find it. BTW I tried changing defaults of Java project but it does not effect dynamic web projects.
Can you add web capabilities to your existing Java Project?
Also, this is how to convert a Java Project by editing the .project file (different than how I remember doing it in Eclipse). That might give some insight into how to modify your .project file.
The docs seem to indicate that JavaSource is the property which dictates your Java source files for Dynamic Web Projects.
JavaSource
Contains the project's Java source code for classes, beans, and servlets. When these resources are added to a Web project, they are automatically compiled and the generated files are added to the WEB-INF/classes directory. The contents of the source directory are not packaged in WAR files unless an option is specified when a WAR file is created.
Note: Though the default name given to the folder is JavaSources, you can change the name by right clicking on the name in the Project Explorer and clicking on Refactor > Rename.
Also, I think since a Dynamic Web Project is meant to adhere to J2EE standards you can't change the path to the output folder in your project. You can however rename it if you want.
WebContent folder
The mandatory location of all Web resources, including HTML, JSP, graphic files, and so on. If the files are not placed in this directory (or in a subdirectory structure under this directory), the files will not be available when the application is executed on a server. The Web content folder represents the contents of the WAR file that will be deployed to the server. Any files not under the Web content folder are considered development-time resources (for example, .java files, .sql files, and .mif files), and are not deployed when the project is unit tested or published.
Note: Though the default name given to the folder is WebContent, you can change the name in the Project Explorer by right-clicking the folder and selecting RefactorRename or from the Web page of the project's Properties dialog. In a dynamic Web project, changing the folder name will update the Java build output directory.
It's very easy.
1.Create a text file named "org.eclipse.wst.web.prefs", add following config in it:
# content directory, change the default name "WebContent" to
"webroot"
webContent=webroot
# make the default output of web project from %proj%\bin to
%webroot%\WEB-INF\classes
useSingleRootStructure=true
2.Move it into %workspace%\.metadata\.plugins\org.eclipse.core.runtime\.settings.
3.Restart you eclipse.