java.lang.NoSuchMethodError when deploying JAX-RS/JPA WAR
dmison Aug 31, 2011 2:56 AMI'm trying to build a simple REST service to frontend DB access. I'm fairly new to this but it builds ok but blows up when deploying on AS 7.0.0, 7.0.1 and a build of the trunk (last night).
I can't make much sense of the errors (pasted below) but I don't see any indication that the implicity JAX-RS dependencies are added. I tried each of the techniques described at https://docs.jboss.org/author/display/AS7/JAX-RS+Reference+Guide
Can anyone explain what I'm doing wrong or if this is a bug?
I've added all of my code below the server log of the deployment:
server.log
16:28:27,408 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) Starting deployment of "TopicRS.war" 16:28:27,430 INFO [org.jboss.jpa] (MSC service thread 1-4) read persistence.xml for topicPU 16:28:27,438 INFO [org.jboss.as.jpa] (MSC service thread 1-4) added javax.persistence.api, javaee.api, org.jboss.as.jpa, org.javassist dependencies to TopicRS.war 16:28:27,438 INFO [org.jboss.as.jpa] (MSC service thread 1-4) added (default provider) org.hibernate dependency to application deployment (since 1 PU(s) didn't specify jboss.as.jpa.providerModule) 16:28:27,439 INFO [org.jboss.as.jpa] (MSC service thread 1-4) added org.hibernate dependency to application deployment 16:28:27,487 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named TopicManager in deployment unit deployment "TopicRS.war" are as follows: java:global/TopicRS/TopicManager!com.shinysparkly.topicRS.services.rest.TopicManager java:app/TopicRS/TopicManager!com.shinysparkly.topicRS.services.rest.TopicManager java:module/TopicManager!com.shinysparkly.topicRS.services.rest.TopicManager java:global/TopicRS/TopicManager java:app/TopicRS/TopicManager java:module/TopicManager 16:28:27,500 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."TopicRS.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."TopicRS.war".INSTALL: Failed to process phase INSTALL of deployment "TopicRS.war" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765) at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26] at java.lang.Thread.run(Thread.java:680) [:1.6.0_26] Caused by: java.lang.NoSuchMethodError: org.jboss.invocation.proxy.ProxyFactory.getCachedMethods()[Ljava/lang/reflect/Method; at org.jboss.as.ee.component.ViewConfiguration.addViewInterceptor(ViewConfiguration.java:113) at org.jboss.as.ejb3.component.stateless.StatelessComponentDescription$3.configure(StatelessComponentDescription.java:148) at org.jboss.as.ee.component.ComponentDescription$DefaultFirstConfigurator.configure(ComponentDescription.java:872) at org.jboss.as.ee.component.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:65) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) ... 5 more 16:28:27,711 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployment of "TopicRS.war" was rolled back with failure message {"Failed services" => {"jboss.deployment.unit.\"TopicRS.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"TopicRS.war\".INSTALL: Failed to process phase INSTALL of deployment \"TopicRS.war\""},"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.TopicRS.TopicRS.TopicRS.Validator missing [ jboss.naming.context.java.module.TopicRS.TopicRS ]","jboss.naming.context.java.comp.TopicRS.TopicRS.TopicRS.ValidatorFactory missing [ jboss.naming.context.java.module.TopicRS.TopicRS ]"]} 16:28:27,723 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) Stopped deployment TopicRS.war in 11ms 16:28:27,726 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Failed services" => {"jboss.deployment.unit.\"TopicRS.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"TopicRS.war\".INSTALL: Failed to process phase INSTALL of deployment \"TopicRS.war\""},"Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.TopicRS.TopicRS.TopicRS.Validator missing [ jboss.naming.context.java.module.TopicRS.TopicRS ]","jboss.naming.context.java.comp.TopicRS.TopicRS.TopicRS.ValidatorFactory missing [ jboss.naming.context.java.module.TopicRS.TopicRS ]"]}}}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.shinysparkly</groupId> <artifactId>TopicRS</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>Topic REST Service</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format> <jboss.home>${env.JBOSS_HOME}</jboss.home> </properties> <repositories> <!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users --> <repository> <id>jboss-public-repository</id> <name>JBoss Repository</name> <url>http://repository.jboss.org/nexus/content/groups/public</url> <!-- These optional flags are designed to speed up your builds by reducing remote server calls --> <releases> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>jboss-public-repository</id> <name>JBoss Repository</name> <url>http://repository.jboss.org/nexus/content/groups/public</url> <releases> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> <dependencies> <dependency> <groupId>org.jboss.logging</groupId> <artifactId>jboss-logging</artifactId> <version>3.0.0.GA</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.spec</groupId> <artifactId>jboss-javaee-web-6.0</artifactId> <version>2.0.0.Final</version> <type>pom</type> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build> </project>
src/main/java/com/shinysparkly/topicRS/entities/Topic.java
package com.shinysparkly.topicRS.entities; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.NamedQuery; @Entity public class Topic implements Serializable { @Id private Long TopicID; private String TopicTitle; private String TopicXML; public Long getTopicID() { return TopicID; } public void setId(Long TopicID) { this.TopicID = TopicID; } public String getTopicTitle() { return TopicTitle; } public void setTopicTitle(String TopicTitle) { this.TopicTitle = TopicTitle; } public String getTopicXML() { return TopicXML; } public void setTopicXML(String TopicXML) { this.TopicXML = TopicXML; } }
src/main/java/com/shinysparkly/topicRS/services/rest/ApplicationConfig.java
package com.shinysparkly.topicRS.services.rest; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; @ApplicationPath("topics") public class ApplicationConfig extends Application { }
src/main/java/com/shinysparkly/topicRS/services/rest/TopicManager.java
package com.shinysparkly.topicRS.services.rest; import com.shinysparkly.topicRS.entities.Topic; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.EntityNotFoundException; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; @Path("topic") @Stateless @Produces("application/xml") public class TopicManager { @PersistenceContext(unitName="topicPU") private EntityManager em; @GET @Path("{id}") String getRawTopicByID(@PathParam("id") int id) { try { Topic t = em.find(Topic.class, id); return t.getTopicXML(); } catch(EntityNotFoundException ex) { throw new WebApplicationException(Response.status(404).entity("topic not found").build()); } } }
src/main/java/resources/META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="topicPU" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/TopicDS</jta-data-source> <class>com.shinysparkly.topicRS.entity.Topic</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> </persistence>