I am using spring MVC validation for my login form in eclipse.
Here i want to add my jar files (Hibernate-validator,javax.validator etc..) into the lib folder in the WEB CONTENT.But if every time i add it will get into Javascript Resources.
I do found these question in forum but still cant get the right answer.Can any suggest me want i have to do.
Check if any copy of it is actually physically being copied to your javascript resoures at runtime. If so there might be some setup which is doing so, otherwise there is no possibility of your jar files being copied to your javascript resources.
Related
I have a case where I need to unpack the library using the:
spring-boot:repackage:requiresUnpack
Otherwise, the other library from the project is not able to work properly. As stated in the link, the selected libraries are unpacked and copied over to the temporary directory. Unpacking the libraries to the temp directory isn't great idea if I would like to keep the application running longer that the temp files expiration time. The files would be removed and application will just stop working properly.
Is there a way to specify the different target directory?
Is there a reason why the temp location is good place for the application libraries?
So far, I was able to change the location target location via overwriting the TMP and TEMP environment variables but that sounds like terrible idea in the long run.
Appriciate any help here.
This problem is not specific to "requiresUnpack" only, this is how spring-boot/tomcat handles its temporary files. So it might also surprise you in other areas.
There is an issue describing that behavior: https://github.com/spring-projects/spring-boot/issues/5009
Workarounds:
use server.tomcat.basedir to define Tomcat base directory. If not specified, a temporary directory is used.
use -Djava.io.tmpdir=/var/tmp to start the app with different temporary directory.
Another solution would be to NOT unpack your library. Don't store it in your fat jar, but store it somewhere on the classpath.
I'm currently working on a small Java Project (~30 Classes, 5 external libs).
The code accesses resources in the folders src/resources and src/test_resources using getClass.getResouce("/resources/any.file").
Most of these resource files will probably never be touched by a user, but there are also some regular configuration files which are intended to be edited by the end users.
My question now is: How should I be deploying such an application?
Exporting everything into a runnable jar doesn't seem to be a good way, as I don't wanna torture my users and let them unzip the jar for editing the configuration files.
Should I export all of the internal stuff into the jar, and copy the resources directory into a Folder side by side with it? How can I access the resources then?
Thank you guys!
You could copy the resources folder. It doesn't necessarily need to be side-by-side with the jar file. The key is that you need to put the parent folder of the resources folder on the classpath.
For example, you could copy it someplace like:
c:\some\directory\resources
Then, when you execute, do something like:
java -cp c:\some\directory;c:\some\path\to\your.jar;... your.main.ClassName
Grails newbie here. My application is in Grails, my IDE is IntelliJ IDEA. I configured my project (in IntelliJ) to say that my resources folder is under root\src\resources. I have an image file in there that I need to load into an InputStream / BufferedImage. However I can't seem to get to those resources from my Grails controller. This is what I was trying:
def image = this.getClass().getClassLoader().getResourceAsStream("image.png")
But that just returns null. I use this exact same convention in Java projects (well, except I have to declare image being of type InputStream), and it does work there. I was under the impression that I could essentially drop Java code in a Grails project and it should just work. What do I need to do differently to get this to work in my Grails controller? I need to access that static resource file.
If you mark a directory as a source directory in IntelliJ IDEA, Grails won't know about it. You have to configure Grails properly by either adding your new directory as a source directory or move the resource to one of the standard source directories.
I've never actually added a new source directory myself, but the answer to this stackoverflow question looks promising.
Other than that, you can just add resources to any source directory and it will be included, for example: grails-app/conf, src/java, src/groovy and more. In addition, any file in web-app/META-INF/classes will also be in the classpath of the application. The last one is great to know about if you need to copy a java or groovy source file (i.e. just copy, no compilation).
Try this
servletContext.getResourceAsStream("/WEB-INF/resources/yourfile")
I have seen two questions with same subject, but none of them seem to answer my question.
How to load a jar from an URL without downloading it?
Get files from Jar which is on the repository without downloading the whole Jar from Java
I, in an applet, would like to download classes from a Jar file inside the server, but without downloading the whole jar file.
Is it possible?
in an applet, would like to download classes from a Jar file inside
the server, but without downloading the whole jar file
If you have control over server code, write a servlet and then call the servlet with appropriate query to pull the required class in the jar. Something like following:
http://myserver.com/myservlet?download_class=x.y.z.class&jar_file=my.jar
The applet will call on above URL. At the server, your servlet will pick the jar file and extract the required class and then send it across (using ServletOutputStream) to to the applet.
I think above should work for you.
I need some help figuring out how to make some changes to some .jsp pages that are contained inside of a .war package.
I am using jbilling opensource billing software and need to modify some elements/display and want to do it directly in the .jsp, so I unpacked the .war file and made a change, then packaged it back up and put it inside the webapps folder and restarted tomcat. But I noticed the filesize from the .war that I packaged was smaller than the original .war and it should have been larger because I added stuff to it. Needless to say, tomcat didn't start up properly, or at least there were errors in the logs..but they didn't help me and jbilling didn't work right. I reverted back to the orignal .war and it worked fine.
Is it possible for me to unpackage a .war and simply make some html changes, then repackage it up without having to recompile the whole source code with the java classes? Did I use the wronge "packaging" tool to compile it? Is there another way to accomplish what I'm trying to?
I did this in a FreeBSD box with using the following commands:
unpackage-->sudo jar cf ../billing.war *
repackage-->sudo jar -xvf billing.war
Thanks for your help.
Moreover, .WAR and .JAR (AFAIK all it goes for all .*AR) are basically glorified zip files conforming to some structural requirements (manifests, web app descriptors, etc.). The easiest way to do the changes you want are to handle the .WAR file as if it was a plain-simple ZIP file. The choice of the tools is all yours (archiver, pkzip, etc.).
You can simply open war file using archiver utility (seems you are using ubuntu).
Open jsp file from archiver util it self , make changes , and Archiver util will ask that jsp file has been modified you want to update your war file say yes there.
Note: If you are going to do only view changes than go for this tricky way otherwise if you are willing to change source java files than building the war will be strongly recommended