10 Replies Latest reply: Jun 30, 2010 4:22 AM by Eduardo Sanchez-Ros RSS

MappingException when starting persistence unit in Embedded JBoss

Eduardo Sanchez-Ros Newbie

Hi,

 

I have followed the post that shows how to test EJB3 services using TestNG and JBoss Embedded on http://hocinegrine.com/2010/06/17/unit-testing-with-jboss-embedded-ejb3-container/. The test project attached to this post uses version 1.0.0.Alpha9 of JBoss Embedded. After loading that project it works fine but when I tried to test my EJB using the same approach I had the following error:

 

WARN  22-06 12:06:13,786 (Ejb3Configuration.java:addXMLEntities:365)  -Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
ERROR 22-06 12:06:14,598 (AbstractController.java:incrementState:440)  -Error installing to Start: name=persistence.units:jar=classes.jar,unitName=csssyncCache state=Create
org.hibernate.MappingException: property not found: userDomainIdin entity: com.cognitomobile.csssync.entities.cacheresults.CacheAdd

 

userDomainId is an embedded id for the CacheAdd entity. The Entity CacheAdd is as follows:
import javax.persistence.*;
 
@Entity
@SqlResultSetMappings( {
        @SqlResultSetMapping(
                name="AddResultsetMappings",
                entities={
                        @EntityResult(
                                entityClass= CacheAdd.class,
                                fields={
                                        @FieldResult(name="userDomainId.userAddress", column="USER_ADDRESS"),
                                        @FieldResult(name="userDomainId.domain", column="DOMAIN"),
                                        @FieldResult(name="phoneNumber", column="PHONE_NUMBER"),
                                        @FieldResult(name="pid", column="PID")
                                }
                        )
                }
        )
})
@NamedNativeQuery(
        name = "FindAdds",
        query = "SELECT X.USER_ADDRESS, X.DOMAIN, X.PHONE_NUMBER, X.PID FROM CACHE C " +
                "RIGHT JOIN " +
                "(SELECT RJS.USER_ADDRESS, RJS.DOMAIN, RJS.PHONE_NUMBER, RJS.PID " +
                "FROM SNAPSHOT RJS " +
                "EXCEPT " +
                "SELECT RJC.USER_ADDRESS, RJC.DOMAIN, PHONE_NUMBER, PID " +
                "FROM CACHE RJC) AS X " +
                "ON X.USER_ADDRESS = C.USER_ADDRESS " +
                "AND X.DOMAIN = C.DOMAIN " +
                "WHERE C.USER_ADDRESS IS NULL",
        resultSetMapping = "AddResultsetMappings")
 
public class CacheAdd
{
    @EmbeddedId
    private UserDomainId userDomainId;
 
    public UserDomainId getUserDomainId()
    {
        return userDomainId;
    }
 
    public void setUserDomainId(final UserDomainId userDomainId)
    {
        this.userDomainId = userDomainId;
    }
 
    private String phoneNumber;
    private String pid;
 
    public String getDomain()
    {
        return userDomainId.getDomain();
    }
 
    public void setDomain(String domain)
    {
        this.userDomainId.setDomain(domain);
    }
 
    public String getUserAddress()
    {
        return userDomainId.getUserAddress();
    }
 
    public void setUserAddress(String userAddress)
    {
        this.userDomainId.setUserAddress(userAddress);
    }
 
    public String getPhoneNumber()
    {
        return phoneNumber;
    }
 
    public void setPhoneNumber(String phoneNumber)
    {
        this.phoneNumber = phoneNumber;
    }
 
    public String getPid()
    {
        return pid;
    }
 
    public void setPid(String pid)
    {
        this.pid = pid;
    }
 
    @Override
    public String toString()
    {
        return new StringBuilder()
                .append("User Address: ")
                .append(userDomainId.getUserAddress())
                .append(". Domain: ")
                .append(userDomainId.getDomain())
                .append(". Phone Number: ")
                .append(phoneNumber)
                .append(". Pid: ")
                .append(pid)
                .toString();
    }
}

and here is the class UserDomainId:
import javax.persistence.Embeddable;
import java.io.Serializable;
 
@Embeddable
public class UserDomainId implements Serializable
{
    private String userAddress;
    private String domain;
 
    public UserDomainId() {}
    public UserDomainId(String userAddress, String domain) {
      this.userAddress = userAddress;
      this.domain = domain;
    }
 
    public String getUserAddress() { return userAddress; }
    public String getDomain() { return domain; }
 
    public void setUserAddress(String userAddress)
    {
        this.userAddress = userAddress;
    }
 
    public void setDomain(String domain)
    {
        this.domain = domain;
    }
 
    @Override
    public boolean equals(Object o) {
        return ((o instanceof UserDomainId) &&
                userAddress.equals(((UserDomainId)o).getUserAddress()) &&
                domain.equals(((UserDomainId)o).getDomain()));
 
    }
 
    @Override
    public int hashCode() {
        return userAddress.hashCode() + domain.hashCode();
    }
}

 

If I deploy my EJB on a JBoss server (version 5.1.0) it works fine and I don't get the MappingException.

 

My questions are:

- Is this a known issue with this particular version of JBoss Embedded and EmbeddedId?

- Is there a newer version of JBoss Embedded that I should be using?

 

Thanks in advance.

 

Regards,

Eduardo

  • 1. Re: MappingException when starting persistence unit in Embedded JBoss
    Andrew Rubinger Master

    Eduardo Sanchez-Ros wrote:

    - Is there a newer version of JBoss Embedded that I should be using?

    Yep.

     

    The latest release of the Embedded APIs for JBossAS work against AS 6.0.0.M3.  You can find a full example project explained here: JBoss Embedded AS | Quickstart and Runnable Example

     

    Main Wiki for the project is now: JBoss Embedded AS

     

    S,

    ALR

  • 2. Re: MappingException when starting persistence unit in Embedded JBoss
    Eduardo Sanchez-Ros Newbie

    Hi Andrew,

     

    Thanks for your answer. I downloaded the full example project from JBoss Embedded AS | Quickstart and Runnable Example but I haven't managed to make it work yet as the project doesn't compile. After some fiddling I managed to compile it but I had to change some of the packages:

     

    From

     

    import org.jboss.embedded.api.server.JBossASEmbeddedServer;
    import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
    
    

     

    To

     

    import org.jboss.bootstrap.api.embedded.server.JBossASEmbeddedServer;
    import org.jboss.bootstrap.api.embedded.server.JBossASEmbeddedServerFactory;
    

     

    I followed the instructions in JBoss Embedded AS | Full ClassPath via Maven but it doesn't seem to work for me either. It couldn't find version 6.0.0.20100429-M3 of the jbossas so I have to use 6.0.0-SNAPSHOT.

     

    I have attached my pom. Am I missing something?

     

    I managed to make the Entity with the EmbeddedId work with JBoss Embedded, but we are really interested in using JBoss Embedded AS for our testing.

     

    Thanks for your help in advance.

     

    Regards,

    Eduardo.

  • 3. Re: MappingException when starting persistence unit in Embedded JBoss
    Andrew Rubinger Master

    Looks like your POM just has the wrong/outdated JBoss Repo configured.  Check out:

     

    Maven Getting Started - Users

     

    ...where the new URL is: https://repository.jboss.org/nexus/content/groups/public/.

     

    Then you should be able to get at M3.

     

    S,

    ALR

  • 4. Re: MappingException when starting persistence unit in Embedded JBoss
    Eduardo Sanchez-Ros Newbie

    I tried the URL https://repository.jboss.org/nexus/content/groups/public/ with different SVN clients but I get the following error:


     

    Server sent unexpected return  value (500 No enum const class org.sonatype.nexus.proxy.access.Action.options) 
    in response to OPTIONS request for  ‘https://repository.jboss.org/nexus/content/groups/public’
    

     

    I also tried the other repositories that are mentioned in the link (repositories/releases, repositories/snapshots, etc) but I get the same message.

     

    Is there an alternative URL to get at M3 from?

     

    Thanks.

    Eduardo

  • 5. Re: MappingException when starting persistence unit in Embedded JBoss
    Andrew Rubinger Master

    Eduardo Sanchez-Ros wrote:

     

    I tried the URL https://repository.jboss.org/nexus/content/groups/public/ with different SVN clients but I get the following error:

    Looks like you hit some unfortunate timing when things were down.  Looks allright to me now.

     

    S,
    ALR

  • 6. Re: MappingException when starting persistence unit in Embedded JBoss
    Eduardo Sanchez-Ros Newbie

    I tried again and it still doesn't work. I asked some colleagues to try as well but they had the same error.

     

    I also tried a connection without a proxy and still didn't work.

     

    I can browse to the URL but I can't connect using TortoiseSVN or Maven. What SVN client do you use to connect to the repository? What version of Maven do you use?

     

    Thanks

    Eduardo

  • 7. Re: MappingException when starting persistence unit in Embedded JBoss
    Andrew Rubinger Master

    Just re-read your post a bit.  What do you mean by, "using an SVN client" to browse the Maven repository?  Your project's POM should likely have this configured, or do so in your Maven settings (as advised by Maven Getting Started - Users).

     

    If you're still getting errors, please post 'em here.

     

    S,

    ALR

  • 8. Re: MappingException when starting persistence unit in Embedded JBoss
    Eduardo Sanchez-Ros Newbie

    Hi,

     

    I followed the link you posted step by step (Maven Getting Started - Users) and I get the same error:

     

    "C:\Program Files\Java\jdk1.6.0_20\bin\java" -Dclassworlds.conf=E:\Development\Maven\apache-maven-2.2.1\bin\m2.conf -Dmaven.home=E:\Development\Maven\apache-maven-2.2.1 -Didea.launcher.port=7544 "-Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 9.0.2\bin" -Dfile.encoding=windows-1252 -classpath "E:\Development\Maven\apache-maven-2.2.1\boot\classworlds-1.1.jar;C:\Program Files\JetBrains\IntelliJ IDEA 9.0.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher --no-plugin-registry --fail-fast --no-plugin-updates --strict-checksums --update-snapshots -f "E:\Development\Cognito\Projects\CssSync\Test\Embedded JBoss\JBoss Embedded AS\pom.xml" install -P embedded,jboss-public-repository
    + Enabling strict checksum verification on all artifact downloads.
    [INFO] Scanning for projects...
    Downloading: https://repository.jboss.org/nexus/content/groups/public/org/jboss/jbossas/jboss-as-depchain/6.0.0.20100429-M3/jboss-as-depchain-6.0.0.20100429-M3.pom
    [WARNING] Unable to get resource 'org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3' from repository jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public): Error transferring file: Connection timed out: connect
    Downloading: http://repository.jboss.com/maven2/org/jboss/jbossas/jboss-as-depchain/6.0.0.20100429-M3/jboss-as-depchain-6.0.0.20100429-M3.pom
    [INFO] Unable to find resource 'org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3' in repository jboss (http://repository.jboss.com/maven2)
    Downloading: http://download.java.net/maven/2/org/jboss/jbossas/jboss-as-depchain/6.0.0.20100429-M3/jboss-as-depchain-6.0.0.20100429-M3.pom
    [INFO] Unable to find resource 'org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3' in repository java (http://download.java.net/maven/2)
    Downloading: http://repo1.maven.org/maven2/org/jboss/jbossas/jboss-as-depchain/6.0.0.20100429-M3/jboss-as-depchain-6.0.0.20100429-M3.pom
    [INFO] Unable to find resource 'org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3' in repository main (http://repo1.maven.org/maven2)
    Downloading: http://repository.jboss.com/maven2/org/jboss/jbossas/jboss-as-depchain/6.0.0.20100429-M3/jboss-as-depchain-6.0.0.20100429-M3.pom
    [INFO] Unable to find resource 'org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3' in repository maven.jboss.org (http://repository.jboss.com/maven2)
    Downloading: http://snapshots.jboss.org/maven2/org/jboss/jbossas/jboss-as-depchain/6.0.0.20100429-M3/jboss-as-depchain-6.0.0.20100429-M3.pom
    [INFO] Unable to find resource 'org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3' in repository snapshots.jboss.org (http://snapshots.jboss.org/maven2)
    Downloading: http://repo1.maven.org/maven2/org/jboss/jbossas/jboss-as-depchain/6.0.0.20100429-M3/jboss-as-depchain-6.0.0.20100429-M3.pom
    [INFO] Unable to find resource 'org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3' in repository central (http://repo1.maven.org/maven2)
    [INFO] ------------------------------------------------------------------------
    [ERROR] FATAL ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Error building POM (may not be this project's POM).
    
    
    Project ID: org.jboss.jbossas:jboss-as-depchain
    
    Reason: POM 'org.jboss.jbossas:jboss-as-depchain' not found in repository: Unable to download the artifact from any repository
    
      org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3
    
    from the specified remote repositories:
      central (http://repo1.maven.org/maven2),
      main (http://repo1.maven.org/maven2),
      snapshots.jboss.org (http://snapshots.jboss.org/maven2),
      maven.jboss.org (http://repository.jboss.com/maven2),
      jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public),
      jboss (http://repository.jboss.com/maven2),
      java (http://download.java.net/maven/2)
    
     for project org.jboss.jbossas:jboss-as-depchain
    
    
    [INFO] ------------------------------------------------------------------------
    [INFO] Trace
    org.apache.maven.reactor.MavenExecutionException: POM 'org.jboss.jbossas:jboss-as-depchain' not found in repository: Unable to download the artifact from any repository
    
      org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3
    
    from the specified remote repositories:
      central (http://repo1.maven.org/maven2),
      main (http://repo1.maven.org/maven2),
      snapshots.jboss.org (http://snapshots.jboss.org/maven2),
      maven.jboss.org (http://repository.jboss.com/maven2),
      jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public),
      jboss (http://repository.jboss.com/maven2),
      java (http://download.java.net/maven/2)
    
     for project org.jboss.jbossas:jboss-as-depchain
         at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
         at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
         at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
         at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
    Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.jboss.jbossas:jboss-as-depchain' not found in repository: Unable to download the artifact from any repository
    
      org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3
    
    from the specified remote repositories:
      central (http://repo1.maven.org/maven2),
      main (http://repo1.maven.org/maven2),
      snapshots.jboss.org (http://snapshots.jboss.org/maven2),
      maven.jboss.org (http://repository.jboss.com/maven2),
      jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public),
      jboss (http://repository.jboss.com/maven2),
      java (http://download.java.net/maven/2)
    
     for project org.jboss.jbossas:jboss-as-depchain
         at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605)
         at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:251)
         at org.apache.maven.project.DefaultMavenProjectBuilder.mergeManagedDependencies(DefaultMavenProjectBuilder.java:1456)
         at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:999)
         at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880)
         at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
         at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
         at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
         at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
         at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
         ... 17 more
    Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository
    
      org.jboss.jbossas:jboss-as-depchain:pom:6.0.0.20100429-M3
    
    from the specified remote repositories:
      central (http://repo1.maven.org/maven2),
      main (http://repo1.maven.org/maven2),
      snapshots.jboss.org (http://snapshots.jboss.org/maven2),
      maven.jboss.org (http://repository.jboss.com/maven2),
      jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public),
      jboss (http://repository.jboss.com/maven2),
      java (http://download.java.net/maven/2)
    
    
         at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228)
         at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
         at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)
         ... 26 more
    Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
         at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)
         at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
         ... 28 more
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 25 seconds
    [INFO] Finished at: Tue Jun 29 14:56:01 BST 2010
    [INFO] Final Memory: 2M/15M
    [INFO] ------------------------------------------------------------------------
    
    Process finished with exit code 1
    
    
    

     

    So it looks like it times out while trying to request the POM from the repository. The other repositories seem to respond pretty quickly to the request. Is there a way to increase the timeout value in Maven?

     

    Thanks

    Eduardo

  • 9. Re: MappingException when starting persistence unit in Embedded JBoss
    Andrew Rubinger Master

    Now that's odd.  As you can see in your output, Maven is logging a correct request:

     

    https://repository.jboss.org/nexus/content/groups/public/org/jboss/jbossas/jboss-as-depchain/6.0.0.20100429-M3/jboss-as-depchain-6.0.0.20100429-M3.pom

     

    I remember we had some issues w/ Maven resolution in dependencyManagement and import scope; I think the fix was to use the latest Maven 3.0 Beta; give that a spin?

     

    After the artifacts are in your local repository, 2.2.x should work fine again.

     

    S,

    ALR

  • 10. Re: MappingException when starting persistence unit in Embedded JBoss
    Eduardo Sanchez-Ros Newbie

    That worked. I managed to download all the artifacts using Maven 3 and the project built successfully.

     

    Thanks very much for your help.

     

    Regards,

    Eduardo