- This topic has 13 replies, 5 voices, and was last updated 19 years, 10 months ago by haobaba1.
-
AuthorPosts
-
robinsinghMemberENVIRONMENT DETAILS:
I have configured myEclipse with jboss 4.0 final version
on windows XP professional(SP2) using Java[TM] 2 Platform,
Eclipse Platform
Version: 3.0.0
Build id: 200406251208
jdk version(build 1.4.2_05-b04)
myEclipse 3.8.2
———————
I have deployed an ejb named cabinEJb on jboss A.S
now my following client application on its call to InitialContext() —
searches the classpath for jndi.properties (listed after this)
the author uses the ant tool for pointing the classpath to the appropriate jndi directory .I am trying to port this client application to myEclipse so that i can run it without using ant tool from command line i.e by just doing the Run as –> Java Application in my eclipse.
while running the application i add the program argument
-classpath e:\workbook\jndi\jndi.properties
to include the jndi.properties in the classpath
but it doesnt work
and throws the following exceptionjavax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280) at javax.naming.InitialContext.lookup(InitialContext.java:347) at com.titan.clients.Client_1.main(Client_1.java:19)
where/how do i appropriately point to the jndi.properties in the classpath so that the client_1.java acknowledges it.
please help.
robin[b]client_1.java[/b] package com.titan.clients; import com.titan.cabin.CabinHomeRemote; import com.titan.cabin.CabinRemote; import javax.naming.InitialContext; import javax.naming.Context; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import java.rmi.RemoteException; public class Client_1 { public static void main(String [] args) { try { Context jndiContext = getInitialContext(); Object ref = jndiContext.lookup("CabinHomeRemote"); CabinHomeRemote home = (CabinHomeRemote) PortableRemoteObject.narrow(ref,CabinHomeRemote.class); CabinRemote cabin_1 = home.create(new Integer(1)); cabin_1.setName("Master Suite"); cabin_1.setDeckLevel(1); cabin_1.setShipId(1); cabin_1.setBedCount(3); Integer pk = new Integer(1); CabinRemote cabin_2 = home.findByPrimaryKey(pk); System.out.println(cabin_2.getName()); System.out.println(cabin_2.getDeckLevel()); System.out.println(cabin_2.getShipId()); System.out.println(cabin_2.getBedCount()); } catch (java.rmi.RemoteException re){re.printStackTrace();} catch (javax.naming.NamingException ne){ne.printStackTrace();} catch (javax.ejb.CreateException ce){ce.printStackTrace();} catch (javax.ejb.FinderException fe){fe.printStackTrace();} } public static Context getInitialContext() throws javax.naming.NamingException { return new InitialContext(); /**** context initialized by jndi.properties file Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces"); p.put(Context.PROVIDER_URL, "localhost:1099"); return new javax.naming.InitialContext(p); */ } }
[b]jndi.properties[/b] java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=localhost
GregMemberYou can put the jndi.properties file in the root of the “src” directory so it will be copied to the root of your output directory. When you run the application, it should find it there.
robinsinghMemberI included the properties file in the root of src directory ,
here is the layout of the project
SRC folder
|
|
package
com.titan.cabin. —>CabinBean.java
com.titan.cabin. —>CabinHomeRemote.java
com.titan.cabin. —>CabinRemote.javaalso SRC has the client package
com.titan.client.–>client_1.java
also SRC root has the jndi.properties (as you suggested)but still it throws the same exception as earlier.
—————–javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280) at javax.naming.InitialContext.lookup(InitialContext.java:347) at com.titan.clients.Client_1.main(Client_1.java:19)
—————————————————-
Taking another chance , i moved the client1.java & jndi.properties from com.titan.clients to com.titan.cabin .wich made the layout as follows :
SRC folder
|
|
package
com.titan.cabin. —>CabinBean.java
com.titan.cabin. —>CabinHomeRemote.java
com.titan.cabin. —>CabinRemote.java
com.titan.cabin. —>Client1.java
jndi.propertiesredeployed the bean(wich works as always)
then executed the client.. it still throws the same exception
I dont understand why cannt i port such a small ANT functionality in myEclipse.please help me with this..i dont have time/patience to learn ANT scripting.! 🙁
I dont know if it will help..but i am pasting a part of the build.xml Deployment descriptor that ant uses to build the classfiles. and keeps the jndi.properties file in the classpath as well..
<!-- Build classpath --> <path id="classpath"> <fileset dir="${jboss.home}/client"> <include name="**/*.jar"/> </fileset> <pathelement location="${build.classes.dir}"/> <!-- So that we can get jndi.properties for InitialContext --> <pathelement location="${basedir}/jndi"/> </path> <property name="build.classpath" refid="classpath"/>
P.S they have kept the jndi.properties file in the jndi directory that’s why they point to the jndi/ directory
I would really appreciate your expert guidance on this issue.
Any other readers of the post , kindly please contribute …!
thanks all.!
robin
GregMemberIf you can’t get jndi.properties to work, can you try to use that code snippet that you have in the getInitialContext() method instead?
robinsinghMemberI tried uncommenting the snippet code and rest remains the same.
these are the exceptions thrown.:
what do you think about it.
kindly help
robinjavax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243) at javax.naming.InitialContext.init(InitialContext.java:219) at javax.naming.InitialContext.<init>(InitialContext.java:195) at com.titan.cabin.Client_1.getInitialContext(Client_1.java:50) at com.titan.cabin.Client_1.main(Client_1.java:16) Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:199) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:187) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:219) at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649) ... 5 more
GregMemberThis is a difference exception from what we saw before. Because it wasn’t finding the right properties to continue. Now it is continueing but it can’t find the class org.jnp.interfaces.NamingContextFactory. You will need to add the jbossall-client.jar file into your test project and then add it as a referenced jar in the Java Build Path.
robinsinghMemberOkay ,it worked by adding the .jar file in the JAVA BUILD PATH be doing the right click on the project->properties.Thanks .
but the following error comes while i run the client.
i added the log4j.jar and logkit.jar from jboss4\client in the project properties’
Java Build path
still it doesnt get resolved.Failed to initalize plugin: org.jboss.logging.Log4jLoggerPlugin@1be2d65 ----------- regular --- -- output --- -------------
help me with this.
———————
2)
one more strange thing is going on .:
i am trying to deploy one more project ejbProject41b.jar besides this ejbproject.jar on jboss4.0 final .myEclipse deploy utility deploys it successfully , the file gets copied into the deploy dir as well , but jboss doesnt acknowledge for some reason. the the corresponding client also doesnt run and says the component interfaces are not available (since the ejb has not been deployed..)i restarted the jboss A.S as well , but the same thing happens , it just acknowledges the first ejbproject.jar but not the second ejbproject41b.jar
on the command prompt.would u know why is this happening..!!
(p.S this for sure nothing about the ejb itself , since i have tried deploying both the ejb’s on the command prompt outside myEclipse using the antscripts it works fine.)robin
robinsinghMemberjust a quick follow up to to my last Query.sorry but
all that was done on the jboss 4.0 RC1 release ( and not Final version , though i mentioned otherwise in the Environment details on the top of the Query)okay when i noticed that its working in jboss 4.0 RC1, i started the jboss 4.0 final A.S , copied the corresponding jbossall-client.jar in the build path
and changed the application server connector appropriately . then i ran the same client_1.java program , it threw the following exception.
i am so surprised here.and the problem # 2 still continues with this version as well. (cannt deploy ejbproject_41.jar after i have deployed ejbproject.jar ., though the corresponding .jar files do get copied in the deploy dir . Ant scripts run it fine from the command prompt)
crux of the matter,jboss4.0final+myEclipse combo is adding to the problems and is not solving any of them.jboss4.0RC1+mE is still better in this case.
kindly help.
Failed to initalize plugin: org.jboss.logging.Log4jLoggerPlugin@1be2d65 javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.InvalidClassException: org.jnp.interfaces.MarshalledValuePair; local class incompatible: stream classdesc serialVersionUID = -6485622724173581497, local class serialVersionUID = -3403843515711139134] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:648) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:508) at javax.naming.InitialContext.lookup(InitialContext.java:347) at com.titan.clients.Client_1.main(Client_1.java:17) Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.InvalidClassException: org.jnp.interfaces.MarshalledValuePair; local class incompatible: stream classdesc serialVersionUID = -6485622724173581497, local class serialVersionUID = -3403843515711139134 at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164) at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:529) ... 3 more Caused by: java.io.InvalidClassException: org.jnp.interfaces.MarshalledValuePair; local class incompatible: stream classdesc serialVersionUID = -6485622724173581497, local class serialVersionUID = -3403843515711139134 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324) at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:146) ... 5 more
robinsinghMemberokay here’s the further follow up for the jboss4.0RC1+myEclipse combo.–problem
(summary::ejbproject.jar and its client works , but the second ejbproject_41b.jar doenst get deployed at al and its client cannt find the bean and crashes)i have two separate EJB projects in ex1 and ex2 directories.
i have made 2 separate EJB projects in myEclipse to contain the files of the ex1 and ex2 directories.i copy corresponding files ex1 –> ejbproject (this has one entity ejb called cabinEJB)
ex2 –> ejbproject_41b (this has 2 ejb called (entity)cabinEJB and (session)travelAgentEJB)while deploying,
ant scripts on the command prompt make titan.jar for both ex1 and ex2 ,
but myEclipse makes the corresponding .jars as ejbproject.jar and ejbproject_41b.jar
(as expected..nothing wrong with this.!)following is the result of operations done on the command prompt.
when deploying ejbproject.jar’s –> equivalent–> titan.jar first time from ant script)
.jar file has just one EJB called CabinEJBjboss has the following console output.
21:48:00,833 INFO [EjbModule] Deploying CabinEJB 21:48:02,576 INFO [CabinEJB] Table 'CabinEJB' already exists 21:48:02,586 INFO [EJBDeployer] Deployed: file:/E:/jboss4/server/default/deploy/titan.jar
when deploying ejbproject_41b.jar’s –> equivalent–> titan.jar second time from ant script)
.jar file has 2 ejb’s cabinEJB and TravelAgentEJbant script first undeploys the titan.jar having CabinEJB in it then
deploys the titan.jar having cabinEJB and travelagentEJB in it.that’s how it works for the command prompt .
jboss console output for second project.21:49:34,268 INFO [EJBDeployer] Undeploying: file:/E:/jboss4/server/default/deploy/titan.jar 21:49:34,288 INFO [EjbModule] Undeployed CabinEJB 21:49:34,288 WARN [DeploymentInfo] Could not delete file:/E:/jboss4/server/default/tmp/deploy/tmp42634titan.jar restart will delete it 21:49:34,638 INFO [EjbModule] Deploying CabinEJB 21:49:34,658 INFO [EjbModule] Deploying TravelAgentEJB 21:49:34,668 WARN [EjbModule] The Container Invoker session-webservice-invoker (in jboss.xml or standardjboss.xml) could not be created because of java.lang.Cl assNotFoundException: No ClassLoaders found for: org.jboss.net.ws4ee.server.EJBP roxyFactoryImpl We will ignore this error, but you may miss a transport for this bean. 21:49:35,059 INFO [CabinEJB] Table 'CabinEJB' already exists 21:49:35,099 INFO [EJBDeployer] Deployed: file:/E:/jboss4/server/default/deploy /titan.jar
but for the MyEClipse method, first ejbproject.jar(having cabinEJB gets copied) by myEclipse deploytool.
then when myEclipse deploytool copies ejbproject_41b.jar (having cabinEJB and travelagentEJB gets copied), jboss doesnt acknowledge itREASON FOR THE PROBLEM::
coz (this is what i think) the BEAN cabinEJB has already been registered under the container’s jndi context,
when i am trying to deploy another .jar file having the same cabinEJB in it (with some other bean) jboss wont let
this happen coz the jndi context already has cabinEJB registered in it.
STrangely : jboss doesnt throw an exception about this , but just keeps quiet.
(then may be i am wrong at this explanation)what cud be a workaround for this in myEclipse ????
Even if i undeploy the ejbproject.jar from the deploy dir. using m.E deploytool before deploying the ejbproject_41b.jar
even then it doesnt get acknowledged by jboss.now i am stuck.
robin
I am pasting the ant script(build.xml) for ur reference ,perhaps you can figure something out of this…
<?xml version="1.0"?> <!-- ======================================================================= --> <!-- JBoss build file --> <!-- ======================================================================= --> <project name="JBoss" default="ejbjar" basedir="."> <property environment="env"/> <property name="src.dir" value="${basedir}/src/main"/> <property name="src.resources" value="${basedir}/src/resources"/> <property name="jboss.home" value="${env.JBOSS_HOME}"/> <property name="build.dir" value="${basedir}/build"/> <property name="build.classes.dir" value="${build.dir}/classes"/> <!-- Build classpath --> <path id="classpath"> <fileset dir="${jboss.home}/client"> <include name="**/*.jar"/> </fileset> <pathelement location="${build.classes.dir}"/> <!-- So that we can get jndi.properties for InitialContext --> <pathelement location="${basedir}/jndi"/> </path> <property name="build.classpath" refid="classpath"/> <!-- =================================================================== --> <!-- Prepares the build directory --> <!-- =================================================================== --> <target name="prepare" > <mkdir dir="${build.dir}"/> <mkdir dir="${build.classes.dir}"/> </target> <!-- =================================================================== --> <!-- Compiles the source code --> <!-- =================================================================== --> <target name="compile" depends="prepare"> <javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="on" deprecation="on" optimize="off" includes="**"> <classpath refid="classpath"/> </javac> </target> <target name="ejbjar" depends="compile"> <jar jarfile="build/titan.jar"> <fileset dir="${build.classes.dir}"> <include name="com/titan/cabin/*.class"/> </fileset> <fileset dir="${src.resources}/"> <include name="**/*.xml"/> </fileset> </jar> <copy file="build/titan.jar" todir="${jboss.home}/server/default/deploy"/> </target> <target name="run.client_41a" depends="ejbjar"> <java classname="com.titan.clients.Client_1" fork="yes" dir="."> <classpath refid="classpath"/> </java> </target> <target name="run.client_41b" depends="ejbjar"> <java classname="com.titan.clients.Client_2" fork="yes" dir="."> <classpath refid="classpath"/> </java> </target> <!-- =================================================================== --> <!-- Cleans up generated stuff --> <!-- =================================================================== --> <target name="clean.db"> <delete dir="${jboss.home}/server/default/data/hypersonic"/> </target> <target name="clean"> <delete dir="${build.dir}"/> <delete file="${jboss.home}/server/default/deploy/titan.jar"/> </target> </project>
robinsinghMemberokay i figured it out.
1)i had to fix some glitches in the ejb-jar.xml
2)then i deployed it under a different <ejb-name> –> cabinEJb2
3)and changed the client code accordingly
Thanks for listening to me .
i appreciate your help in all my other problems as well.just for the record : for me jboss 4.0RC1 +myEclipse3.8.2 is working .
i am not gonna try it for jboss 4.0 final version . honestyl i have ran out of time and patience for this.by the way , all my programs run with this warning appended on the top of the console output :
Failed to initalize plugin: org.jboss.logging.Log4jLoggerPlugin@1cd2e5f
i have tried adding log4j.jar , logkit.jar and commons-logging.jar in the java build path for this project .
but it doesnt help . program runs but with this warning..any comments about this . ?
kindly help .robin
robinsinghMemberWell just out of curiosity , i tried running my (otherwise always running on jboss4.0 RC1) project on jboss4.0.0Final version.
(P.S : this project alwasy worked on RC1 version , never had problems with ejb-jar.xml with this one either.So there’s no possibility of any glitch whatsoever in it )–changed the java build path from e:\jbossRC1\client\jbossall-client.jar
–> e:\jbossFinal\client\jbossall-client.jar
— then redeployed the application
–but when i run the client…following exception gets thrown :
Now i am almost certain here taht i am not gonna try jboss 4 final version any more … jboss RC1 is working for me in all the cases i want it to work.
( this is very disappointing.. :-()
if you guys do find any solution around it , then kindly let me know.
regards
robinFailed to initalize plugin: org.jboss.logging.Log4jLoggerPlugin@1be2d65 javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.InvalidClassException: org.jnp.interfaces.MarshalledValuePair; local class incompatible: stream classdesc serialVersionUID = -6485622724173581497, local class serialVersionUID = -3403843515711139134] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:648) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:508) at javax.naming.InitialContext.lookup(InitialContext.java:347) at com.titan.clients.Client_1.main(Client_1.java:17) Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.InvalidClassException: org.jnp.interfaces.MarshalledValuePair; local class incompatible: stream classdesc serialVersionUID = -6485622724173581497, local class serialVersionUID = -3403843515711139134 at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164) at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:529) ... 3 more Caused by: java.io.InvalidClassException: org.jnp.interfaces.MarshalledValuePair; local class incompatible: stream classdesc serialVersionUID = -6485622724173581497, local class serialVersionUID = -3403843515711139134 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324) at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:146) ... 5 more
pjrichterMemberI’m running Eclipse 3.1R4, MyEclipse 3.8.3, JBoss 3.2.5, & WASP web services.
I added another project to my JBoss IDE classpath and starting getting the Failed to initalize plugin: org.jboss.logging.Log4jLoggerPlugin error repeatedly, and JBoss would no longer run through the IDE (I could start it through a command line).
It turns out, that the project I added, referenced a .jar that had an older and incompatible version of Log4j. That .jar was added to my JBoss server config automatically when I made the change. As soon as I removed the conflicting jar, the problem went away.
Riyad KallaMemberThank you for the additional comments pjrichter, it will help our users troubleshoot possible problems in the future.
haobaba1MemberI just thought I would add this tidbit.
Since log4j runs as a singleton, is integrated into jboss, and jboss has a unified class loader it is not possible to instantiate another instance of log4j. The easiest way to use log4j with jboss it to modify the log4j.xml and add appenders and categories as needed.
If this is not convenient then this page has information about setting the class loader scope:
http://www.jboss.org/wiki/Wiki.jsp?page=Logging -
AuthorPosts