2012-01-27 31 views
1

有誰知道爲什麼我收到以下錯誤,當我嘗試部署我的耳朵到GlassFish:錯誤而結合JNDI名稱com.jinsoft.dating.server.ProfileEJBRemote

java.lang.RuntimeException: Error while binding JNDI name ... 
... 
Caused by: javax.naming.NameAlreadyBoundException 

我使用Maven,所以我的文件結構(簡體)看起來是這樣的:

ear 
    pom.xml 

ejb 
+--src 
    +--main 
    +--java 
     +--(package) 
     Profile.java 
     ProfileEJB.java 
     ProfileEJBRemote.java 
    pom.xml 

web 
+--src 
    +--main 
    +--java 
     +--(package) 
     ProfileController.java 
    +--webapp 
     +--META-INF 
     index.jsp 
     listProfiles.xhtml 
     newProfile.xhtml 
    pom.xml 

EAR的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.jinsoft.dating</groupId> 
<artifactId>dating</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>ear</packaging> 
<name>dating</name> 
<dependencies> 
<dependency> 
<groupId>com.jinsoft.dating</groupId> 
<artifactId>server</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<type>ejb</type> 
<scope>compile</scope> 
</dependency> 
<dependency> 
<groupId>com.jinsoft.dating</groupId> 
<artifactId>web</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<type>war</type> 
<scope>compile</scope> 
</dependency> 
</dependencies> 
<properties> 
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<build> 
<plugins> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <version>2.3.2</version> 
    <configuration> 
     <source>1.6</source> 
     <target>1.6</target> 
    </configuration> 
    </plugin> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-ear-plugin</artifactId> 
    <version>2.6</version> 
    <configuration> 
     <version>6</version> 
     <defaultLibBundleDir>lib</defaultLibBundleDir> 

     <modules> 
      <webModule> 
       <groupId>com.jinsoft.dating</groupId> 
       <artifactId>web</artifactId> 
       <bundleFileName>dating.war</bundleFileName> 
       <contextRoot>/dating</contextRoot> 
      </webModule> 
      <ejbModule> 
       <groupId>com.jinsoft.dating</groupId> 
       <artifactId>server</artifactId> 
       <bundleFileName>dating.jar</bundleFileName> 
      </ejbModule> 
     </modules> 
     <displayName>JinDate</displayName> 
     <!-- If I want maven to generate the application.xml, set this to true --> 
     <generateApplicationXml>true</generateApplicationXml>    
    </configuration> 
    </plugin> 
    </plugins> 
    </build> 
</project> 

EJB POM:

<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.jinsoft.dating</groupId> 
<artifactId>server</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>ejb</packaging> 

<name>server</name> 

<properties> 
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-api</artifactId> 
     <version>6.0</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>joda-time</groupId> 
     <artifactId>joda-time</artifactId> 
     <version>2.0</version> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.18</version> 
    </dependency>   
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
       <compilerArguments> 
        <endorseddirs>${endorsed.dir}</endorseddirs> 
       </compilerArguments> 
      </configuration> 
     </plugin>    
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-ejb-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <ejbVersion>3.1</ejbVersion> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.1</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${endorsed.dir}</outputDirectory> 
         <silent>true</silent> 
         <artifactItems> 
          <artifactItem> 
           <groupId>javax</groupId> 
           <artifactId>javaee-endorsed-api</artifactId> 
           <version>6.0</version> 
           <type>jar</type> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

WAR POM:

<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.jinsoft.dating</groupId> 
<artifactId>web</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>war</packaging> 

<name>web</name> 

<properties> 
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-web-api</artifactId> 
     <version>6.0</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.faces</groupId> 
     <artifactId>jsf-api</artifactId> 
     <version>2.1</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.jinsoft.dating</groupId> 
     <artifactId>server</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
     <type>ejb</type> 
     <scope>compile</scope> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
       <compilerArguments> 
        <endorseddirs>${endorsed.dir}</endorseddirs> 
       </compilerArguments> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.1.1</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.1</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${endorsed.dir}</outputDirectory> 
         <silent>true</silent> 
         <artifactItems> 
          <artifactItem> 
           <groupId>javax</groupId> 
           <artifactId>javaee-endorsed-api</artifactId> 
           <version>6.0</version> 
           <type>jar</type> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

回答

0

第一次的猜測?在服務器上還有另一個部署,它也有一個EJB,其中包含您試圖部署的名稱。也許,這是一箇舊的測試部署? 這基本上意味着,您正試圖將一個新對象部署到另一個對象已經使用的名稱下的JNDI樹中。擺脫所有以前的部署,清理你的項目並重試。

Rgds, M

+0

它是唯一部署到Glassfish容器的應用程序。 – 2012-02-03 03:19:49