Note that there are some explanatory texts on larger screens.

plurals
  1. POEJB 3.0 test client working without maven but not with
    primarykey
    data
    text
    <p>here is my problem, I made an EJB with maven and 2 test clients,</p> <ul> <li>a test client without maven, only added jnp-client and the EJB to it's class path, work like a charm</li> <li>a test client using MAVEN, added the EJB through the POM and jnp-client, does not work</li> </ul> <p>this is my EJB :</p> <p><img src="https://i.stack.imgur.com/14gJ6.png" alt="the EJB"></p> <p>it's POM :</p> <pre><code>&lt;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"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.thongvan.mp&lt;/groupId&gt; &lt;artifactId&gt;MyFirstMavenEjb&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;ejb&lt;/packaging&gt; &lt;name&gt;MyFirstMavenEjb&lt;/name&gt; &lt;url&gt;http://maven.apache.org&lt;/url&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;javax&lt;/groupId&gt; &lt;artifactId&gt;javaee-api&lt;/artifactId&gt; &lt;version&gt;6.0&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;!-- setting default EJB2 to EJB3 --&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;2.0.2&lt;/version&gt; &lt;configuration&gt; &lt;source&gt;1.5&lt;/source&gt; &lt;target&gt;1.5&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-ejb-plugin&lt;/artifactId&gt; &lt;version&gt;2.1&lt;/version&gt; &lt;configuration&gt; &lt;ejbVersion&gt;3.0&lt;/ejbVersion&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>this is my first test client, the one without maven wich has no problem whatsoever to speak with the EJB</p> <p><img src="https://i.stack.imgur.com/c4eyr.png" alt="regular test client"></p> <p>this is my second test client, using maven, it cannot speak with the EJB, all I'm getting is :</p> <pre><code>Context lookup finished Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference cannot be cast to com.thongvan.mp.MyFirstMavenEjb.TestMavenEjb at com.thongvan.mp.TestClientMavenEjb.App.main(App.java:27) </code></pre> <p><img src="https://i.stack.imgur.com/d3pBE.png" alt="the maven test client"></p> <p>It's POM : </p> <pre><code>&lt;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"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.thongvan.mp&lt;/groupId&gt; &lt;artifactId&gt;TestClientMavenEjb&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;jar&lt;/packaging&gt; &lt;name&gt;TestClientMavenEjb&lt;/name&gt; &lt;url&gt;http://maven.apache.org&lt;/url&gt; &lt;properties&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;/properties&gt; &lt;!-- pour la dependance jnp-client, besoin de la version 5.0.3.GA --&gt; &lt;repositories&gt; &lt;repository&gt; &lt;id&gt;Jboss&lt;/id&gt; &lt;url&gt;https://repository.jboss.org/nexus/content/repositories/releases/&lt;/url&gt; &lt;/repository&gt; &lt;/repositories&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.jboss.naming&lt;/groupId&gt; &lt;artifactId&gt;jnp-client&lt;/artifactId&gt; &lt;version&gt;5.0.3.GA&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.thongvan.mp&lt;/groupId&gt; &lt;artifactId&gt;MyFirstMavenEjb&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/project&gt; </code></pre> <p>Both clients have the same main :</p> <pre><code>public static void main( String args[] ) throws NamingException { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "localhost"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" ); Context ctx = new InitialContext(env); System.out.println("Context lookup finished"); TestMavenEjb proxy = (TestMavenEjb)(ctx.lookup("TestMavenEjbBean/remote-com.thongvan.mp.MyFirstMavenEjb.TestMavenEjb")); System.out.println(proxy.getClass()); System.out.println("do something!"); proxy.doSomething(); } </code></pre> <p>So, anybody has even the slightest idea about why the maven test client is not working?</p> <p>Jboss 5.1.0.GA Eclipse indigo Maven 3.0.4</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload