Cannot find message resources under key org.apache.struts.action.MESSAGE in struts - struts

I am getting the following error in the browser window :
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
I have included the resource file in the struts-config.xml using
And my resource file is stored as WEB-INF/classes/Application.properties file.

Well this is an old post, but my answer can help, I guess...
I personally wasted some time to make work a poject that had been developped under Tomcat 5.5 under Tomcat 7.
Note : You should name your ressource file : "ApplicationResources"...
There is several reasons why it wouldn't work, but the most common answer I found on the net was : put the line
<message-resources parameter="ApplicationResources" null="false" />
in your "struts-config.xml".
In my case, this line was already present, and this was the contrary : I had to remove it and replace at the "web.xml" file level by :
<context-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</context-param>
in the "servlet" tag.
I'm sorry that I don't have a valuable explanation for this, but my application behaves just fine now.
Does anyone has (an explanation) ?

This happened to me because I was converting my project to maven and my resources directory was not correct.
I had struts-config.xml like this:
<message-resources parameter="messages.appResources" null="false"/>
My pom.xml was like this:
<resource>
<directory>src/main/resources</directory>
</resource>
But my messages folder was in my project root. So I moved it to:
${project.basedir}/src/main/resources/messages

Make sur that you are using the same version of the DTD in the header of struts-config.xml:
I had this error when using two differents versions:
//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
and the Pb was solved once the correction made:

An XML might be missing...
In which context is your application running ? Tomcat ? JBoss ?
Try including xalan and xerces dependencies.

The following solved my problem:
In Struts Config, include:
(At the top)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<message-resources
parameter="common.properties.Common" /> (or the path to your resources file)
This error seems to be caused by a lack of a path to message-resource in struts-config.xml
and the DOCTYPE definition at the top of the same.

you should put this line in your struts-config.xml
< message-resources parameter="ApplicationResources" null="false" key="ApplicationResources" />

In my case problem was fixed after delete all unnecessary attributes from message-resources element in struts-config.xml file. Just like following:
<message-resources parameter="ApplicationResources"/>

Related

How do I change the default location for mule application log files?

I would like to change the log directory from MULE_HOME/logs to MULE_HOME/logs/apps. The only place I have found that refers to a file path is in MULE_HOME/conf/wrapper.conf. Editing the wrapper.logfile does allow me to relocate the mule_ee.log file, which seems to be the Mule application log, but I'd like to include Mule application logs there, too. If I create an application called FOO and deploy it to the runtime environment, it will create a file called MULE_HOME/logs/mule-app-FOO.log, but changing the location seems to be difficult short of completely messing things up writing custom log4j2 XML files.
If you have Mule version 3.6+, then it is recommended to use log4j2.xml instead of log4j.xml.... Using log4j2 you can change the path and get your application log ... a simple example would be :-
<RollingFile name="RollingFile" fileName="${env:MULE_HOME}/logs/${sys:CustomapplicationName}.log"
filePattern="${env:MULE_HOME}/logs/${sys:CustomapplicationName}-%d{yyyy-MM-dd}-%i.log"> <!-- CustomapplicationName is set at mule-app.properties or in VM argument in Run As Configure as -DCustomapplicationName=Log4j -->
<PatternLayout>
<pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="120 KB" />
</Policies>
<DefaultRolloverStrategy max="1" />
</RollingFile>
Just put this above code in your log4j2.xml in src/main/resource folder
Here in above you can see that, you have configured your path of your log files by mentioning here:-
<RollingFile name="RollingFile" fileName="${env:MULE_HOME}/logs/apps/${sys:CustomapplicationName}.log"
filePattern="${env:MULE_HOME}/logs/apps/${sys:CustomapplicationName}-%d{yyyy-MM-dd}-%i.log">
where ${sys:CustomapplicationName} is the System variable set in mule-app.properties as following :-
CustomapplicationName=yourApplicationName
Right way is to have log4j properties / xml file for FOO application and have that define the desired path for FOO application log. This way will ensure mule_ee.log is not messed up and at the same time other applications too will have their own log files which will be easy to manage and easy to introspect specific application log in case of errors / exceptions
Define location in log4j.properties file.

IntelliJ Idea: Schemas and DTDs / configuring XML catalog

I have a lot of xml files in my project which are described with many xsd schema files.
XSD schemas use complex namespace structure and I want to configure IDE (IntelliJ Idea) to resolve URIs of these schemas on my local file system (https://www.jetbrains.com/idea/help/xml-catalog.html).
So I open Idea Settings, select Language & Frameworks -> Schemas and DTDs -> XML Catalog and point the path to xml-catalog.properties file with following content:
catalogs=xml-catalog.xml
relative-catalogs=yes
#verbosity=99
Next I create xml-catalog.xml file (in the same directory as the xml-catalog.properties file):
<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:oasis:names:tc:entity:xmlns:xml:catalog http://www.oasis-open.org/committees/entity/release/1.0/catalog.xsd"
prefer="public">
<rewriteSystem systemIdStartString="http://www.mycompany.com/schemas" rewritePrefix="file:///c:/Projects/MyProject/schemas"/>
</catalog>
I expect Idea will resolve all the schemas with prefix http://www.mycompany.com/schemas in my local directory c:/Projects/MyProject/schemas and uses them for validating and code highlighting. But all the URIs in the editor remain red...
Googling and playing with paths, URIs and directives in xml-catalog.xml gave no results for me...
Could anyone show me working XML catalog settings which help to resolve at least one URI or public/system or point me detailed manual of doing this?..
Per the OASIS XML Catalog specification [1] your example should work as follows:
http://www.mycompany.com/schemas/foo.xsd
rewrites to:
file:///c:/Projects/MyProject/schemas/foo.xsd
Have you tried using a 'rewriteURI' [2] instead of a 'rewriteSystem' [1] ?
Here is an example that we've been using extensively for several years at JPL. At least, I know this works reliably on linux & macosx; however, I don't make any claims about windows.
<?xml version='1.0'?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="public">
<rewriteURI
rewritePrefix="file:./www.omg.org/"
uriStartString="http://www.omg.org/"/>
</catalog>
With the Apache XML Resolver 1.2 library implementation [3], the above rewrites the following URI:
http://www.omg.org/spec/UML/20110701/UML.xmi
to:
file:./www.omg.org/spec/UML/20110701/UML.xmi
However, IntelliJ 14.1.3 says that the above is ill-formed; specifically, IntelliJ claims the attribute 'uriStartString' is not allowed and that 'rewriteURI' is missing the 'uriIdStartString' Attribute. That is, IntelliJ expects this:
<?xml version='1.0'?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="public">
<rewriteURI
rewritePrefix="file:./www.omg.org/"
uriIdStartString="http://www.omg.org/"/>
</catalog>
The Apache XML Resolver 1.2 library does not handle this form.
Who to trust: IntelliJ? OASIS? Apache XML Resolver?
It does not help that the OASIS XML Catalog spec 1.0 uses 'uriStartString' in [2] and Appendix B (non-normative) but 'uriIdStartString' in Appendix A (non-normative).
It would be great if Norm Welch could comment on this; after all he wrote the OASIS XML Catalog spec and has been involved in the Apache XML Resolver implementation.
[1] https://www.oasis-open.org/committees/entity/spec-2001-08-06.html#s.rewritesystem
[2] https://xerces.apache.org/xml-commons/components/resolver/resolver-article.html
[3] https://www.oasis-open.org/committees/entity/spec-2001-08-06.html#element-rewriteURI

Liquibase 3.2 not finding dbchangelog-3.2.xsd

Running version 3.2 I am getting an error
[WARN] liquibase - schema_reference.4: Failed to read schema document 'http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.2.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
When I look for http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.2.xsd it is not there, although http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd is.
I came accross this https://liquibase.jira.com/browse/CORE-1840, which I interpret to say you dont need access to the internet to get dbchangelog-3.2.xsd. It doesnt seem to help when the internet is available but the .xsd is not there.
I have reverted back to 3.1 but would like to know the root cause of my 3.2 problem.
Updating the liquibase version to the latest solved my problem
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.3</version>
</dependency>
I solved it by distributing the schema with my application and referring to it locally (relative path). In the example below I have the schema file in the same folder as the changelog.
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog-3.1.xsd">
<!-- all the things -->
</databaseChangeLog>
Liquibase does not looking for xsd in Internet. http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.2.xsd will be replaced to path to java recources
More detailed info can be find here
I fixed the issue following what found here.
The solution works only for the one using maven-liquibase-plugin.
You have to run liquibase migration with the following option -Dprefer.internal.xsd=true:
mvn -Dprefer.internal.xsd=true liquibase:update
Check your changlog.xml file headers having xsd document version.
If it doesn't match it will during spring boot:run

weblogic hot deployment working for jsps but not for web-inf/classes

I am deploying an ear application in weblogic 10.3 in exploded format with fast swap enabled and in dev mode.
The ear file contains a web app also in exploded format. The changes made to the jsps in the web app are getting reloaded. But the classes under web-inf when changed are not reloaded.
The weblogic deployment configuration is given below.
weblogic-application.xml content in ear/META-INF
<wls:fast-swap>
<wls:enabled>true</wls:enabled>
<wls:refresh-interval>10</wls:refresh-interval>
</wls:fast-swap>
<wls:classloader-structure>
<wls:classloader-structure>
<wls:module-ref>
<wls:module-uri>web.war</wls:module-uri>
</wls:module-ref>
</wls:classloader-structure>
</wls:classloader-structure>
application.xml content in ear/META-INF
<display-name>web-ear</display-name>
<module>
<web>
<web-uri>web.war</web-uri>
<context-root>/web</context-root>
</web>
</module>
<library-directory>lib</library-directory>
weblogic.xml content in war/WEB-INF
<wls:fast-swap>
<wls:enabled>true</wls:enabled>
<wls:refresh-interval>10</wls:refresh-interval>
</wls:fast-swap>
<wls:context-root>/web</wls:context-root>
<wls:session-descriptor>
<wls:cookie-max-age-secs>-1</wls:cookie-max-age-secs>
<wls:cookie-name>JSESSIONID_SQE_AAI</wls:cookie-name>
<wls:cookie-path>/</wls:cookie-path>
<wls:cookies-enabled>true</wls:cookies-enabled>
<wls:invalidation-interval-secs>120</wls:invalidation-interval-secs>
<wls:id-length>52</wls:id-length>
<wls:timeout-secs>7200</wls:timeout-secs>
<wls:url-rewriting-enabled>true</wls:url-rewriting-enabled>
<wls:persistent-store-type>memory</wls:persistent-store-type>
<wls:http-proxy-caching-of-cookies>false</wls:http-proxy-caching-of-cookies>
</wls:session-descriptor>
<wls:jsp-descriptor>
<wls:page-check-seconds>6</wls:page-check-seconds>
</wls:jsp-descriptor>
<wls:container-descriptor>
<wls:servlet-reload-check-secs>6</wls:servlet-reload-check-secs>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
Is the configuration done above right? Are there any config details I have missed to include here? What other settings or configurations should I check?
Any help would be very much appreciated thanks.
Even if you enable FastSwap in your application, the modules that are declared in the classloader-structure will not support FastSwap because they aren't loaded by the RedefiningClassLoader, but rather by the GenericClassLoader.
You can test this by printing the classloader of your classes under WEB-INF/classes and check if it's the com.bea.wls.redef.RedefiningClassLoader or not.
I struggled to make them work together, you can see more details here https://forums.oracle.com/forums/thread.jspa?threadID=2476484&tstart=60 but, unfortunately, no solution so far.
Regards.

Can't get nhibernate config section out though configuration manager

I'm trying to to setup Memcached 2nd level caching. I've followed what documentation I could find, including downloading the project from SVN and looking at how it is configured in their test project, and ended up with this in my app.config.
<configuration>
<configSections>
<section name="memcache" type="NHibernate.Caches.MemCache.MemCacheSectionHandler,NHibernate.Caches.MemCache" />
</configSections>
<memcache>
<memcached host="xx.xx.xx.xx" port="11211" weight="10" />
</memcache>
</configuration>
However, when the MemCache provider code in NHibernate.Caches.MemCache calls configurationmanager.getsection("memcache"), null is returned, which causes it to error out.
I have three projects, .UI, .Core, and .Data - the app.config is for .UI and .Data is where SessionFactory gets built and the code that wants to load this configuration section is launched. .Data has the Nhibernate.Caches.Memcache reference, and I've tried adding it to .UI, however that did not solve the issue.
What is incorrect about this configuration? Or perhaps is it something about my project? Does anyone have any experience at all with NHibernate.Caches.MemCache? There is not much information about it to be found via Google.
The issue ended up being some corruption with my app.config. Everything was right, but it was not being loaded by the assembly. I deleted and re-added it, and then it worked fine.