<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Cannot make my maven test client to speak with my EJB, missing jar?
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/eildosa">eildosa</a> in <i>EJB3</i> - <a href="https://community.jboss.org/message/735377#735377">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi, here is my problem, I made an EJB with maven and 2 test clients,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>* a test client without maven, only added jnp-client and the EJB to it's class path, work like a charm</p><p>* a test client using MAVEN, added the EJB through the POM and jnp-client, does not work</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>this is my EJB :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span>[img]</span><a class="jive-link-external-small" href="http://img11.hostingpics.net/pics/480421EJB1.png" target="_blank">http://img11.hostingpics.net/pics/480421EJB1.png</a><span>[/img]</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>it's POM :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[code]</p><p><span><project xmlns="</span><a class="jive-link-external-small" href="http://maven.apache.org/POM/4.0.0" target="_blank">http://maven.apache.org/POM/4.0.0</a><span>" xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span></p><p><span>  xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://maven.apache.org/POM/4.0.0" target="_blank">http://maven.apache.org/POM/4.0.0</a><span> </span><a class="jive-link-external-small" href="http://maven.apache.org/xsd/maven-4.0.0.xsd" target="_blank">http://maven.apache.org/xsd/maven-4.0.0.xsd</a><span>"></span></p><p>  <modelVersion>4.0.0</modelVersion></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <groupId>com.thongvan.mp</groupId></p><p>  <artifactId>MyFirstMavenEjb</artifactId></p><p>  <version>0.0.1-SNAPSHOT</version></p><p>  <packaging>ejb</packaging></p><p>  <name>MyFirstMavenEjb</name></p><p><span>  <url></span><a class="jive-link-external-small" href="http://maven.apache.org" target="_blank">http://maven.apache.org</a><span></url></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <dependencies></p><p>    <dependency></p><p>      <groupId>javax</groupId></p><p>      <artifactId>javaee-api</artifactId></p><p>      <version>6.0</version></p><p>      <scope>provided</scope></p><p>    </dependency></p><p>  </dependencies></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   <!-- setting default EJB2 to EJB3 --></p><p>  <build></p><p>    <plugins></p><p>      <plugin></p><p>        <groupId>org.apache.maven.plugins</groupId></p><p>        <artifactId>maven-compiler-plugin</artifactId></p><p>        <version>2.0.2</version></p><p>        <configuration></p><p>          <source>1.5</source></p><p>          <target>1.5</target></p><p>        </configuration></p><p>      </plugin></p><p>      <plugin></p><p>        <groupId>org.apache.maven.plugins</groupId></p><p>        <artifactId>maven-ejb-plugin</artifactId></p><p>        <version>2.1</version></p><p>        <configuration></p><p>          <ejbVersion>3.0</ejbVersion></p><p>        </configuration></p><p>      </plugin></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    </plugins></p><p>  </build></p><p></project></p><p>[/code]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>this is my first test client, the one without maven wich has no problem whatsoever to speak with the EJB</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span>[img]</span><a class="jive-link-external-small" href="http://img11.hostingpics.net/pics/974963EJB0.png" target="_blank">http://img11.hostingpics.net/pics/974963EJB0.png</a><span>[/img]</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>this is my second test client, using maven, it cannot speak with the EJB, all I'm getting is :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[code]</p><p>Context lookup finished</p><p>Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference cannot be cast to com.thongvan.mp.MyFirstMavenEjb.TestMavenEjb</p><p>          at com.thongvan.mp.TestClientMavenEjb.App.main(App.java:27)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[/code]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span>[img]</span><a class="jive-link-external-small" href="http://img11.hostingpics.net/pics/651692EJB2.png" target="_blank">http://img11.hostingpics.net/pics/651692EJB2.png</a><span>[/img]</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>It's POM : </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[code]</p><p><span><project xmlns="</span><a class="jive-link-external-small" href="http://maven.apache.org/POM/4.0.0" target="_blank">http://maven.apache.org/POM/4.0.0</a><span>" xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span></p><p><span>  xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://maven.apache.org/POM/4.0.0" target="_blank">http://maven.apache.org/POM/4.0.0</a><span> </span><a class="jive-link-external-small" href="http://maven.apache.org/xsd/maven-4.0.0.xsd" target="_blank">http://maven.apache.org/xsd/maven-4.0.0.xsd</a><span>"></span></p><p>  <modelVersion>4.0.0</modelVersion></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <groupId>com.thongvan.mp</groupId></p><p>  <artifactId>TestClientMavenEjb</artifactId></p><p>  <version>0.0.1-SNAPSHOT</version></p><p>  <packaging>jar</packaging></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <name>TestClientMavenEjb</name></p><p><span>  <url></span><a class="jive-link-external-small" href="http://maven.apache.org" target="_blank">http://maven.apache.org</a><span></url></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <properties></p><p>    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></p><p>  </properties></p><p>  </p><p>  <!-- pour la dependance jnp-client, besoin de la version 5.0.3.GA --></p><p>  <repositories></p><p>    <repository></p><p>      <id>Jboss</id></p><p><span>      <url></span><a class="jive-link-external-small" href="https://repository.jboss.org/nexus/content/repositories/releases/" target="_blank">https://repository.jboss.org/nexus/content/repositories/releases/</a><span></url></span></p><p>    </repository></p><p>  </repositories></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <dependencies></p><p>          <dependency></p><p>                      <groupId>org.jboss.naming</groupId></p><p>                      <artifactId>jnp-client</artifactId></p><p>                      <version>5.0.3.GA</version></p><p>          </dependency></p><p>          <dependency></p><p>                      <groupId>com.thongvan.mp</groupId></p><p>                      <artifactId>MyFirstMavenEjb</artifactId></p><p>                       <version>0.0.1-SNAPSHOT</version></p><p>          </dependency></p><p>  </dependencies></p><p></project></p><p>[/code]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Both clients have the same main :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[code]</p><p>    public static void main( String args[] ) throws NamingException</p><p>    {</p><p>              Hashtable env = new Hashtable(); </p><p>        env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); </p><p>        env.put(Context.PROVIDER_URL, "localhost"); </p><p>        env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" ); </p><p>        Context ctx = new InitialContext(env);</p><p>                    System.out.println("Context lookup finished");</p><p>  </p><p>                    TestMavenEjb proxy = (TestMavenEjb)(ctx.lookup("TestMavenEjbBean/remote-com.thongvan.mp.MyFirstMavenEjb.TestMavenEjb"));</p><p>                    System.out.println(proxy.getClass());</p><p>  </p><p>                    System.out.println("do something!");</p><p>  </p><p>                    proxy.doSomething();</p><p>    }</p><p>[/code]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>So, anybody has even the slightest idea about why the maven test client is not working?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Jboss 5.1.0.GA</p><p>Eclipse indigo</p><p>Maven 3.0.4</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Also I did some poking around by printing a toString on both context lookup here is what I got :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[b]Maven project (not working)[/b]</p><p>Reference Class Name: Proxy for: com.thongvan.mp.MyFirstMavenEjb.TestMavenEjb</p><p>Type: ProxyFactoryKey</p><p>Content: ProxyFactory/MyFirstMavenEjb/TestMavenEjbBean/TestMavenEjbBean/remote</p><p>Type: EJB Container Name</p><p>Content: jboss.j2ee:jar=MyFirstMavenEjb.jar,name=TestMavenEjbBean,service=EJB3</p><p>Type: Proxy Factory is Local</p><p>Content: false</p><p>Type: Remote Business Interface</p><p>Content: com.thongvan.mp.MyFirstMavenEjb.TestMavenEjb</p><p>Type: Remoting Host URL</p><p>Content: socket://localhost:3873/</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[b]regular project (working)[/b]</p><p>Proxy to jboss.j2ee:jar=MyFirstMavenEjb.jar,</p><p>name=TestMavenEjbBean,</p><p>service=EJB3 implementing [interface com.thongvan.mp.MyFirstMavenEjb.TestMavenEjb]</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/735377#735377">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>