How to add mime type in web sphere liberty server? - websphere-liberty

How to add Mime type in web sphere liberty server. we are new to web sphere liberty server.

You can add new extensions and their corresponding mimetypes by appending the a section like the following to server.xml:
<mimeTypes>
<type>.bar=text/bar</type>
</mimeTypes>
I didn't have any luck overriding a built-in type this way.

Related

Relative Namespace - SOAP Call - Liberty

We are right now on WAS 8.5 and are trying to move to Liberty. Our applications are using a lot of SOAP calls and among them, there is a one that is using a relative namespace that is raising an exception. I know that using a relative namespace is not recommended but we are the client not the producer. There is a way to handle that in WAS 8.5 by adding the parameter "com.ibm.wsspi.wssecurity.dsig.relativeNamespaceAllowed=true".
Is there such a parameter in Liberty ? Otherwise, we are stuck.
Liberty changed it's JAX-WS implementation from what was used with WAS 8.5, and it doesn't support the same behavior that this property allows. That being said it might be possible implement it, if it's a requirement for your application I suggest opening a support ticket with IBM. There have been other JAX-WS behavioral differences that have been brought into Liberty for users that have requested it through support, and this might be such a case.

Migrating URLs from WebSphere Traditional Application Server to Liberty

I'm working on migrating a complex application to Liberty and it uses property files that use the WAS URL resource. Is there a way, without re-writing anything in the application so that it will run in Liberty? How can I define the URL in the server.xml ?
Did you try using jndiURL like this:
<jndiURLEntry jndiName="myFirstJNDIEntry" value='"file:///myDirectory/myConfigFile.properties"' />
And access it in code like:
#Resource(name="myFirstJNDIEntry")
private URL propsURL;
It is discussed in this Redbook Microservices Best Practices for Java and in documentation JNDI URL Entry (jndiURLEntry)

Where do you specify urls in a spring mvc project?

If we are calling an internal service we would look up its address from a service registry. But what if the service we are calling is external like some google api. What is the right place to declare the url? In the .net world we would define it in web.config but not sure what would be a good place to declare it in spring mvc.
If you are using Spring Framework
Good place to define all your static URLs would be in *.properties file.
Default one is application.properties
This file will be added in src/main/resources folder of project

Something like Spring's VelocityEngineUtils that can use URL to template

I'm using Spring and Velocity templates to send emails. The new request is that the templates are no longer stored locally, but fetched from an external service. VelocityEngineUtils expects a relative path to the template, but all I now have is an URL. While I'm aware that I can fetch and save the template locally before calling VelocityEngineUtils, I'm asking if there already is something in Spring that can help (as it often happens).
what velocity resourceloader you are using at the moment? I assume that you are using ClasspathResourceLoader?
If you need to get velocity template from an external service through a URL, you can specify the resource loader to org.apache.velocity.runtime.resource.loader.URLResourceLoader

Setting up a URL resource on WebSphere Application Server 7.0?

I need to setup a URL resource in WebSphere and is following this tutorial. However, the tutorial requires the modification of WebSphere's web.xml and ibm-web-bnd.xml using WebSphere Studio. I don't have a WebSphere Studio so I need to modify those files manually using a text editor. I tried to "search" for the 2 files but the "search results" are so many that I don't know which one is the right file.
Where can I find the 2 files? Also what value do I need to set for the resource-ref's id? I notice that WebSphere Studio doesn't have any text field for setting the resource-ref's but it has a value on its code view.
Thank you!
web.xml is a standard JavaEE file and its structure is well-documented in the Servlet specification. In web.xml, you declare the URL as it is known within your local JNDI namespace (java:comp/env).
web.xml should be located inside WEB-INF, underneath your WAR project structure. If you are using an IDE (such as Eclipse) to create Web projects, this file should already be created for you (unless you use Servlet Specification 2.5 and up - Servlet Specification 2.5 is included with JavaEE 5.0 - where deployment descriptors are optional).
ibm-web-bnd.xml is a WebSphere-specific file. It contains the binding of declared artifacts (such as a URL definition) into a real artifacts. You should refer to IBM's documentation in order to figure out the format of that file.
The ibm-web-bnd.xml file should be located in the same directory as web.xml.
The id attribute of resource-ref can be set to any value you like, as long as it is cross-referenced by a matching id attribute inside ibm-web-bnd.xml. That's how WebSphere can correlate definitions in ibm-web-bnd.xml to definitions in web.xml. The random string you see in the tutorial are created by RAD or WSAD; you can place any identifier there.
EDIT (added instructions)
In a nutshell, the process is this:
In web.xml, you define the local JNDI name. That would be the name by which your Java code is referring to the URL. For example, myWebsiteUrl. Your code will have to perform a JNDI lookup on java:comp/env/myWebsiteUrl. The definition is along these lines:
<resource-env-ref>
<resource-env-ref-name>myWebsiteUrl</resource-env-ref-name>
<resource-env-ref-type>java.net.URL</resource-env-ref-type>
</resource-env-ref>
In WebSphere itself, add a URL definition. The key there is the JNDI name in WebSphere's JNDI tree by which the URL will be known. You can set any value there, although it is recommended (by convention) that you prefix it with url/. For example: url/test.
In ibm-web-bnd.xml, you need to bind myWebsiteUrl (looked-up by your application) to url/test (which is the JNDI name by which WebSphere knows the URL). The definition will be along the lines of:
<resource-env-ref name="myWebsiteUrl" binding-name="url/test"/>
Step 3 is not required. If ibm-web-bnd.xml doesn't exist at deployment time, then the GUI-based deployment flow (used when you deploy applications through the WAS administration console) will prompt you for the binding values. (If you are deploying using scripting, you can still omit the ibm-web-bnd.xml file as long as you specify the bindings in a different way, but that's beyond the scope of this answer. Read the IBM documentation about strategy files and AdminApp.installApplication)
Note: as long as you use JavaEE 5.0 and up, you don't need the id attribute in the definitions. The article you're reading, by the way, is extremely outdated.

Resources