I've got a relatively simple jar-with-dependencies being built with Maven that is way larger than it seems like it should be. It's around 20MB, and in order to figure out what's taking up so much space, I've done the following:
First, I ran mvn dependency:tree. Then I checked in my .m2 cache for the size of each of the jars in the dependency tree. If I add up all of those sizes, it comes to about 8MB. How can I figure out where the other 12MB are coming from?
One thing I noticed in looking through my .m2 was that for many of the dependencies, they'll have something like this:
total 5224
-rw-r--r-- 1 user 289B Jul 25 2016 _remote.repositories
-rw-r--r-- 1 user 1.7M Jul 25 2016 commons-compress-1.12-javadoc.jar
-rw-r--r-- 1 user 407B Jul 25 2016 commons-compress-1.12-javadoc.jar.lastUpdated
-rw-r--r-- 1 user 40B Jul 25 2016 commons-compress-1.12-javadoc.jar.sha1
-rw-r--r-- 1 user 427K Jul 25 2016 commons-compress-1.12-sources.jar
-rw-r--r-- 1 user 407B Jul 25 2016 commons-compress-1.12-sources.jar.lastUpdated
-rw-r--r-- 1 user 40B Jul 25 2016 commons-compress-1.12-sources.jar.sha1
-rw-r--r-- 1 user 432K Jul 22 2016 commons-compress-1.12.jar
-rw-r--r-- 1 user 407B Jul 22 2016 commons-compress-1.12.jar.lastUpdated
-rw-r--r-- 1 user 40B Jul 22 2016 commons-compress-1.12.jar.sha1
-rw-r--r-- 1 user 13K Jul 22 2016 commons-compress-1.12.pom
-rw-r--r-- 1 user 407B Jul 22 2016 commons-compress-1.12.pom.lastUpdated
-rw-r--r-- 1 user 40B Jul 22 2016 commons-compress-1.12.pom.sha1
What are the -sources and -javadoc jars? Are those included in my uber jar? Because if every one of my dependencies uses the -javadoc jar instead of the standard one, that gets me a lot closer to 20MB.
Run
jar tvvf <your_simple-jar-with-dependencies.jar>
Or, open it with any zip compatible archiver and examine the contents to determine what is being included. Alternatively, run maven with -X for more extensive runtime information.
Related
I've just installed IntelliJ and imported a Maven / Spring Boot project. I've set up my run configuration as "application", but when I try to run it, it fails and complains of not being able to resolve dependencies. When I check my local Maven repository, those dependencies are installed:
/Users/user/Projects/myapplication/src/test/java/com/something
/SomethingServiceTest.java:23:29
java: package org.junit.jupiter.api does not exist
local maven repo:
$ ll ~/.m2/repository/org/junit/jupiter/
total 0
drwxr-xr-x 6 user Users 192B 21 Aug 2020 ./
drwxr-xr-x 6 user Users 192B 2 Sep 2020 ../
drwxr-xr-x 3 user Users 96B 21 Aug 2020 junit-jupiter/
drwxr-xr-x 3 user Users 96B 21 Aug 2020 junit-jupiter-api/
drwxr-xr-x 3 user Users 96B 21 Aug 2020 junit-jupiter-engine/
drwxr-xr-x 3 user Users 96B 21 Aug 2020 junit-jupiter-params/
IntelliJ and the pom.xml are probably not in-sync.
Right click on the pom.xml and Maven -> Reload Project
I've been the same problems. Sometimes I try to remove or change the name of the ~/.m2/repository directory.
After that, I make
mvn clean compile and install
Try this.
Anyone can tell me where can I find the full version of JFreeChart? I downloaded the JCommon and JFreeChart as well (from the sourceforge page), but the JFreeChart contains only the jfreechart-demo.jar, so even if I correctly added the libraries in Eclipse, it doesn't work either...
Many Thanks!
When unpacked, the required JAR files are in the lib directory.
$ ls -ln lib
total 5800
-rw-r--r--# 1 501 20 45024 Jul 31 2014 hamcrest-core-1.3.jar
-rw-r--r--# 1 501 20 330246 Jul 31 2014 jcommon-1.0.23.jar
-rw-r--r--# 1 501 20 13796 Jul 31 2014 jfreechart-1.0.19-experimental.jar
-rw-r--r--# 1 501 20 79793 Jul 31 2014 jfreechart-1.0.19-swt.jar
-rw-r--r--# 1 501 20 1570157 Jul 31 2014 jfreechart-1.0.19.jar
-rw-r--r--# 1 501 20 50769 Jul 31 2014 jfreesvg-2.0.jar
-rw-r--r--# 1 501 20 245039 Jul 31 2014 junit-4.11.jar
-rw-r--r--# 1 501 20 445025 Jul 31 2014 orsoncharts-1.4-eval-nofx.jar
-rw-r--r--# 1 501 20 72444 Jul 31 2014 orsonpdf-1.6-eval.jar
-rw-r--r--# 1 501 20 80054 Jul 31 2014 servlet.jar
-rw-r--r--# 1 501 20 17492 Jul 31 2014 swtgraphics2d.jar
For example, the following command line runs TimeSeriesChartDemo1 on Unix; separate class path entries with a semicolon (;) on Windows.
$ java -cp .:lib/* org.jfree.chart.demo.TimeSeriesChartDemo1
I have a war file deployed on tomcat ( /var/lib/tomcat7/webapps folder ), say, rest-api-webapp-0.0.1.war
To access the rest endpoint check, exposed in this war, I use curl in the format
curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -d "remarks=Tester" https://localhost:8080/rest-api-webapp-0.0.1/check The problem I face is, whenever I up the patch/major/minor versions of my webapp, I need to change the curl appropriately (say the version is now 0.1.4, then the curl must change as curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -d "remarks=Tester" https://localhost:8080/rest-api-webapp-0.1.4/check. I donot wish to change the way the client calls the endpoint (because it requires the client to upgrade their app, which they resent and see as high maintenance) Can this be avoided by doing something like this
Create a symbolic link as below ln -s rest-api-webapp-0.0.1.war rest-api inside the /var/log/tomcat7/webapps folder so that whennever I up the version, I just change the symlink to point to the new version and the client need not do anything to use the new version of the api. In effect, I need the api endpoint to be fixed and not change as and when I up the versions on the server. For Ex: I need the endpoint to be fixed as https:gva.atr.in/colouring-api/check and whenever I have a major change in the controllers and all that I need to do is just update the symlink and not change the endpoint. If you find that this approach is flawed, please show me the right direction as I have been trying to read about this from the past 2 days, but found very less articles that address my problem.
I read the tomcat documentation and realised that I need to create a symbolic link to the war file and give the symbolic file the war extension. So If this is what you have in your tomcat webapps directory
/var/lib/tomcat7/webapps user1$ ls
drwxr-xr-x 11 user1 wheel 374 Oct 19 21:52 .
drwxr-xr-x 9 user1 admin 306 Oct 19 19:36 ..
drwxr-xr-x 19 user1 wheel 646 Aug 29 20:19 ROOT
drwxr-xr-x 55 user1 wheel 1870 Aug 29 20:19 docs
drwxr-xr-x 4 user1 wheel 136 Oct 19 19:46 rest-api-webapp-0.2.1
-rw-r--r-- 1 user1 wheel 48258097 Oct 19 19:46 rest-api-webapp-0.2.1.war
drwxr-xr-x 7 user1 wheel 238 Aug 29 20:19 host-manager
drwxr-xr-x 8 user1 wheel 272 Aug 29 20:19 manager
Do this,
ln -s rest-api-webapp-0.2.1.war rest-api.war So that the directory looks like this (Wait for sometime for the tomcat engine to deploy the new war)
drwxr-xr-x 11 user1 wheel 374 Oct 19 21:52 .
drwxr-xr-x 9 user1 admin 306 Oct 19 19:36 ..
drwxr-xr-x 19 user1 wheel 646 Aug 29 20:19 ROOT
drwxr-xr-x 4 user1 wheel 136 Oct 19 21:52 rest-api
drwxr-xr-x 4 user1 wheel 136 Oct 19 19:46 rest-api-webapp-0.2.1
-rw-r--r-- 1 user1 wheel 48258097 Oct 19 19:46 rest-api-webapp-0.2.1.war
lrwxr-xr-x 1 user1 wheel 25 Oct 19 21:51 rest-api.war -> rest-api-webapp-0.2.1.war
drwxr-xr-x 7 user1 wheel 238 Aug 29 20:19 host-manager
drwxr-xr-x 8 user1 wheel 272 Aug 29 20:19 manager If needed restart your tomcat and you can use the curl command like this curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -d "remarks=Tester" https://localhost:8080/rest-api/check totally not bothering about the major, minor, patch versions. All that you need to do once you have a new version is unlink rest-apiln -s rest-api-webapp-X.Y.Z.war rest-api.war
In eclipse it does it anyway when exporting jars, and will only give a warning unless you tell it not to. However in IntelliJ, it refuses to delete the file when building a new version, and I have to go through and manually delete the jar myself for IntelliJ to export properly. Is there a way I force IntelliJ to overwrite jars when it exports?
IntelliJ always overrides artifacts. Try it again. Make sure no other process is using the file with:
$ lsof |grep [file name]
I just tried to make a project with artifact generation, no issues whatsoever.
bender:queues_jar demo$ ls -ltra
total 1408
-rw-r--r-- 1 demo staff 718737 Feb 11 21:26 queues.jar
drwxr-xr-x 3 demo staff 102 Feb 11 21:26 ..
drwxr-xr-x 3 demo staff 102 Feb 11 21:26 .
bender:queues_jar demo$ ls -ltra
total 1408
drwxr-xr-x 3 demo staff 102 Feb 11 21:26 ..
-rw-r--r-- 1 demo staff 718737 Feb 11 21:27 queues.jar
drwxr-xr-x 3 demo staff 102 Feb 11 21:27 .
I want to create size based log files. I am setting the following entry in the log4j.properties file:
log4j.appender.UserFileAppenderDebug=org.apache.log4j.RollingFileAppender
log4j.appender.UserFileAppenderDebug.Threshold=TRACE
log4j.appender.UserFileAppenderDebug.File=../log/coordinator-debug.log
log4j.appender.UserFileAppenderDebug.MaxFileSize=1KB
log4j.appender.UserFileAppenderDebug.MaxBackupIndex=7
log4j.appender.UserFileAppenderDebug.layout=org.apache.log4j.PatternLayout
log4j.appender.UserFileAppenderDebug.layout.ConversionPattern=%m%n
multiple log files are created based on size but with following names:
-rw-r--r-- 1 root root 32 Aug 6 11:28 coordinator-debug.log
-rw-r--r-- 1 root root 1.1K Aug 6 11:28 coordinator-debug.log.1
-rw-r--r-- 1 root root 1.1K Aug 6 11:28 coordinator-debug.log.2
-rw-r--r-- 1 root root 1.2K Aug 6 11:28 coordinator-debug.log.3
-rw-r--r-- 1 root root 1.1K Aug 6 11:28 coordinator-debug.log.4
-rw-r--r-- 1 root root 1.1K Aug 6 11:28 coordinator-debug.log.5
-rw-r--r-- 1 root root 1.1K Aug 6 11:28 coordinator-debug.log.6
-rw-r--r-- 1 root root 1.1K Aug 6 11:28 coordinator-debug.log.7
I would like to have the file name as follows
coordinator-debug.log.2013-08-01 11:28:39, 232
I would appreciate if you please share your comments/suggestions.
Thanks.
Have you tried:
log4j.appender.UserFileAppenderDebug.DatePattern='.'yyyy-MM-dd_HH-mm-ss
(remember that your filename will not allow : e.g 11:28:39, you will need to replace them to e.g. 11-28-39 )
(edited)
Sorry, I thought you used the *Daily*RollingFileAppender...
There are RollingPolicys that you might use to get filename pattern for the RollingFileAppender.
E.g.
log4j.appender.UserFileAppenderDebug.RollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
log4j.appender.UserFileAppenderDebug.RollingPolicy.FileNamePattern=../log/coordinator-debug.log.%d{yyyy-MM-dd-HH-mm-ss}