As per the given specs WAS9 is using JAVAEE 7 and related specs . I want to use servlet spec 3.0 due to some constraints . Is there any way to configure it . I am using plain profile (No liberty profile).
The constraints is I am having two servlets with same URL mapping which is not allowed in servlet spec-3.1.
As per give here I can use servlet spec 3.
How can I make WAS 9 to use servlet spec 3?
There is no way to make WAS 9 use the servlet 3.0 specification. You should change the URL pattern for the servlet mapping. If you use WebSphere Liberty then you could use either the servlet-3.0 feature or the servlet-3.1 feature in your server.xml. This would allow you on WebSphere Liberty to get the behavior you require.
Related
I've always worked in Symfony 2.2 and 2.8
Now glancing at the blog of the version 3.3 and I can't overcome the new feature of getting services by (fully qualified) class name:
// before Symfony 3.3
$this->get('app.manager.user')->save($user);
// Symfony 3.3
$this->get(UserManager::class)->save($user);
Before Symfony 3.3 the service container was a factory with the knowledge of how to instantiate the service class, with the great benefit of a factory: You can swith the old class to any other class, and as long as they both let's say implement the same interface, maybe you don't even have to touch anything else in your code. But if you ask for a service by class name, you have to refactor your whole code, and change the class name in every occurrence of the service. Either when directly accessing by $container->get() or by using typehint and autowire.
Considering these the old way service aliasing seem much more practical or am I just missing something? I know you still can use it the old way, I'm just wondering in what cases could one benefit from preferring this new method instead the classic one.
One of the main points about the new style of service naming it to avoid asking for services by name directly from the container. By typehinting them all (and having them instead created by the framework), then any service that is not being used at all (and is private, so not get-able), can be removed. Anything that is hinted via the container and does not exist will immediately fail on the container building step as well - it would not be possible to rename a service and forget to also change all the other uses of it.
With so much being injected into the controllers (or a controller action) as well, unit testing the services, and even controllers is also more controllable - there wouldn't be any other things that are being pulled from the container within a test.
As for the transition, because of the container compilation step, Symfony is very good about being able to say if there is anything wrong, or at least deprecated. It's not hard to mark all the current services as public with just a small Yaml snippet at the top of each services.yml file (or anywhere else they are defined).
It will be a while until most of the 3rd party bundles and other supporting libraries will be fully 4.0 compatible, but it was also the case for the breaking changes between 2.8 & 3.0. This is a large part of the reason why 2.8 & now 3.4 are long-term-supported versions - with 3.4 supported to November 2021, giving plenty of time to upgrade away from the deprecations and update the 3rd party bundles.
I am trying to deploy the spring osgi application in IBM Websphere liberty server using gemini blueprint virgo DM. While deploying the application, I am facing the below error, says " ....PackageAdmin service is required . Can anyone has an idea on this?
java.lang.IllegalStateException:
org.osgi.service.packageadmin.PackageAdmin service is required at
org.eclipse.gemini.blueprint.io.internal.resolver.PackageAdminResolver$1.run(PackageAdminResolver.java:179)
at
org.eclipse.gemini.blueprint.io.internal.resolver.PackageAdminResolver$1.run(PackageAdminResolver.java:174)
at java.security.AccessController.doPrivileged(Native Method) at
org.eclipse.gemini.blueprint.io.internal.resolver.PackageAdminResolver.getPackageAdmin(PackageAdminResolver.java:174)
at
org.eclipse.gemini.blueprint.io.internal.resolver.PackageAdminResolver.getImportedBundles(PackageAdminResolver.java:67)
at
org.eclipse.gemini.blueprint.io.OsgiBundleResourcePatternResolver.findClassPathMatchingResources(OsgiBundleResourcePatternResolver.java:217)
at
org.eclipse.gemini.blueprint.io.OsgiBundleResourcePatternResolver.findResources(OsgiBundleResourcePatternResolver.java:154)
at
org.eclipse.gemini.blueprint.io.OsgiBundleResourcePatternResolver.getResources(OsgiBundleResourcePatternResolver.java:186)
at
org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext.getResources(AbstractOsgiBundleApplicationContext.java:439)
at
org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext.getResources(ServerOsgiBundleXmlWebApplicationContext.java:346)
at
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:270)
at
org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:248)
at
org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:87)
at
org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1411)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1401)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:172)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:142)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
... 25 more
Starting from fixpack 8.5.5.9 of Liberty, PackageAdmin will not be available to the application region unless you create a custom Liberty feature that exports the package admin service using the IBM-API-Service header.
Create a Liberty feature as explained in this article
Make sure that the feature exports PackageAdmin as in the example below
Declare your custom feature to server.xml using usr:myfeature
Subsystem-ManifestVersion: 1.0
IBM-Feature-Version: 2
IBM-ShortName: myfeature
Subsystem-SymbolicName: myfeature;visibility:=public
Subsystem-Version: 1.0.0
Subsystem-Type: osgi.subsystem.feature
Manifest-Version: 1.0
IBM-API-Service: javax.xml.parsers.SAXParserFactory,
org.osgi.service.packageadmin.PackageAdmin,
org.osgi.service.cm.ConfigurationAdmin
According to the description of a defect fix in 8.5.5.9 fixpack, IBM made this change because Liberty was leaking its own services to the application, so now the OSGi services registered by Liberty are not visible to the application unless you create a feature like the one below to export explicitly those that you need.
Literally, is it possible to make file upload without using commons-fileupload.jar in spring framework?
(if so, how can I make without it?)
Yes, it's possible. In Servlet 3.0 environment you can use StandardServletMultipartResolver. See Spring documentation for more info: http://docs.spring.io/spring-framework/docs/4.3.x/spring-framework-reference/html/mvc.html#mvc-multipart-resolver-standard
I have an embedded jetty in karaf in my application. I need to add the default servlet parameter accept-ranges as bytes. Can I add into the org.ops4j.pax.web.cfg file. If yes than what should be the property? I referred this link but couldn't find the valid property name and its value. If not what is the other alternative approach to add the default servlet parameters into the embedded jetty of karaf
As Pax Web is a mediation layer on top of a variety of Serlvet Containers, like Jetty, Tomcat and Undertow to help people use those within an OSGi environment, the default servlet isn't one provided by the underlying Serlvet Container but of PaxWeb itself. So it's a bit tricky to add those parameters to the ResourceServlet.
It's usually better to define your own Serlet which listenes on "/"
In order to write servlets code I need servlet-api.jar.
Where do i get servlet-api.jar from ?
Make sure that you're using the same Servlet API specification that your Web container supports. Refer to this chart if you're using Tomcat: http://tomcat.apache.org/whichversion.html
The Web container that you use will definitely have the API jars you require.
Tomcat 6 for example has it in apache-tomcat-6.0.26/lib/servlet-api.jar
Grab it from here
Just choose required version and click 'Binary'. e.g direct link to version 2.5
You may want to consider using Java EE, which includes the javax.servlet.* packages. If you require a specific version of the servlet api, for instance to target a specific web application server, you will probably want the Java EE version which matches, see this version table.
You can find a recent servlet-api.jar in Tomcat 6 or 7 lib directory. If you don't have Tomcat on your machine, download the binary distribution of version 6 or 7 from http://tomcat.apache.org/download-70.cgi