I'm using Mule 3 to query a database using JDBC, and I'd like to modify the query depending on input from a .properties file. I have this in my xml...
<context:property-placeholder location="C:\path\to\file\settings.properties" />
Getting the following exception...
Exception in thread "main" org.mule.module.launcher.DeploymentInitException: SAXParseException: The prefix "context" for element "context:property-placeholder" is not bound.
Do I need to include some special .xsd file?
Add the xmlns namespace prefix and schema location to your Mule config mule element tag.
Prefix:
xmlns:context="http://www.springframework.org/schema/context"
SchemaLocation:
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
It should look like as below.
Eg:
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.3/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.3/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
<context:property-placeholder location="C:/path/to/file/settings.properties" />
........... Other stuff
</mule>
I had the same issues and fixed it. Here what I did.
Kept all .properties under src/main/resources
< context:property-placeholder location="file.dev.properties,file.stage.properties" />
Keeping all the files in classpath was a challenge. So Goto your project folder, Open .classpath file in text pad and add the below line
< classpathentry
including="file.dev.properties|file.prod.properties|file.stage.properties"
kind="src" path="src/main/resources"/ >
Save, refresh and it works.
Use the following xsd in xsi:schemaLocation --
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
The other answers covered the namespace issue, but I'll add that I found that the context:property-placeholder tag needed to be between "spring:beans" tags. Here's an example that presumes that the properties file sets a property named "jmsBrokerURL":
<mule xmlns="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<spring:beans>
<context:property-placeholder location="C:/path/to/file/settings.properties" />
<spring:bean name="myConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<spring:property name="brokerURL" value="${jmsBrokerURL}" />
</spring:bean>
</spring:beans>
<flow name="MyFlow" doc:name="MyFlow">
<!-- Flow configuration here. -->
</flow>
</mule>
An alternate method of reading properties (and one I prefer) is to use the Spring "util:properties" tag to read properties into a Properties bean which you then refer to using Spring EL. Watch out in this case that you use the Spring EL "#{}" notation instead of "${}" to reference the object and its variables. Here's the above example modified for that technique:
<mule xmlns="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<spring:beans>
<util:properties id="myConfig" location="C:/path/to/file/settings.properties" />
<spring:bean name="myConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<spring:property name="brokerURL" value="#{myConfig.jmsBrokerURL}" /> <!-- Note the pound (hash) symbol. -->
</spring:bean>
</spring:beans>
<flow name="MyFlow" doc:name="MyFlow">
<!-- Flow configuration here. -->
</flow>
</mule>
I like this latter approach mainly because I can deal with multiple properties files and included application context files more easily. The context:property-placeholder tag can be problematic when dealing with either multiple property files or when including an application context file within another.
Just put the properties file under resource folder and
Use this " classpath:settings.properties " in the property-placeholder and it will work ...
Related
i am a complete beginner in java world, i want to start building an JAX-RS endpoint so i am using Intellij with glassfish/tomcat application servers.
after i run my server, i tried all the urls like
http://localhost:8080/Demo-1.0-SNAPSHOT/api/hello-world
http://localhost:8080/Demo-1.0-SNAPSHOT/hello-world
and it didn't work.also i tried with tomcat, same problem. it would be nice if someone help me unblock this problem.
here is my project and its configuration :
https://i.imgur.com/oG0TqXG.png
https://i.imgur.com/qiOOunQ.png
I think you need a web.xml under src/main/webapp:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<session-config>
<session-timeout>
15
</session-timeout>
</session-config>
</web-app>
And you can put the beans.xml in the same Folder.
I'm using WebLogic 11g server, OIM (Oracle identity Manager), and I created a new web application on Wicket 6 as a module. When I execute my application in WebLogic server http://192.168.112.31:7001/WicketReport I receive a 403 Error.
My web.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Wicket Web Application</display-name>
<filter>
<filter-name>Application</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>kz.ecc.wicketreport.pages.Application</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Application</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file/>
</welcome-file-list>
</web-app>
I couldn't find any tutorial or instructions that describe how to do this. Please show me what I need to do or some steps to achieve it.
UPDATE
I tried to add:
<login-config>
<auth-method>CLIENT-CERT,BASIC</auth-method>
<realm-name>myRealm</realm-name>
</login-config>
after </welcome-file-list> in my web.xml but I still receive the 403 Error.
I'm having a really strange problem (at least it is strange because it has worked for me in the past) with a Silverlight Application consuming WCF services.
When I debug both Silverlight Application and WCF in localhost it works perfect. When I publish both projects, they work perfect. The problem is when I try to debug the Silverlight Application against published WCF... it throws the typical crossdomain exception.
I promise I've both clientaccesspolicy.xml and crossdomain.xml uploaded into the root path in server.
Looking in fiddler, it doesn't even try to read the clientaccesspolicy file before crashing.
Do you have any idea??? Thanks in advance.
Put these files inside your service folder
clientaccesspolicy.xml
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
my silverlight site is running in https port, when i try to access some handler in my site it searches for crossdomain.xml and clientaccesspoliy.xaml
the problem is it always searches crossdomain in https://ipaddress//crossdomaim.xml
so when i debug with fiddler it shows HTTP Error 404.0 - Not Found.
client accesspolicy.xml
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
First, get rid of the crossdomain.xml file as you only need clientaccesspolicy.xml for Silverlight (and it has more features).
Second, the file must be in the root of the https site, as that is not the same as the http site (I assume you have placed the file on your http site only). You need in on both sites if both the http and https sites are accessed by your app.
Thirdly, if you are still having problems, add https explicitly to the config. e.g. with
<allow-from>
<domain uri="http://*">
<domain uri="https://*">
</allow-from>)
This page on Network Security Access Restrictions in Silverlight has more detail of the options
Try This crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<!--<allow-http-request-headers-from domain="*" headers="SOAPAction,Content- Type"/>-->
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
I have created a wcf service that i have uploaded to my host (using IIS). Everything works fine.
So, if i go to http://www.mydomain.com/path/Service.svc it works fine.
If i go to http://mydomain.com/path/Service.svc i get a resource not found error.
I have created a clientaccesspolicy.xml under the path folder which contains the following:
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="http://*"/>
<domain uri="http://www.mydomain.com/path/*" />
<domain uri="http://mydomain.com/path/*" />
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
but it doesnt seem to have any effect. Have looked on the web but didnt find a decent explanation on how this is solved. Any ideas?
Thank you.
You should to add more host headers on IIS. Take a look here: How to Create Multiple Websites with one IP address