Java – deploy spring based war and externalize its jar dependencies

I have a spring application that has many dependencies (18 megabyte jar files..) – Now, when I test on a remote Tomcat 6.0 server, I don't want to upload that 19 megabyte dependency, and I just need to upload the course It's simple, isn't it?

I can't get the damn thing

I am using eclipse 3.4. If I delete the export of all dependencies in Java build path - > order and export, I will get a good small war

So this is what I tried:

I upload all LIBS to the server and put them in Tomcat's common / lib The directory doesn't exist, so I created it and modified Catalina properties:

shared.loader=${catalina.home}/common/lib/*.jar

I've tried other configurations, but they didn't work Restart the server and the deployment war cannot start especially:

SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderList$java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener       at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1

It is trying to load the log4j listener and it cannot find it in the classpath The spring library where the listener is located is common / lib

In addition - when I deployed the full 18 megabyte war, it worked properly All content and applications start Of course, it can work normally locally

Oh - I've replaced hard - coded logging jars with those in the extras folder to allow log4j to work

How can this help? I don't know why it doesn't work

Solution

"I have a spring application with many dependencies (18 megabyte jar file...) – now, and upload the course. It's very simple, isn't it“

I don't understand that - 19Mb isn't a lot You just need to pack war

I suggest that you test locally on the same Tomcat instance, work it all, and then deploy the war to the remote Tomcat instance

Update: one problem with putting these jars in Tomcat's / lib directory is that now every application you deploy to the instance will see these jars - change them to one, and all of them will be affected If you put jars in each web - inf / lib, you can modify each application without affecting other applications The cost is duplicate jars and disk space, which is cheap

If you have to migrate from devl - > test - > prod, another problem is that now each environment must deploy the same jar to make your application work normally Miss one, you are broken Your application depends on whether you have these dependencies If they're not on the server, you're out of luck Keep control and package the jar in a war file

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>