JBoss 10当我将XML更改为JSON格式以将数据从客户端发送到REST端点时我得到客户端java.lang.NoClassDefFoundError

时间:2017-05-10 10:59:27

标签: java json rest jboss

我正在尝试编写一个简单的REST端点(@POST),它接收在JSon中打包的类实例对象并将其添加到List中。 只要我使用XML格式,代码就可以正常工作,但是当我尝试将其更改为JSon时,会疯狂地返回有关缺少库的错误。 我尝试添加boss-deployment-structure.xml并排除库但它不起作用。我尝试手动将java.rs库添加到/ modules / org /文件夹,但同样,它不起作用。 我使用RESTeasy库,我不允许使用Jersey。

这是我尝试将Son对象发送到端点时收到的错误消息。它出现在客户端。

Exception in thread "main" java.lang.NoClassDefFoundError:     org/jboss/resteasy/resteasy_jaxrs/i18n/LogMessages
at org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.write.   To(ResteasyJackson2Provider.java:138)
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:129)
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:118)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100)
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.writeRequestBody(ClientInvocation.java:322)
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.writeRequestBodyToOutputStream(ApacheHttpClient4Engine.java:509)
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.buildEntity(ApacheHttpClient4Engine.java:475)
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.loadHttpMethod(ApacheHttpClient4Engine.java:374)
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:232)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:388)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.post(ClientInvocationBuilder.java:195)
at pl.edu.agh.kis.Main.sendData(Main.java:95)
at pl.edu.agh.kis.Main.main(Main.java:192)
Caused by: java.lang.ClassNotFoundException: org.jboss.resteasy.resteasy_jaxrs.i18n.LogMessages
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 14 more

当我在Wild fly 10上加载项目时,这是来自服务器的消息。那里有一些警告,但我在互联网上找不到如何解决野蝇警告我的问题。

/Applications/wildfly-10.1.0.Final/bin/standalone.sh
/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java -classpath "/Applications/IntelliJ   IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/lib/util.jar" -Dfile.encoding=UTF-8   com.intellij.rt.execution.CommandLineWrapper  /private/var/folders/zq/19w4ng_s3db2xlzgvgrv56wc0000gn/T/idea_classpath  com.intellij.javaee.oss.process.JavaeeProcess 51972 com.intellij.javaee.oss.jboss.agent.JBoss71Agent
 [2017-05-10 12:25:44,066] Artifact rest-ear:ear: Server is not connected. Deploy is not available.
Detected server admin port: 9990
Detected server http port: 8080
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /Applications/wildfly-10.1.0.Final

  JAVA:     /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

12:25:48,630 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
12:25:59,014 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
12:25:59,110 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting
12:26:00,633 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
12:26:00,670 INFO  [org.xnio] (MSC service thread 1-1) XNIO version 3.4.0.Final
12:26:00,680 INFO  [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.4.0.Final
12:26:00,712 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
12:26:00,718 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
12:26:00,721 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
12:26:00,716 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
12:26:00,752 INFO  [org.jboss.as.security] (MSC service thread 1-7) WFLYSEC0001: Current PicketBox version=4.9.6.Final
12:26:00,754 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
12:26:00,799 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
12:26:00,818 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0003: Undertow 1.4.0.Final starting
12:26:00,834 INFO  [org.jboss.as.connector] (MSC service thread 1-3) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.4.Final)
12:26:00,835 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
12:26:00,885 INFO  [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
12:26:00,885 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-5) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
12:26:00,919 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
12:26:00,931 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0018: Started Driver service with driver-name = h2
12:26:00,961 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 42.0)
12:26:00,964 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = postgresql
12:26:01,093 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path '/Applications/wildfly-10.1.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
12:26:01,181 INFO  [org.jboss.remoting] (MSC service thread 1-8) JBoss Remoting version 4.0.21.Final
12:26:01,268 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0012: Started server default-server.
12:26:01,277 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0018: Host default-host starting
12:26:01,469 INFO  [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
12:26:01,469 INFO  [org.jboss.as.ejb3] (MSC service thread 1-4) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
12:26:01,522 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
maj 10, 2017 12:26:01 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.4.0.Final
maj 10, 2017 12:26:02 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.4.0.Final
12:26:02,041 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-3) WFLYDM0111: Keystore /Applications/wildfly-10.1.0.Final/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
12:26:02,081 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) WFLYDS0013: Started FileSystemDeploymentService for directory /Applications/wildfly-10.1.0.Final/standalone/deployments
12:26:02,377 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-7) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.4.Final
12:26:02,411 INFO    [org.infinispan.configuration.cache.EvictionConfigurationBuilder]  (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
12:26:02,411 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 62) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
12:26:02,411 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 63) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
12:26:02,412 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
12:26:02,413 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 62) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
12:26:02,413 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 63) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
maj 10, 2017 12:26:02 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.21.Final
12:26:02,569 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
12:26:02,861 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBossWS 5.1.5.Final (Apache CXF 3.1.6) 
12:26:11,906 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/PostgresDS]
12:26:11,907 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
12:26:12,133 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
12:26:12,134 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
12:26:12,135 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 24133ms - Started 339 of 585 services (394 services are lazy, passive or on-demand)
 Connected to server
[2017-05-10 12:26:12,423] Artifact rest-ear:ear: Artifact is being deployed, please wait...
12:26:12,594 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Starting deployment of "rest-ear.ear" (runtime-name: "rest-ear.ear")
12:26:12,860 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0207: Starting subdeployment (runtime-name: "rest-soap.jar")
12:26:12,860 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0207: Starting subdeployment (runtime-name: "rest-rest.war")
12:26:14,526 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0059: Class Path entry jaxb-api.jar in /content/rest-ear.ear/rest-rest.war/WEB-INF/lib/jaxb-core-2.2.7.jar  does not point to a valid jar for a Class-Path reference.
12:26:14,527 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0059: Class Path entry jaxb-api.jar in /content/rest-ear.ear/rest-rest.war/WEB-INF/lib/jaxb-impl-2.2.7.jar  does not point to a valid jar for a Class-Path reference.
12:26:14,528 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0059: Class Path entry jaxb-core.jar in /content/rest-ear.ear/rest-rest.war/WEB-INF/lib/jaxb-impl-2.2.7.jar  does not point to a valid jar for a Class-Path reference.
12:26:14,599 WARN  [org.jboss.as.connector] (MSC service thread 1-1) WFLYJCA0091: -ds.xml file deployments are deprecated. Support may be removed in a future version.
12:26:15,028 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) WFLYJPA0002: Read persistence.xml for primary
12:26:15,146 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Bound data source [java:jboss/datasources/restDS]
12:26:15,157 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 25) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'rest-ear.ear/rest-soap.jar#primary'
12:26:15,174 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0003: Processing weld deployment rest-ear.ear
12:26:15,185 INFO  [org.hibernate.jpa.internal.util.LogHelper]      (ServerService Thread Pool -- 25) HHH000204: Processing PersistenceUnitInfo      [
    name: primary
    ...]
12:26:15,271 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-5) HV000001: Hibernate Validator 5.2.4.Final
12:26:15,342 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 25) HHH000412: Hibernate Core {5.0.10.Final}
12:26:15,347 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 25) HHH000206: hibernate.properties not found
12:26:15,349 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 25) HHH000021: Bytecode provider name : javassist
12:26:15,459 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 25) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
12:26:15,500 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0003: Processing weld deployment rest-soap.jar
12:26:15,611 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) WFLYWELD0003: Processing weld deployment rest-rest.war
12:26:15,629 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-7) WFLYEJB0473: JNDI bindings for session bean named 'UpdateStudent' in deployment unit 'subdeployment "rest-rest.war" of deployment "rest-ear.ear"' are as follows:

    java:global/rest-ear/rest-rest/UpdateStudent!pl.edu.kis.agh.UpdateStudent
    java:app/rest-rest/UpdateStudent!pl.edu.kis.agh.UpdateStudent
    java:module/UpdateStudent!pl.edu.kis.agh.UpdateStudent
    java:global/rest-ear/rest-rest/UpdateStudent
    java:app/rest-rest/UpdateStudent
    java:module/UpdateStudent

12:26:15,632 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-7) WFLYEJB0473: JNDI bindings for session bean named 'AddStudent' in deployment unit 'subdeployment "rest-rest.war" of deployment "rest-ear.ear"' are as follows:

java:global/rest-ear/rest-rest/AddStudent!pl.edu.kis.agh.AddStudent
java:app/rest-rest/AddStudent!pl.edu.kis.agh.AddStudent
java:module/AddStudent!pl.edu.kis.agh.AddStudent
java:global/rest-ear/rest-rest/AddStudent
java:app/rest-rest/AddStudent
java:module/AddStudent

12:26:15,632 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-7) WFLYEJB0473: JNDI bindings for session bean named 'RemoveStudent' in deployment unit 'subdeployment "rest-rest.war" of deployment "rest-ear.ear"' are as follows:

java:global/rest-ear/rest-rest/RemoveStudent!pl.edu.kis.agh.RemoveStudent
java:app/rest-rest/RemoveStudent!pl.edu.kis.agh.RemoveStudent
java:module/RemoveStudent!pl.edu.kis.agh.RemoveStudent
java:global/rest-ear/rest-rest/RemoveStudent
java:app/rest-rest/RemoveStudent
java:module/RemoveStudent

12:26:15,772 INFO  [org.jboss.weld.Version] (MSC service thread 1-7) WELD-000900: 2.3.5 (Final)
12:26:16,107 INFO   [org.infinispan.configuration.cache.EvictionConfigurationBuilder]  (ServerService Thread Pool -- 25) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
12:26:16,108 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 25) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
12:26:16,141 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 6) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'rest-ear.ear/rest-soap.jar#primary'
12:26:16,569 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 6) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
12:26:16,577 WARN  [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 6) HHH000431: Unable to determine H2 database version, certain features may not work
12:26:16,667 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 25) WFLYCLINF0002: Started client-mappings cache from ejb container
12:26:16,672 INFO  [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 6) Envers integration enabled? : true
12:26:17,315 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 6) HHH000227: Running hbm2ddl schema export
12:26:17,323 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 6) HHH000230: Schema export complete
12:26:18,128 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 2) WELD-001125: Illegal bean type org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider<javax.xml.bind.JAXBElement<?>> ignored on [EnhancedAnnotatedTypeImpl] public @Provider @Consumes @ApplicationScoped @Produces class   org.jboss.resteasy.plugins.providers.jaxb.JAXBElementProvider
12:26:18,132 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 2) WELD-001125: Illegal bean type interface javax.ws.rs.ext.MessageBodyReader<javax.xml.bind.JAXBElement<?>> ignored on [EnhancedAnnotatedTypeImpl] public @Provider @Consumes @ApplicationScoped  @Produces class  org.jboss.resteasy.plugins.providers.jaxb.JAXBElementProvider
12:26:18,133 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 2) WELD-001125: Illegal bean type interface javax.ws.rs.ext.MessageBodyWriter<javax.xml.bind.JAXBElement<?>> ignored on [EnhancedAnnotatedTypeImpl] public @Provider @Consumes @ApplicationScoped  @Produces class org.jboss.resteasy.plugins.providers.jaxb.JAXBElementProvider
12:26:18,133 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 2) WELD-001125: Illegal bean type class org.jboss.resteasy.plugins.providers.AbstractEntityProvider<javax.xml.bind.JAXBElement<?>> ignored on [EnhancedAnnotatedTypeImpl] public @Provider @Consumes @ApplicationScoped @Produces class org.jboss.resteasy.plugins.providers.jaxb.JAXBElementProvider
12:26:18,200 WARN  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 3) WELD-000167: Class org.jboss.resteasy.plugins.providers.DocumentProvider is annotated with @ApplicationScoped but it does not declare an appropriate constructor therefore is not registered as a bean!
12:26:18,208 WARN  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 4) WELD-000167: Class org.jboss.resteasy.core.AsynchronousDispatcher is annotated with @RequestScoped but it does not declare an appropriate constructor therefore is not registered as a bean!
12:26:18,865 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 8) Initializing Mojarra 2.2.13.SP1 20160303-1204 for context ''
12:26:20,696 WARN  [org.jboss.as.weld] (ServerService Thread Pool -- 8) WFLYWELD0052: Using deployment classloader to load proxy classes for module org.jboss.resteasy.resteasy-jaxrs:main. Package-private access will not work. To fix this the module should declare dependencies on [org.jboss.weld.core, org.jboss.weld.spi]
12:26:20,908 WARN  [org.jboss.as.weld] (ServerService Thread Pool -- 8) WFLYWELD0052: Using deployment classloader to load proxy classes for module org.jboss.resteasy.resteasy-jaxb-provider:main. Package-private access will not work. To fix this the module should declare dependencies on [org.jboss.weld.core, org.jboss.weld.spi]
12:26:21,180 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002225: Deploying javax.ws.rs.core.Application: class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,190 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002200: Adding class resource pl.edu.kis.agh.Hello from Application class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,190 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002200: Adding class resource pl.edu.kis.agh.UpdateStudent from Application class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,191 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002205: Adding provider class pl.edu.kis.agh.Message from Application class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,191 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002200: Adding class resource pl.edu.kis.agh.HelloWorld from Application class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,191 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002200: Adding class resource pl.edu.kis.agh.AddStudent from Application class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,191 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002200: Adding class resource pl.edu.kis.agh.RemoveStudent from Application class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,191 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002200: Adding class resource pl.edu.kis.agh.ArrayOfArrays from Application class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,191 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 8) RESTEASY002200: Adding class resource pl.edu.kis.agh.AuthenticateUser from Application class pl.edu.kis.agh.HelloWorldApplication$Proxy$_$$_WeldClientProxy
12:26:21,263 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 8) WFLYUT0021: Registered web context: /
12:26:21,289 INFO  [org.jboss.as.server] (management-handler-thread - 4) WFLYSRV0010: Deployed "rest-ear.ear" (runtime-name : "rest-ear.ear")
[2017-05-10 12:26:21,305] Artifact rest-ear:ear: Artifact is deployed successfully
[2017-05-10 12:26:21,305] Artifact rest-ear:ear: Deploy took 8 882 milliseconds

这是创建相关端点的服务器类。

import javax.ejb.Stateless;
import javax.imageio.ImageIO;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

@Path("/AddStudent")
@Stateless

public class AddStudent {

    private MyArrayList students = new MyArrayList();
    private ArrayList<Course> courses = new ArrayList<>();

    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)

    public Response dodajMiska(Student student) throws IOException {


        for (Student x : students.getRealMap()) {
            if (x.getIndexNumber().equalsIgnoreCase(student.getIndexNumber()))
                return Response.status(302).entity("Student already added to database").build();
        }

        for (Object o : student.getCourses()) {
            Course temp = new Course(((Course) o).getName(), ((Course) o).getEcts());
            courses.add(temp);
        }

        DecodeToImage decoder = new DecodeToImage();
        BufferedImage bufferedImage = decoder.decode(student.getPath());
        String pathName = "/Users/user/Desktop/REST_PROJEKT_2/tokens/rest/rest-rest/pics/" + student.getFirstName() + student.getSurname() + ".jpg";
        File outputfile = new File(pathName);
        try {
            ImageIO.write(bufferedImage, "jpg", outputfile);
        } catch (IOException e) {
            e.printStackTrace();
         }

        Student nowy = new Student(student.getFirstName(), student.getSurname(), student.getIndexNumber(), student.getLogin(), student.getPassword(), courses, pathName);
        students.put(nowy);

        Integer k = students.wielk();
        if (k == 0) {
            return  Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Student not added to database").build();
        } else {
            return Response.status(201).entity("Student added to database").build();
        }
    }
}

这是客户端方法。

    @Produces(MediaType.APPLICATION_JSON)
    public static Response sendData() {

        ResteasyClient client = new ResteasyClientBuilder().build();
        String path = "http://localhost:8080/examples/AddStudent";
        ResteasyWebTarget target = client.target(UriBuilder.fromPath(path));

        String s = "/Users/user/Desktop/REST_PROJEKT_2/tokens/restClient/src/pics/pic.jpg";
        String codedPic = FileSenderApache.Send(s);
        Response response = target.request().post(Entity.entity(new Student.Builder().firstName("Asia").surname("Kuku").indexNumber("1234").login("popo").password("kuku").courses(new Course.Builder().name("SOA").ects(4).build()).courses(new   Course.Builder().name("SD").ects(3).build()).path(codedPic).build(), MediaType.APPLICATION_JSON));

        System.out.println(response.getStatus());
        response.close();
       return response;
    }

1 个答案:

答案 0 :(得分:1)

ClassNotFoundException和NoClassDefFoundError通常被抛出,因为类不在类路径中,这可能是因为应用程序的打包或指定的类加载器隔离设置。查看“类位置”以找到它的打包位置,并与隔离设置进行比较。为特定部署类型定义的Java EE类路径。

当JVM尝试加载类的定义并且找不到定义时,抛出NoClassDefFoundError。 NoClassDefFoundError通常由ClassNotFoundException

引起

注意:如果应用程序中不存在该类,并且java源文件未列出该类,则使用javap或其他反编译器对该类进行反编译,并查看类定义是否与源匹配。当类路径缺少类​​时,某些IDE可能会生成无效类,它们可能会生成具有无效类引用的类,如果这些类被部署,则会导致不常见的ClassNotFoundExceptions,例如没有包的类名。