I don't know why it is not working.
I am trying to accept multipart-formdata in my servlet but request.getPart("") is not showing. I am using glassfish 3.1.2 server. Tha framework used is vaadin for developing application. Can any one help me to fix this problem?
Assuming that your concrete problem is indeed that your IDE didn't show the getPart() method on autocomplete, then that can only mean that the project is not configured as a Servlet 3.0 compatible project. That method was namely introduced in Servlet 3.0.
You didn't tell anything about which IDE exactly you're using and your question history doesn't give any clues as well, so let's assume that it's Eclipse which is rather widely used. In that case, you need to configure it at 2 places, provided that you've correctly associated the Dynamic Web Project with a Servlet 3.0 compatible container as Targeted Runtimes in project's properties (otherwise HttpServletRequest and consorts wouldn't have compiled at all):
In the Project Facets section of project's properties, the Dynamic Web Module version must be set to 3.0.
If your IDE has generated a /WEB-INF/web.xml file, then you need to make sure that its <web-app> root declaration also matches Servlet 3.0, otherwise it would still fail during runtime.
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>
I had the same problem. Here's what eventually turned out to be the problem for me. I had a dependency on:
<dependency>
<groupId>com.googlecode.jsontoken</groupId>
<artifactId>jsontoken</artifactId>
<version>1.1</version>
</dependency>
And it turned out jsontoken has a dependency on servlet-api 2.5. So what fixed the problem was simply this:
<dependency>
<groupId>com.googlecode.jsontoken</groupId>
<artifactId>jsontoken</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
This worked for me
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
To those that stumble on this later, if the resolution suggested by BalusC does not resolve the problem for you please check your build path for provided libraries whose runtime does not match the runtime of your server.
For example if your maven pom.xml contains entries that provide java EE libraries like so...
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>javaee-api</artifactId>
<version>5.0-1</version>
<scope>provided</scope>
</dependency>
... they can interfere with what your IDE perceives as the runtime environment, which will be used to provide code completion suggestions.
The easiest way to track the problem is to figure out where the HttpServletRequest class is sourced from.
maven.. pom.xml.. modify this dependency
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
servlet api 2.5 is not work
I had the same problem, I want to share it with you in case anyone else bumps in the same problem:
In my case I had a j2ee.jar which was automatically downloaded and its version was probably old. It was located under Libraries --> j2ee Runtime Library (stackoverflow doesn't let me add an image so in eclipse - in Project Explorer - expand the project --> Java Resources --> libraries --> J2ee Runtime Library --> j2ee.jar)
I went to the file system where this file was located (you have the location next to the file in eclipse) and replaced it with a newer jar. You can take the jar from here.
Then clean and rebuild the project.
One possible reason, as pointed out in Bjørn's answer, is a conflicting artifact servlet-api (Servlet 2.5 spec).
In my case it was this dependency
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
<version>1.30.10</version>
To find out which dependency compiles the conflicting library just build and print the dependency tree with:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
Part of the output:
Finally exclude the artifact from the dependency
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
<version>1.30.10</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Hi friends I too faced simillar problem and I will tell you what I did.
I'm using eclipse juno and Tomcat 7 server. Make sure you use latest servlet API jar. Tomcat 7 will only support dynamic module version 2.5 not more than that. So use higher Tomcat version or lower dynamic module version then it will work.
One more thing: open your servlet api jar and see whether it contains "Part" you can easily check it.
Related
The current Quarkus 1.0 release uses Flyway 6, whose CE is not supporting some older database versions.
I tried to exchange in the pom file the default Flyway version of the quarkus-flyway artifact with an older Flyway release, but Quarkus then crashes on startup with some flyway-fluent...-method-not-found exception.
Would there be some easy way to accomplish switching Flyway releases?
Due the build time nature of a lot of Quarkus extensions, changing the version of the dependency may or may not work.
If you use maven, you can custom flyway verions in pom.xml, like this:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-flyway</artifactId>
<!-- exclude flyway-core -->
<exclusions>
<exclusion>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>'custom version you want'</version>
</dependency>
I am using Spring boot version 2.2.0.M4. When I am adding dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
while starting server it fails to start with below mentioned error
APPLICATION FAILED TO START
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator.<init>(DiscoveryCompositeHealthIndicator.java:42)
The correct way of working with Spring Cloud projects versioning is using the dependencyManagement plugin and release trains versions rather than passing versions of separate artifacts manually.
You can get a correct pom generated automatically (with all the correct versions) at start.spring.io.
On the date that question was posted, a version of Spring Cloud supporting Spring Boot 2.2.x has not been released yet. The latest Spring Cloud release version available is Greenwich.SR2, that supports Spring Boot 2.1.6.RELEASE.
UPDATE: Spring Cloud Hoxton.M1 that supports Spring Boot 2.2.0.M4 was released on 3rd July 2019. You can now use it and also generate correct build files with this version from start.spring.io.
For the following dependency:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
The Following spring cloud version worked for me.
<properties>
<java.version>11</java.version>
<spring-cloud.version>Hoxton.SR4</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I tried to google this, looking for code examples but I had no luck.
Anyone knows a place where I can find a tutorial or just examples on how to use Imagej in Java to open and process images?
I was able to get ImageJ in a Jar
What I'd like to do is make a simple image difference processor
Thanks for your help and time
There are two major versions of ImageJ you can program against: the original ImageJ 1.x, and the still-in-beta ImageJ2.
Either way, I strongly suggest structuring your code as a Maven project. By doing this, you avoid manually managing JAR files, and can develop your project in any Maven-enabled IDE (Eclipse, NetBeans, IDEA, etc.) or from the command line.
The ImageJ artifacts (for either v1 or v2) are not yet available on Maven Central, but will be soon. Until then, you'll need to add a <repository> reference to maven.imagej.net. Here is a sample snippet for your pom.xml:
<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>1.15</version>
</parent>
...
<dependencies>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
<version>${imagej1.version}</version>
</dependency>
</dependencies>
...
<!-- NB: for project parent -->
<repositories>
<repository>
<id>imagej.releases</id>
<url>http://maven.imagej.net/content/repositories/releases</url>
</repository>
</repositories>
Or if you want to depend on ImageJ2:
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij-app</artifactId>
<version>${imagej.version}</version>
</dependency>
For documentation of ImageJ1, ImageJ2 and related projects including many of their dependencies, see the javadoc at:
http://javadoc.imagej.net/
For tutorials on how to use ImageJ2, see:
https://github.com/imagej/imagej-tutorials
And for more information on programming against ImageJ1, see:
http://imagej.net/developer/
i am trying to build my first servlet using maven but don't know what i should add to the POM so the servlet
I have tried to add the below dependencies to the POM file (I found in one of the posts). The addition enables me to compile my servlet but when i try to run mvn package or to test my JUnits i am getting a ClassFormatError:
Initial SessionFactory creation failed.java.lang.ClassFormatError:
Absent Code attribute in method that is not native or abstract
in class file javax/validation/Validation
The pom.xml is:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<repository>
<id>java.net2</id>
<name>Repository hosting the Java EE 6 artifacts</name>
<url>http://download.java.net/maven/2</url>
</repository>
can someone explain and guide?
Thanks
:-)
At the outset, you may want to follow Senthil's comment above.
As for the error, it is because the specified dependency only has the APIs (method definitions) and not the implementation.
Typically, the implementation is provided by the app server. Hence the application should work in an app server which implements Java EE 6 (like Glassfish).
mvn package should not give any error - it is the test phase before packaging which fails, which you can circumvent, if interested using mvn package -DskipTests.
I have a maven project with flex-mojos 3.1.0. Can I have a module with swf packaging and configure a dependency on it in another module? When I do, I get a compilation error.
project
| - module1:swf
| - module2:swf
module2/pom.xml:
<parent>
<groupId>com.mygroup</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.mygroup</groupId>
<artifactId>module1</artifactId>
<version>1.0-SNAPSHOT</version>
<type>swf</type>
</dependency>
</dependencies>
Seems to be impossible
If you need module-to-module dependency to ensure correct build order for your modules then you can simply create a parent pom for both modules and arange build order in it.