WebLogic load jar without class file? - java

I'm currently working on a prebuilt application running on weblogic.
The application consist in NAME_APPLICATION.jar that must be deployed on weblogic.
My problem is that I can't analyze anything for the simple reason that the jar DOES NOT CONTAIN ANY .JAVA OR .CLASS FILE
The jar just contain the following files:
- APPLICATION_1.0.sources
- APPLICATION_1.0.space
- APPLICATION.ws
- GET_SOMETHING.ds
- GET_SOMETHING.service
I really don't understand it. Where is the application ? How weblogic knows the logic (forgive me the pun) of the app? How to edit the application and where is the source files?
It's the first time that I see such Jar file, it's probably because I'm a weblogic beginner
Thanks

These are resources that must be available on the classpath for the application to find them and access them. I am guessing that the documentation tells you to deploy it as a shared library.
If they are binary files (not text files that you could try reading with a text editor), then whatever application needs them obviously knows their format and how to read them.

Related

Running a Java Web Start application without Java Web Start

I want to run a fat client delivered as a Java web start application without Java web start. I launched it via javaws and managed to get all the jar files mentioned in the JNLP file from the cache after they were downloaded.
I tried running the jar file that contains the main class according to the JNLP file, but I get the 'Could not find or load main class' error. Were I just trying to run a class I'd set the classpath accordingly, but since I'm running a jar file with java -jar, as far as I know the classpath settings will be ignored anyway. Now I'm not sure what to do, does anybody know how to tackle this?
I'll answer this myself now, turns out it is stupidly simple: Get all the jar files, unzip them to get the content, merge all the content (best done with rsync), create a new MANIFEST.MF file that contains the main class to be loaded and the merged hashes for all existing files from all MANIFEST.MF files, zip again to create a jar. That's it.

How to refresh a java application after making a file change

This may sounds like a dumb question to some, but I am not a Java developer, we have moved a Java app from Rackspace server to AWS linux server and upgraded MySql from 5.2.x to 5.7.x. Some SQL statements are causing issues so I am trying to fix those inside the .java files. However, when I save the file, and use .sftp library from VSCode to push the changes to the linux server, then refresh the site, it does not reflect the changes. Is there anything else I need to be doing every time I make a change?
I was able to update some string in a .jsp file and that worked when I refreshed, so I am not sure why when I change a .java file, it does not reflect change.
The entire directory is confusing to me, I believe it was done so that all files, configs, tomcat files, etc. would be under one git folder so that it can just be dropped anywhere. I find a lot of sources state that a .war file would be created and you would place that file in the tomcat apps directory.
Here is the basic layout of the directory of the app
-www/live/njun
-build.xml
+lib
+scripts
+sql
+src
-tomcat(has some config files, scripts, webapps folder)
-web
-content
-index.jsp
-trampoline
-includes folders with .java files
-tickets
-ticketsMgr.java (this is the file I modified but I could not see any differences in app)
-index.jsp (this is one I modified and did reflect in browser)
-WEB-INF
-classes/com/njun
-lots of folder that have .Class files(although when I open them it's all gibberish characters)
This is the basic structure of what I am looking at.
I tried going to the /opt/tomcat/bin and > sh startup.sh - to restart tomcat. That didn't work.
I also ran the > sh startup.sh version inside of the tomcat folder above,
/tomcat/bin/sh startup.sh - that shows me some info where the home, base tmpdir, jre_home, etc. But that didn't work neither.
I am not being asked to make major modifications on this app, I figure I can manage the SQL errors myself. If we get to the point where we need enhancements done to this app, we would hire a Java developer.
Please let me know if I am missing something and I can provide.
Thanks in advance,
That's because a .java file is just source code. You need to compile it and upload the corresponding .class file generated when you compile the .java sources. How to compile and run a Java program. Or well, since it runs on a Tomcat instance, you might have a JAR or WAR file. But the idea is still the same, since those are just basically zip files that hold your .class files (among other stuff that's less relevant for your issue).

Using Java Web Start when main jar depends on other files

I have recently completed a java program and Im now looking into options for deploying it. I was introduced today to Java Web Start. My problem is the following: my program contains the main executable jar, a lib folder that contains the libraries which my program uses, and a couple of other folders which contain files that my program reads from and writes to. Is it possible to use Java Web Start with such a structure? All the examples I have seen on the web were simple programs made up of just one jar. Thanks.
The extra libraries are no problem. Just add a reference to each one in the JNLP resources section.
The 'loose files' are, slightly, in that loose resources cannot be referenced in a JNLP and archives are not writable. But even that is fixable. See the accepted answer to How can an app use files inside the JAR for read and write?

Files not accessible in Deployed Java class, but working locally in Web app developed on play 2.2 framework

I have a web application that I developed in Java over Play 2.2 framework.
When I am running the app locally one of my java class which is accessing some files in the project folders run fine.
After I create a jar file and run it, the java code is not able to read those files. The files are in the public folder and I have ensured packaged in the jar.
There are other files which I have referred from HTML and they are accessible but the java classes are not able to access the files.
Please help me solve this issues.
I think you are trying to access a file inside a jar. If I have understood your question. Please correct me if I am wrong
You could use something like this:
InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileFromJarFile);
If test.txt was in the root of your JAR file, you'd use:
InputStream is = this.getClass().getClassLoader().getResourceAsStream("test.txt");
NOTE : The file and the java class needs to be in same jar file.
The code was all fine in my case, the directory structure at the jar side was where I missed the part.
I had to keep the files/folders in the directory as same as that of the jar as #APaul said, I tried that but it did not work because I was using a batch to run the jar. My files should have been in the folder containing the batch file. My bad!
Anyways Thanks #APaul.

Java .War File Compilation

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

Categories