aspose file tools*
The moose likes JBoss/WildFly and the fly likes javax.naming.NameNotFoundException: HelloBean not bound Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "javax.naming.NameNotFoundException: HelloBean not bound" Watch "javax.naming.NameNotFoundException: HelloBean not bound" New topic
Author

javax.naming.NameNotFoundException: HelloBean not bound

rex hindlekar
Greenhorn

Joined: Feb 25, 2010
Posts: 13
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<enterprise-beans>
<session>
<ejb-name>ejb/HelloBean</ejb-name>
<business-remote>examples.stateless.Hello</business-remote>
<ejb-class>examples.stateless.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>ejb/HelloBean</ejb-name>
<jndi-name>HelloBean</jndi-name>
</session>
</enterprise-beans>
</jboss>


package examples.stateless;

public interface Hello {

public void ttt();

}


/**
*
*/
package examples.stateless;

import javax.ejb.Remote;
import javax.ejb.Stateless;


@Stateless
@Remote(Hello.class)
public class HelloBean implements Hello {

public static final String RemoteJNDIName = HelloBean.class.getSimpleName() + "/remote";
public static final String LocalJNDIName = HelloBean.class.getSimpleName() + "/local";

@Override
public void ttt() {
System.out.println("seetesh");

}

}

package test;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;

import examples.stateless.Hello;
import examples.stateless.HelloBean;

//import junit.framework.TestCase;

public class CalculatorTest {//extends TestCase {

// private InitialContext initialContext;

// protected void setUp() throws Exception {
// Properties properties = new Properties();
// properties.put("java.naming.provider.url","localhost:1099");
// Context ctx = new InitialContext(properties);
// properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
// initialContext =
// }

/**
* Lookup the Hello bean via its remote interface
*
* @throws Exception
*/
/*
public void testHelloViaRemoteInterface() throws Exception {
Object object = initialContext.lookup(HelloBean.RemoteJNDIName);
assertNotNull(object);
assertTrue(object instanceof Hello);
Hello calc = (Hello) object;
calc.ttt();
}*/


public static void main(String[] args) throws Exception {
// InitialContext initialContext = null;
Properties properties = new Properties();

properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs","org.jboss.namingrg.jnp.interfaces");
properties.put("java.naming.provider.url","127.0.0.1");
Context ctx = new InitialContext(properties);
System.out.println("seetesh before 111");
Hello aaa = (Hello)ctx.lookup("HelloBean");
System.out.println("seetesh before");
aaa.ttt();
}


}

<?xml version="1.0" encoding="UTF-8"?>

<project name="EJB" default="dist" basedir="." >


<!-- Properties -->

<property environment="env"/>
<property name="ANT.OUT.DIR" value="${basedir}/antout"/>
<property name="BIN.DIR" value="${ANT.OUT.DIR}/bin"/>
<property name="CONFIG.DIR" value="${ANT.OUT.DIR}/confg"/>
<property name="WAR.OUT.DIR" value="${ANT.OUT.DIR}/dist"/>
<property name="SRC-PATH" value="${basedir}"/>
<property name="ASLIBREPOSITORY_HOME" value="${env.ASLIBREPOSITORY_HOME}"/>
<property name="GENERATED-SRC" value="${basedir}/generated"/>
<property name="AXIS_LIB_HOME" value="${env.AXIS_HOME}/lib"/>

<property name="examples.stateless" location="src/examples/stateless"/>
<property name="src.resources" location="${SRC-PATH}/src/resources"/>
<property name="build.main" location="target/classes"/>
<property name="dist" location="target"/>


<target name="init">
<mkdir dir="${build.main}"/>
<!-- server classpath -->
<path id="server.cp">
<pathelement location="classes"/>
<fileset dir="${env.JAVA_HOME}">
<include name="lib/*.jar"/>
</fileset>

<fileset dir="D:/jboss-5.1.0.GA/client">
<include name="jboss-javaee.jar"/>
</fileset>
<fileset dir="${env.JWSDP_HOME}/jaxrpc/lib">
<include name="jaxrpc-*.jar"/>
</fileset>
<fileset dir="${env.JWSDP_HOME}/jwsdp-shared/lib">
<include name="activation.jar"/>
<include name="mail.jar"/>
</fileset>
<fileset dir="${env.JWSDP_HOME}/saaj/lib">
<include name="saaj-api.jar"/>
<include name="saaj-impl.jar"/>
</fileset>
<fileset dir ="${ASLIBREPOSITORY_HOME}">
<include name="ASCommon.jar" />
</fileset>
<fileset dir ="${ASLIBREPOSITORY_HOME}">
<include name="ASDispatcher.jar" />
</fileset>
<fileset dir="${AXIS_LIB_HOME}">
<include name="*.jar" />
</fileset>
<fileset dir="${env.JWSDP_HOME}/jaxp/lib/endorsed">
<include name="dom.jar"/>
<include name="sax.jar"/>
<include name="xalan.jar"/>
<include name="xercesImpl.jar"/>
</fileset>
</path>


</target>

<target name="compile" depends="init">

<javac srcdir="${examples.stateless}" destdir="${build.main}">
<classpath>
<path refid="server.cp" />
</classpath>
</javac>
<copy todir="${build.main}">
<fileset dir="${src.resources}"/>
</copy>


</target>

<target name="test" depends="compile">

</target>

<target name="dist" depends="test">
<jar jarfile="${dist}/ejbone.jar" basedir="${build.main}"/>
<copy file="${dist}/ejbone.jar" todir="${env.SEETJBOSS_HOME}/server/deault/deploy" overwrite="true"/>
</target>

</project>


Any clue why I am not able to get this sample working?
rex hindlekar
Greenhorn

Joined: Feb 25, 2010
Posts: 13
Not sure if the ejb-jar.xml is properly set as I get this error now

Deployment "vfszip:/D:/jboss-5.1.0.GA/server/default/deploy/ejbone.jar/" is in error due to the following reason(s): java.io.IOException: Entry no longer available: ejb-jar.xml in file D:\jboss-5.1.0.GA\server\default\deploy\ejbone.jar
Kuldip Shetty
Ranch Hand

Joined: Jan 07, 2010
Posts: 39

Is ejb-jar.xml file placed under META-INF folder in ejbone.jar as shown below

%ROOT-DIR%/META-INF
%ROOT-DIR%/META-INF/ejb-jar.xml
%ROOT-DIR%/META-INF/jboss.xml
rex hindlekar
Greenhorn

Joined: Feb 25, 2010
Posts: 13
I kept the META-INF consisting of ejb-jar.xml, jboss.xml and MANIFEST.MF in the bin folder as the build was not including these 2 xml files in the jar

jboss.xml
------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">

<jboss>
<enterprise-beans>
<session>
<ejb-name>HelloBean</ejb-name>
<jndi-name>HelloBeanSeet</jndi-name>
</session>
</enterprise-beans>
</jboss>

Now I am getting

java.lang.ClassCastException: javax.naming.Reference cannot be cast to examples.stateless.Hello

Hello aaa = (Hello)ctx.lookup("HelloBeanSeet");

Doesnt seem to work.

Tried this link too

http://www.coderanch.com/t/454071/EJB-Certification-SCBCD/certification/javax-naming-Reference-cannot-cast#2022716
rex hindlekar
Greenhorn

Joined: Feb 25, 2010
Posts: 13
I am using JBoss 5.1.0, JDK 1.6


Global JNDI Namespace

+- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
+- SecureManagementView (class: org.jnp.interfaces.NamingContext)
| +- remote-org.jboss.deployers.spi.management.ManagementView (class: Proxy for: org.jboss.deployers.spi.management.ManagementView)
| +- remote (class: Proxy for: org.jboss.deployers.spi.management.ManagementView)
+- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
+- HelloBean (class: org.jnp.interfaces.NamingContext)
| +- remote-examples.stateless.Hello (class: Proxy for: examples.stateless.Hello)
+- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
+- HelloBeanSeet (class: Proxy for: examples.stateless.Hello)
+- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
+- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
+- UserTransactionSessionFactory (proxy: $Proxy225 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
+- SecureDeploymentManager (class: org.jnp.interfaces.NamingContext)
| +- remote (class: Proxy for: org.jboss.deployers.spi.management.deploy.DeploymentManager)
| +- remote-org.jboss.deployers.spi.management.deploy.DeploymentManager (class: Proxy for: org.jboss.deployers.spi.management.deploy.DeploymentManager)
+- console (class: org.jnp.interfaces.NamingContext)
| +- PluginManager (proxy: $Proxy220 implements interface org.jboss.console.manager.PluginManagerMBean)
+- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
+- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
+- TomcatAuthenticators (class: java.util.Properties)
+- SecureProfileService (class: org.jnp.interfaces.NamingContext)
| +- remote-org.jboss.profileservice.spi.ProfileService (class: Proxy for: org.jboss.profileservice.spi.ProfileService)
| +- remote (class: Proxy for: org.jboss.profileservice.spi.ProfileService)
+- ProfileService (class: org.jboss.aop.generatedproxies.AOPProxy$2)
+- jmx (class: org.jnp.interfaces.NamingContext)
| +- invoker (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor (proxy: $Proxy219 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
| +- rmi (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
+- queue (class: org.jnp.interfaces.NamingContext)
| +- ExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
| +- DLQ (class: org.jboss.jms.destination.JBossQueue)
+- topic (class: org.jnp.interfaces.NamingContext)

rex hindlekar
Greenhorn

Joined: Feb 25, 2010
Posts: 13
Now I am getting the following message while running the client.

At Jboss Command prompt
-------------------------------

java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:424)
at org.jboss.ws.core.soap.SOAPMessageImpl.<init>(SOAPMessageImpl.java:82)
at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:169)
at org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC.createSOAPMessage(SOAPFaultHelperJAXRPC.java:317)
at org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC.toSOAPMessage(SOAPFaultHelperJAXRPC.java:235)
at org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC.exceptionToFaultMessage(SOAPFaultHelperJAXRPC.java:213)
at org.jboss.ws.core.jaxrpc.SOAP11BindingJAXRPC.createFaultMessageFromException(SOAP11BindingJAXRPC.java:61)
at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:669)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:520)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

On Eclipse while running the Java code for both Stub and Dynamic Proxy I get the following error

Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Premature end of file.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at org.apache.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:163)
at $Proxy0.sayHello(Unknown Source)
at test.testdynamicproxy.main(testdynamicproxy.java:41)

{http://xml.apache.org/axis/}hostname:administrator

org.xml.sax.SAXParseException: Premature end of file.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at org.apache.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:163)
at $Proxy0.sayHello(Unknown Source)
at test.testdynamicproxy.main(testdynamicproxy.java:41)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
... 11 more


Stuck with this issue for the last 2 days.

Can someone point out why the code throws up such exceptions.

Rgds,

Seetesh
rex hindlekar
Greenhorn

Joined: Feb 25, 2010
Posts: 13
Hello Kuldeep,

Any clue?

Rgds
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9343
    
111

While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.


As for your exception:

java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:424)


See this


[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.naming.NameNotFoundException: HelloBean not bound
 
Similar Threads
Junit-Ant Building
[Ant] how to create a jar (not runnable) with other dependencies?
JBOSS
Ant + Junit + Log4J Problem
Building Seam projects in Eclipse