GetClassLoader weblogic error - java

i have any problems with weblogic 12c.
I have a java web application, it run with TomCat.
No i must trasfer this application on weblogic 12c server. I have chage any file and deploy the application. Found, but i can't read a file.jsp. (This file found correctly on TOMCAT).
I have this strcture:
Folder:
WebContent
- WEB-INF
-- jsp
--- errorIdent.jsp
But when i use this cose
InputStream in =
this.getClass().getClassLoader().getResourceAsStream("../jsp/errorIdent.jsp");
the inputStream object is null.
For this i try some test case and i find this file only if i put it into WEB-INF/classes

WEB-INF is not on the classpath.
WEB-INF/classes is the root of the classpath.
Libraries in WEB-INF/lib are also put on the classpath.
Why would you want/need to read a JSP file from Java anyway?

Related

GetResourceAsStream not working on Websphere server

Application Server : IBM Websphere
Java 6
Issue :
Below is the folder structure of web application :
WEB-INF/libs/props/
The issue is below code is not working :
this.getClass().getResourceAsStream('/props'/+fileName) where fileName is a valid file name inside props folder of WEB-INF/lib/pros.
The class which is calling above method is inside a JAR and included in lib
The above call returns NULL.
The same set up works on tomcat with web application deployed in expanded mode integrated inside Inteliij IDE. On environment where this issue is coming , the application is deployed as ear
Please help as I not able to get any clue on this
The jar files under WEB-INF/lib are in the classpath. Not WEB-INF/lib itself.
The file should be in one of those jars, or under WEB-INF/classes (which is in the classpath)

wildfly 8.2 Read properties files inside ear

I need to read a properties file located inside an ear. In jboss 5.1 I put the file in the root of the ear and it works, but in wildfly it doesn´t.
In wildfly, I managed to read the property file outside the ear according to this
http://blog.jyore.com/?p=58
But I haven´t found the way to do the same but with the file inside the ear. I´ve tried without success putting the file in the METAINF folder, also tried with the "Class-Path: ." in the manifest...
Please any ideas?? Do I have to put the file in any specific location??
I found the solution:
In WildFly 8, to get those properties available in the classpath, package them within your application. For example, if you are deploying a .war then package those properties in WAR WEB-INF/classes/ folder. If you want those properties accessible to all components in a .ear, then package them at the root of some .jar and place that jar in EAR lib/ folder.
https://docs.jboss.org/author/display/WFLY8/How+do+I+migrate+my+application+from+AS5+or+AS6+to+WildFly
Thanks for your help

Difference between deploying WAR and Build folder

Question 1: May I ask what is the difference between deploying a java webapp with it's WAR file vs just copy/pasting the build folder into tomcat webapp folder?
Question 2: Somehow I am told to deploy my project just by renaming my /build/web folder to /build/, then copy and paste this folder into tomcat/webapp folder. Tomcat did serve the web app and I could access it via url. But the problem is that I suspect my System variables were not set. I start up a servlet and put this code in this init(ServletConfig config) method:
System.setProperty("LogPath","D:/Test/logs");
And doing this in my log4j.properties
log4j.appender.file.FILE=${LogPath}/wrapper.log
wrapper.log is not found in the designated directory but a stdout.log is found in tomcat/logs folder.
I am sure the init() method was fired because I have a quartz scheduler there. I am suspecting that my System.setProperty was not set. Any hint?
Update: With all the same source code, I have no problem if I am deploying with a WAR file. The ${LogPath} in log4j.properties work as expected.
Let me answer you the first question.
WAR file is a zip archive with different name. When you deploy this file to the Tomcat server, it unpacks this file to its folder as you would do it by copy-paste. If you are just developing your own project in your own environment and you don't want to distribute it, you don't need to create a war file. But if you want to distribute this project, I recommend you to create a war file. One file is easier to be sent.
Read more on Wikipedia http://en.wikipedia.org/wiki/WAR_%28file_format%29

JOSSO gateway deployment on Weblogic 10

I'm trying to work out a proof of concept with SSO using JOSSO. However, i'm having issue installing JOSSO on my server, which is a Weblogic 10 instance.
I have managed to install JOSSO in my domain. However when i start the server, there's an error saying it failed to parse one of the configuration XML file on the server because the file is not found. I double check the directory and the XML file is actually there.
The exception:
SEVERE: IOException parsing XML document from class path resource
[josso-gateway-config.xml]; nested exception is
java.io.FileNotFoundException: class path resource
[josso-gateway-config.xml] cannot be opened because it does not exist
Also another issue i'm facing is, on my production server, the webapp directory is actually in a separate partition as the Weblogic home folder. I found that the JOSSO installation program will assume that both of them are located in the same directory. Is there any way i can customize this?
Thanks in advance.
Managed to get it solved. Posting it here in case can help someone.
Due to the setup of my weblogic environment, i have decided to explode the war file, and deploy it as an exploded directory. Steps i followed:
Use WinRAR and unrar the war file into a directory
Copy all the xml configuration files into the classes folder
Rename one of the stores configuration file into josso-gateway-stores.xml
Deploy the exploded directory

Viewing JSPs with Weblogic JSPServlet

We are currently migrating from OC4J to Weblogic. We have an ANT script which builds the EAR file. The ANT also compiles and packs all the .jsp files into a jar. But when I tried to run the application on Weblogic it always returned 404 when trying to access .jsps. So I tried to add a mapping in web.xml for weblogic.servlet.JSPServlet for the URL pattern *.jsp, but I still get 404 when I try to access .jsps.
What could be the problem?
Thanks.
Your EAR file structure needs to be correct.
If you are deplying to WLS, you can deploy either an EAR or WAR seperately, however if you choose EAR file, you must have the the JSP's within the WAR file. You should only need to specify servlet and resource mapping within the web and context xml files.
You must also make sure that you have your .jar files in the library. Otherwise you can run into problems.
Let me know if you need more info.

Categories