Closed ChristianLoza closed 3 years ago
Try to register the multipart feature in your Application:
@Override
public Map<String, Object> getProperties() {
Map<String, Object> props = new HashMap<>();
props.put("jersey.config.server.provider.classnames", "org.glassfish.jersey.media.multipart.MultiPartFeature");
return props;
}
Hello, thank you very much for your answer, I tried the following codes:
i had same error: @Override public Set<Class<?>> getClasses() {
final Set<Class<?>> resources = new HashSet<Class<?>>();
resources.add(MultiPartFeature.class);
resources.add(Example.class);
return super.getClasses();
}
when added getProperties():
@ApplicationPath("api")
@SwaggerDefinition(info = @Info(title = "SDP-EPIS", version = "v1.0.0"))
@CrossOrigin
public class ServiceResource extends Application {
@Override
public Map<String, Object> getProperties() {
Map<String, Object> props = new HashMap<>();
props.put("jersey.config.server.provider.classnames", "org.glassfish.jersey.media.multipart.MultiPartFeature");
return props;
}
}
I had next error,
,UNAVAILABLE} {} java.lang.NoClassDefFoundError: org/glassfish/jersey/server/internal/inject/AbstractValueFactoryProvider at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at com.kumuluz.ee.loader.EeClassLoader.findJarClass(EeClassLoader.java:399) at com.kumuluz.ee.loader.EeClassLoader.loadClass(EeClassLoader.java:468) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.glassfish.jersey.media.multipart.internal.FormDataParamInjectionFeature.configure(FormDataParamInjectionFeature.java:66) at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:728) at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:736) at org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:647) at org.glassfish.jersey.server.ResourceConfig.configureMetaProviders(ResourceConfig.java:823) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:328) at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$1(ApplicationHandler.java:293) ...
I am not adding any additional jersey dependencies in my pom file this is my pom:
<dependencies>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-core</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-servlet-jetty</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-weld</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-jax-rs-jersey</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-jpa-hibernate</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-jta-narayana</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee.logs</groupId>
<artifactId>kumuluzee-logs-log4j2</artifactId>
<version>${kumuluzee-logs.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee.rest</groupId>
<artifactId>kumuluzee-rest-core</artifactId>
<version>${kumuluzee-rest.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee.cors</groupId>
<artifactId>kumuluzee-cors</artifactId>
<version>${kumuluzee-cors.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee.health</groupId>
<artifactId>kumuluzee-health</artifactId>
<version>${kumuluzee-health.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee.swagger</groupId>
<artifactId>kumuluzee-swagger</artifactId>
<version>${kumuluzee-swagger.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee.swagger</groupId>
<artifactId>kumuluzee-swagger-ui</artifactId>
<version>${kumuluzee-swagger.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-javamail-ri</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee.testing</groupId>
<artifactId>kumuluzee-arquillian-container</artifactId>
<version>${kumuluzee-arquillian-container.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
</dependency>
<!-- -->
<dependency>
<groupId>com.github.dozermapper</groupId>
<artifactId>dozer-core</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-maven-plugin</artifactId>
<version>${kumuluzee.version}</version>
<executions>
<execution>
<id>package</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I made a sample project here: https://github.com/kumuluz/kumuluzee-samples/tree/feature/restForm/kumuluzee-rest-form
It works just by adding feature registration and adding the jersey-media-multipart
pom dependency.
If it still does not help your case I suspect one of your dependencies is playing weird with jersey. Let me know to investigate further.
I was running tests as exploded from Intellij, running from packaged jar might be another thing that could be a culprit although not likely.
thanks @cen1 Thank you very much for your answers, I made the corresponding example and it worked, there were also some conflicts with other libraries
Hello I am trying to use FormDataContentDisposition and FormDataParam, but I get an error when I deploy the application, this error is possibly generated because the framework has the Application class from jax-rs extended. Is there a way that I can bypass this class? Or some alternative way so that this error is not displayed.