WebLogic 12c Domain Home Classpath resource throws FileNotFoundException on Windows but not Linux - spring

I'm creating a web application that needs to run on Weblogic 12c. The application is set-up to have an external XML config file, that is provided by the user, read using the Spring ClasspathResource bean (i.e. <bean id="myResource" value="config.xml>). On a linux environment, this works fine when the file is placed in the DOMAIN_HOME. However, when I attempt the same on a Windows environment, I get a FileNotFoundException as soon as I attempt to access the Resource instance.
The WebLogic installations are from the same jar executable installer and are absolutely identical, so I can't seem to figure out why this doesn't work on Windows. I'd appreciate ANY help whatsoever...
Just to clarify, I know I can get around this on Windows by informing the user to set a CLASSPATH environment variable but I'd rather not.

Related

Web application throws NoClassDefFoundError in Unix server whereas locally in Eclipse it works properly

I'm newbee in web application deployment and stuff related to this. I have simple maven web application which works cool locally in my Eclipse & Tomcat9 server. Application has jsp file and main class, both try to call log4j2 classes like Logger or LogManager:
<% Logger.getLogger("bla").toString()%>
or in main:
private statis final Logger logger = LogManager.getLogger("blablabla");
Just in addition I call getPath() method on those classes and they show me my local maven repository.
After I deployed it on Unix server I get NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.status.StatusLogger in browser and if I try to call it again I always get a bit different: NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
Trying to execute main class through the PuTTY I get the same however after setting up a export CLASSPATH=$CLASSPATH:./WEB-INF/lib/* to the path with the libraries the program exetutes in console showing me enviroment CLASSPATH exactly as i've set before but continuing to not to work as web application through the browser.
I've tried to set CLASSPATH through the command above (startup.sh\setenv.sh etc...) but nothing. The command ...catalina.sh version shows me a CLASSPATH but app still doesn't work. I can only run a main class in PuTTY after manual setting up the CLASSPATH as I said above.
I've run out of ideas, probably you guys can give me some tips & hints about it? Maybe there is some script to set it each time starting the app. Unfortunatelly I'am not able to attache some code stuff.
The problem was related to the SecurityManager which was turned off on my local whereas it was turned on on a server. First I had simulated problem on my local, then I found out what permissions are missed debagging SecurityManager. I then added an VM argument -Djava.security.debug=access,failure to a run conf. Be carefull because of huge amount of output in console and better to log it in external txt file. After that I ran through the log.txt serching a word like "denied\failed\fail" and added necessary permission to a catalina.policy file.
Hope that will be helpfull for somebody.

LD_LIBRARY_PATH on Websphere Liberty profile not known anymore after redeployment JavaEE 8 EAR File

Hi I am currently facing a problem concerning the LD_LIBRARY_PATH variable in Websphere liberty. The application server is used within a docker container and the LD_LIBRARY_PATH variable is set within the server.env file. The first time, the container is starting, everything is fine. The ear is mounted into the container by directory and is getting started. The path within the Variable is resolved correctly.
While doing a rebuild of the ear, while the container is still running (for a shorter development turnaround) the application server detects the changes and restarts the new ear. But at his point, the LD_LIBRARY_PATH cannot be resolved anymore without any change in the server.env file.
Did anybody face the same problem yet and found a solution to it ?
If you need more information feel free to ask.

Pass command-line argument for a particular Tomcat web-application startup

For my Spring-Boot project, I have used jasypt library for encrypting my datasource.password in application.properties file. In my localhost setup, I have configured VM arguments in eclipse and it works completely fine.
-Djasypt.encryptor.password
-Djasypt.encryptor.algorithm
Now, I want to deploy my application to Tomcat server where I am not able to figure out where to configure these VM arguments so that Tomcat picks them when I click on "start" button from Tomcat Manager GUI.
Read solutions about setenv.sh but I think that works at complete Tomcat server level. I need to pass these arguments only for my current application without affecting other applications which are already hosted.
Any help is appreciated.

Can't access static file from Spring Boot application running in Tomcat servlet

All I want to do is access a specific file in a Java class. I am using Spring Boot 2.0.0.M7. When I run from my development machine using mvn spring-boot:run then everything works well. In that case I am using:
File jFile = new File("src/main/resources/static/folder/fileName.txt");
When I deploy this to a Tomcat server (8.5) as a war, the file is put into:
WEB-INF/classes/static/folder/fileName.txt
I've tried everything I could find or think of, but always get an error of some sort, usually a file not found exception.
My most recent attempt was:
URL url = this.getClass().getClassLoader().getResource("fileName.txt");
File jFile = new File(url.getPath());
That produces a null pointer exception with url.getPath().
I have read about needing to access the servlet config, but couldn't ever understand that well enough to get it to work. Does anyone have a clear example so that I can access the file both from the development context and the production context? Thanks!

Tomcat Context Root - Tiles Exception when deploy a Spring app to Tomcat

I have a Spring MVC 4 application deployed in tomcat. It works fine. I have to clone this app to have several applications with same behaviour but different configurations: database instance and folders for file management. Each for different customers. When I deploy de original application to Linux Tomcat it works fine (https://hostname:8443/app1).
Then I change the db connection settings (database name, username, and folders to manage some generated files) and change the name of the artefact to customername. But when I get into the application, it shows the login page right, but when login into the app, I'm getting the following error:
Status HTTP 500 - Request processing failed; nested exception is org.apache.tiles.request.render.CannotRenderException: java.io.IOException: JSPException including path '/WEB-INF/layout/header.jsp'
javax.servlet.ServletException: File [/WEB-INF/layout/header.jsp] not found
when accessing to https://hostname:8443/customername, which it's part of tiles template. Files exist in the deployed application, It's able to reach the login page, so it seems to be resolved the tiles config, but I don't know why is not able to reach the jsp files. It's working fine in local windows without secure Tomcat (port 8080).
EDITED
If I change the name of customername.war to app1.war it's working fine. Anybody knows where the war file keep a reference to the base application app1? It seems that there a reference to app1 in somewhere that makes that If I change the application name (artifact id) it does not reference to customername path.
Seems that it's a context root issue. I have changed it in STS (Project > Properties > Web Project Settings > Context root), deployed on Tomcat but still not working. It's supposed that only with changing the war file name, the context root of the application should be updated, but it's not working.
Upgrading Tomcat from 8.0 to 8.5.5 solves the issue. I don't know why, but there's an issue in 8.0 because no way to force context root for an application, not context.xml application file neither other configuration.
Just upgrade to 8.5.5 and deploy applications without context issue.
BR

Resources