I am moving a Struts 1.3.10 webapp to OpenShift.
To get started I have moved just the login page stuff to OpenShift. It works perfectly on my development machine but on OpenShift, the login page input field labels show like this:
???en_US.label.login???
The labels are in a resource file called MessageResources.properties.
I tried creating a resource file called MessageResources_en_US.properties but it made no difference.
I also tried this:
rhc env-set -a testdb LC_ALL=en_GB.UTF-8
But that made no difference either.
Any ideas?
I know it's something to do with locale...
The solution was to move MessageResources.properties from /src/main/java to /src/main/resources.
Simples...
Related
I have a spring boot application that runs very well, But after generating a war file so as I can run the application on separate tomcat server not the embedded one, I am unable to access some pages and files. I have rename the generated war file to mywarfile.war .This qusetion has two separate relate issues.
First issue-Access a linked page
Below is the link inside index.html that will lead to a method that will perform some code then leads to all.html
<button class="btn btn-secondary"> View Welding Product Record </button>
Method
#GetMapping("/all")
public String getAllProducts(Model model){
//.....codes
return "all"
}
Everything works fine with embedded tomcat with spring boot, but when click the link with the war file deployed to separated tomcat server it redirects to http://localhost:8080/all and shows below error.
HTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/all] is not available
Description The origin server did not find a current representation
for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.65
The mywarfile.war is placed on C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\mywarfile.war
But if I type manual on url http://localhost:8080/mywarfile/all I can access the page. What could be the cause of this. And How can I fix it.
Second issue - Access images
I have a background image in my index.html that can be accessed before generating the war file, But after generating the war file and run it on separate tomcat server I cannot see the image.
Below is the code in index.html
<style>
body{background-image: url('/images/ocean.jpg');}
<style>
This is the structure of how I store the images in my project
\src\main\resources\static\images\ocean.jpg
what could be the cause of this and how can I solve it. Thanks in advance
I know this question has answered many a time with most useful answer as below,
Where to place and how to read configuration resource files in servlet based application?
However, We have some special requirement as below,
Webapp will be deployed to tomcat.
Normal java app in form of .jar will be placed under folder /myapp
myappConfig.property file will be placed under /myapp
Directory Structure on client machine
/myapp
/myapp.jar
/assests/myappConfig.property
/tomcat/webapps/myapp.war
Basically myapp.jar and myapp.war will access sql db connection values for MySql database connection and db operations.
Accessing myappConfig.property from myapp.jar --> Working fine
File jarPath = new File(Myapp.class.getProtectionDomain().getCodeSource().getLocation().getPath());
String propertiesPath = jarPath.getParent();
System.out.println(" propertiesPath-" + propertiesPath);
mainProperties.load(new FileInputStream(propertiesPath + "\\assets\\myapp.property"));
Can anyone help/suggest how to implement,
Accessing myappConfig.property file from mywebapp,
provided run time change in myappConfig.property file does not required myapp.war to be redeployed
Thanks for your help in advance.
edit
Below is the steps in which we want to deliver the project to client.
Below is my app directory
/myapp
/myapp.jar
/assests/myappConfig.property
/tomcat/webapps/myapp.war
pack everything in one package with some packaging tool.
Run this package in client machine at any location and it will have same directory structure as above
Here, I do not want to hard code any location in webapp or tomcat for "/assests/myappConfig.property"
Normal Java app I can read property file but for wepapp I am not getting clear idea for how to do that?
You can add a <context> to tomcat/conf/server.xml (in this example, linux path):
<Context docBase="/home/yourusername/tomcat/assests" path="/assets" />
If you are using Windows:
<Context docBase="C:\path\to\myapp\assets" path="/assets" />
And then you can access it like any other resource within your webapp (e.g.: /assets/myappConfig.property).
If you are using JDBC for example, you could store the connection properties in a Singleton and request it from there, and that class could take care of change checks on that file.
I am currently working on a weblogic 10 application server that has several installed ears. I got a request to change the application name of some aps as they appear in
Home >Summary of Deployments
I went to the appropiate Plan.xml and changed the with the appropriate name, restarted the domain but the name did not change.
Any ideas?
You can do that easily by modifying config.xml file in
DOMAIN_NAME/config
You can just modify the name and restart the server.
<app-deployment>
<name>jms-rename</name>
<target>DefaultServer</target>
<module-type>ear</module-type>
<source-path>C:\JMSTest\application\jms\target\jms-0.0.1-SNAPSHOT.ear</source-path>
<security-dd-model>DDOnly</security-dd-model>
</app-deployment>
The answer was very simple in the end. I added inside the EAR's manifest file the following entry
Weblogic-Application-Version: x.y.z
In this way I didn't have to mess up with any of the Weblogics configuration files.
I have created sample web application, packaged it into WAR, then put it into webapps folder into jetty. And it does not work.
Proof, windows from top to bottom:
1) The content of GreetingController.java
2) The compiled file is present inside WAR file in appropriate place
3) The web application is working, it's name is recognized (folder content displayed)
4) Controller is not working and it's name is not recognized
What else to check?
UPDATE
My WAR file: https://www.sendspace.com/file/mb94jt
I think you are missing something in your app. The page you are referring is just a guide to help understand how the framework works. For complete simple examples, please refer to:
https://github.com/javalite/activeweb-bootstrap - this is a simple app with Bootstrap and no database support
https://github.com/javalite/activeweb-lessc - simple app without database, but with Less instead of CSS
https://github.com/javalite/activeweb-simple - simple ActiveWeb + ActiveJDBC webapp (CRUD)
Here is the Getting Started page: http://javalite.io/getting_started_activeweb
hope it helps
I m new in Struts2. Creating a hello world program using struts. When I run it got first screen where i put my input but when click on submit button giving following error.
Source of this helloworld example: http://www.tutorialspoint.com/struts_2/index.htm
HTTP Status 404 - /HelloWorldStruts2/hello
type Status report
message /HelloWorldStruts2/hello
description The requested resource (/HelloWorldStruts2/hello) is not available.
Apache Tomcat/6.0.29
Suggest what is the issue?
Got the solution.
In index.jsp there was <form> tag. When I changed it to <s:form> its working fine.
Or change from
<form action="hello">
to
<form action="hello.action">
This is what worked for me, specific to the question. Tomcat 8 was used:
Make sure you have created the classes folder under WebContent\WEB-INF.
In that create the logging.properties file and add the following content to it. (It doesn't matter if the file jumps on its own to Java Resources > Libraries) :-
org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = \ java.util.logging.ConsoleHandler
Then in the location of Tomcat's webapps folder delete your HelloWorldStruts2.war file.
Now follow the site's instructions to Export your project to a new HelloWorldStruts2.war file (remember to overwrite the existing .war file with the same name if it's there).
Again, deploy this file by copying it to your Tomcat directory's webapps folder.
In the browser, go to http://localhost:8080/HelloWorldStruts2/index.jsp again, though I'm not sure it will work for sure this time.
But this time, watch the Tomcat server application's verbose output. You will get some kind of exception like this (leave out Warnings for now):
30-Mar-2014 17:39:29.273 SEVERE [localhost-startStop-7] org.apache.catalina.core.StandardContext.filterStart Exception starting filter struts2 java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:213)
at org.apache.struts2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:102)
...
Seeing this, what I did immediately was copy the commons-lang3-x.y.z.jar to the WebContent\WEB-INF\lib folder, and then exported and deployed the project again.
This time, again the page wasn't showing, so I watched the logs and found out that Tomcat did not explicitly clear the contents of the webapps\HelloWorldStruts2 folder.
After deleting both HelloWorldStruts2 and HelloWorldStruts2.war and refreshing the index.jsp page in the browser, my project did work fine!