This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!

Blikkies Marais

Ranch Hand
+ Follow
since Jun 12, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Blikkies Marais

Hi Anayonkar Shivalkar,

Please can you delete this post, I will add a new edited one.

Thanks for the advise
Hi,

I have the following integration test case that starts up 3 embedded jetty servers, and runs unit tests against them. My problem is that while the JUnit class is running, it gets stuck in the waitForStartup method, while the servers return "Connection to https://localhost:8440 refused" ("Connect to localhost:8440 timed out. Connection will be retried using another IP address") it is stuck in a loop waiting for the servers to be ready to run the tests against.

Once I terminate the JUnit test, with the servers still running, then I can access the servers via a browser or Poster (i.e. 200 return code). It is as if the unit test is holding onto the server threads I think. I want the servers to run in separate threads (see where I start the serves).
(While the test is still running the tests httpClient, a browser and Poster all timeout. But once the test is terminated, a browser and Poster can do a GET returning a 200.)

I think it's something to do with the processes are not released from the unit test thread.

Please can you have a look at my code and if you know why the servers seem stuck, please can you advise?

Thanks

Edit: Removed disputed code
Hi All,

I am using Hibernate and JPA. Please can you look at the folowing question:

https://forum.hibernate.org/viewtopic.php?f=1&t=1025568

If you can assist it's appreciated.

Sorry, it was my mistake, it is generating correctly, I just missed it.
I am using Castor to generate java beans from a xml schema. However, it is not generating the expected results.

I have a schema (Letters.xsd) and am using Castor version 1.0.3, but have also tried the latest version of Castor (version 1.1.2.1) with the same results.

I am looking at changing the Letters.xsd to make the 'Signatory' mandatory, so I set the 'minOccurs' to 1.

<xs:complexType name="MaturityLetter">
<xs:sequence>
<xs:element ref="ControlData" />
<xs:element ref="MaturityCase" minOccurs="0" />
<xs:element ref="UnitLifeContract" maxOccurs="10" />
<xs:element ref="Recipient" />
<xs:element ref="LifeAssured" />
<xs:element ref="Lender" minOccurs="0" />
<xs:element ref="Claimant" />
<xs:element ref="Grantee" minOccurs="0" maxOccurs="3" />
<xs:element ref="Signatory" minOccurs="1" maxOccurs="10" />
<xs:element ref="MoneyLaundering" minOccurs="0" maxOccurs="6" />
<xs:element ref="Requirement" minOccurs="0" maxOccurs="60" />
<xs:element ref="Payment" minOccurs="0" maxOccurs="10" />
<xs:element ref="FundQuote" minOccurs="0" maxOccurs="100"/>
<xs:element ref="Pack" />
<xs:element ref="Fmisa" minOccurs="0" maxOccurs="10"/>
</xs:sequence>
<!-- type of document -->
<xs:attributeGroup ref="attrDocumentStyle"/>
</xs:complexType>

However, when I generate the java beans, this check is not there. There is a check for the existing 'maxOccurs="10"' though.

E.g.
if (!(index < 10)) {
throw new IndexOutOfBoundsException("setSignatory has a maximum of 10");

There is no check whether there is at least one Signatory. I have tried removing minOccurs, because the default is supposed to be minOccurs="1" anyway, but still the same result.

Any Ideas? Thanks
[ December 05, 2007: Message edited by: Blikkies Marais ]
I know that the xslt does not have a default namespace, but a namespace of xmlns:solvit="http://resources.vero.co.nz/schemas/ClientEnabler". But when I make this the default namespace (to match the xml) it gets no output. Is one not allowed to define default namespaces in xlt's?
[ March 05, 2006: Message edited by: Blikkies Marais ]
I have some xml that I need to transform to an xml output. However, when the xslt does a xpath lookup on the xml, it cannot find the xml element. This is because it cannot find the namespace.

How do I get this to work if I cannot change the xml, but I can modify the xslt?


<getClientRequest xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://resources.vero.co.nz/schemas/ClientEnabler">
<versionId>2.0</versionId>
<client>
<clientId>
<value>7246272</value>
</clientId>
</client>
</getClientRequest>





<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:solvit="http://resources.vero.co.nz/schemas/ClientEnabler"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2004/10/xpath-functions"
xmlns:xdt="http://www.w3.org/2004/10/xpath-datatypes"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="xsl xsi xdt fn xs #default">

<xsl:template match="*"/>
<xsl:template match="solvit:getClientRequest">
<xsl:element name="SOLVIT">
<xsl:element name="XMLHead">
<xsl:element name="Service">ENQUIRECLIENT</xsl:element>
</xsl:element>
<xsl:element name="XMLData">
<xsl:element name="Client">
<xsl:element name="CLTKY"><xsl:value-of select="client/clientId/value"/></xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>

</xsl:stylesheet>
[ March 05, 2006: Message edited by: Blikkies Marais ]
I managed to get the Universal Test Client to run my session EJB. But oly once I changed the 'Server Connection Type and Admin port' in the server overview from RMI(Better performance) to SOAP(More firewall compatable)? - I guess the firewall must have been affecting it. But it does not expln wht I could not do local lookups, but the client work now.

However, I cannot seem to invoke the session EJB from outside the client still. How do I testt what the JNDI name is?

In the Universal Test Clienrt, when I expand the JNDI Explorer, I can see my EJB there (Method visibility, create()). But how do I know what the JNDI names? (The name I should put in the ctx.lookup("xxx")?
14 years ago
Thansk Jeanne,

I am using IBM Rational Application Developer 6 with WebSphere 6 server.

Do you know how I can invoke the test client n this tool?
14 years ago
Hi,

I am new to EJB, so please can someone help. I am trying to access a stateless session EJB from a class but am having some problems. I am using Rational Application Developer 6 with Websphere Application Server 6.

I have been trying a number of different ways to do a JNDI lookup on the session EJB. Whic I will give examples of below. I am using a class with a main method to test this. I have an EJB Project that contins a session EJB called "Manager". Then I have a Web Project that has a class with a main method which is trying to access the EJB in the EJB Project.

I have 'Run Validation' over the EJB project successfully. I then did a 'Deploy' over the EJB Project.I have modified the Web Projects web.xml file to contain the Manager EJB (see below). I make sure the WAS6 server is running. Then I invoke the test class with the main method:


(1) When I try the following:
<pre>

Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
prop.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809/");
javax.naming.InitialContext ctx = new InitialContext(prop);
Object obj = ctx.lookup("cell/nodes/localhost/servers/server1/ejb/Manager");
ManagerHome ejbHome = (ManagerHome)
PortableRemoteObject.narrow(obj,ManagerHome.class);

</pre>

I get the folowing Exception:

<pre>
javax.naming.NameNotFoundException: Context: your-ky2idxv32cNode01Cell/nodes/your-ky2idxv32cNode01/servers/server1, name: cell/nodes/localhost/servers/server1/ejb/Manager: First component in name localhost/servers/server1/ejb/Manager not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNaming/NamingContext/NotFound:1.0
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:85)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:4045)
....

</pre>

(2) When I try:
<pre>

Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
prop.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809/");
javax.naming.InitialContext ctx = new InitialContext(prop);
Object obj = ctx.lookup("java:comp/env/ejb/org/omg/stub/javax/ejb/manager/ManagerHome");
ManagerHome ejbHome = (ManagerHome)
PortableRemoteObject.narrow(obj,ManagerHome.class);
</pre>

I get the following Exception:
<pre>

06-Aug-2005 10:48:05 com.ibm.ws.naming.java.javaURLContextFactory
SEVERE: javaAccessorNotSet
javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:73)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:592)
....
</pre>

(3) When I try:
<pre>

Object obj = ctx.lookup("java:comp/env/ejb/Manager");
or:
Object obj = ctx.lookup("java:comp/env/ejb/org/omg/stub/javax/ejb/manager/Manager");
or:
Object obj = ctx.lookup("java:comp/env/ejb/manager/Manager");
or:
Object obj = ctx.lookup("java:comp/env/ejb/manager/ManagerHome");
or:
Object obj = ctx.lookup("java:comp/env/ejb/ManagerHome");

I have also tried all of the above without setting the the properties in the InitialContext() constructor.

javax.naming.InitialContext ctx = new InitialContext();

</pre>

I get the same Exception:

<pre>
06-Aug-2005 10:50:42 com.ibm.ws.naming.java.javaURLContextFactory
SEVERE: javaAccessorNotSet
javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:73)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:592)


</pre>

My ejb-jar.xml in the EJB Project is the following:

<pre>
[?xml version="1.0" encoding="UTF-8"?]
[ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"]
[display-name]MyProjectEJB[/display-name]
[enterprise-beans]
[entity id="Album"]
[ejb-name]Album[/ejb-name]
[home]org.omg.stub.javax.ejb.album.AlbumHome[/home]
[remote]org.omg.stub.javax.ejb.album.Album[/remote]
[local-home]org.omg.stub.javax.ejb.album.AlbumLocalHome[/local-home]
[local]org.omg.stub.javax.ejb.album.AlbumLocal[/local]
[ejb-class]org.omg.stub.javax.ejb.album.AlbumBean[/ejb-class]
[persistence-type]Container[/persistence-type]
[prim-key-class]java.lang.Integer[/prim-key-class]
[reentrant]false[/reentrant]
[cmp-version]2.x[/cmp-version]
[abstract-schema-name]Album[/abstract-schema-name]
[cmp-field id="CMPAttribute_1122977976160"]
[field-name]id[/field-name]
[/cmp-field]
[cmp-field id="CMPAttribute_1122977967979"]
[field-name]title[/field-name]
[/cmp-field]
[cmp-field id="CMPAttribute_1122977968069"]
[field-name]artist[/field-name]
[/cmp-field]
[primkey-field]id[/primkey-field]
[ejb-local-ref id="EJBLocalRef_1123062875138"]
[description]
[/description]
[ejb-ref-name]ejb/Album[/ejb-ref-name]
[ejb-ref-type]Entity[/ejb-ref-type]
[local-home]org.omg.stub.javax.ejb.album.AlbumLocalHome[/local-home]
[local]org.omg.stub.javax.ejb.album.AlbumLocal[/local]
[ejb-link]Album[/ejb-link]
[/ejb-local-ref]
[/entity]
[entity id="Track"]
[ejb-name]Track[/ejb-name]
[home]org.omg.stub.javax.ejb.track.TrackHome[/home]
[remote]org.omg.stub.javax.ejb.track.Track[/remote]
[local-home]org.omg.stub.javax.ejb.track.TrackLocalHome[/local-home]
[local]org.omg.stub.javax.ejb.track.TrackLocal[/local]
[ejb-class]org.omg.stub.javax.ejb.track.TrackBean[/ejb-class]
[persistence-type]Container[/persistence-type]
[prim-key-class]java.lang.Integer[/prim-key-class]
[reentrant]false[/reentrant]
[cmp-version]2.x[/cmp-version]
[abstract-schema-name]Track[/abstract-schema-name]
[cmp-field id="CMPAttribute_1122978061723"]
[field-name]id[/field-name]
[/cmp-field]
[cmp-field id="CMPAttribute_1122978061743"]
[field-name]fkalbumid[/field-name]
[/cmp-field]
[cmp-field id="CMPAttribute_1122978061783"]
[field-name]song[/field-name]
[/cmp-field]
[primkey-field]id[/primkey-field]
[ejb-local-ref id="EJBLocalRef_1123062875148"]
[description]
[/description]
[ejb-ref-name]ejb/Track[/ejb-ref-name]
[ejb-ref-type]Entity[/ejb-ref-type]
[local-home]org.omg.stub.javax.ejb.track.TrackLocalHome[/local-home]
[local]org.omg.stub.javax.ejb.track.TrackLocal[/local]
[ejb-link]Track[/ejb-link]
[/ejb-local-ref]
[/entity]
[session id="Manager"]
[ejb-name]Manager[/ejb-name]
[home]org.omg.stub.javax.ejb.manager.ManagerHome[/home]
[remote]org.omg.stub.javax.ejb.manager.Manager[/remote]
[local-home]org.omg.stub.javax.ejb.manager.ManagerLocalHome[/local-home]
[local]org.omg.stub.javax.ejb.manager.ManagerLocal[/local]
[service-endpoint]org.omg.stub.javax.ejb.manager.ManagerService[/service-endpoint]
[ejb-class]org.omg.stub.javax.ejb.manager.ManagerBean[/ejb-class]
[session-type]Stateless[/session-type]
[transaction-type]Container[/transaction-type]
[ejb-local-ref id="EJBLocalRef_1123065469238"]
[description]
[/description]
[ejb-ref-name]ejb/Manager[/ejb-ref-name]
[ejb-ref-type]Session[/ejb-ref-type]
[local-home]org.omg.stub.javax.ejb.manager.ManagerLocalHome[/local-home]
[local]org.omg.stub.javax.ejb.manager.ManagerLocal[/local]
[ejb-link]Manager[/ejb-link]
[/ejb-local-ref]
[/session]
[/enterprise-beans]
[/ejb-jar]
</pre>


My web.xml in the Web Project is the following:
<pre>

[?xml version="1.0" encoding="UTF-8"?]
[web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"]
[display-name]
MyProjectWeb[/display-name]
[welcome-file-list]
[welcome-file]index.html[/welcome-file]
[welcome-file]index.htm[/welcome-file]
[welcome-file]index.jsp[/welcome-file]
[welcome-file]default.html[/welcome-file]
[welcome-file]default.htm[/welcome-file]
[welcome-file]default.jsp[/welcome-file]
[/welcome-file-list]
[ejb-ref]
[ejb-ref-name]ejb/Manager[/ejb-ref-name]
[ejb-ref-type]Session[/ejb-ref-type]
[home]org.omg.stub.javax.ejb.manager.ManagerHome[/home]
[remote]org.omg.stub.javax.ejb.manager.Manager[/remote]
[/ejb-ref]
[/web-app]

</pre>


Please can some one give me some advice. Thanks

(Sorry that I have lost the xml tags when I pasted this here. I have tried to use escape characters, but they do not seem to work. I have replaced the "<" with "]")
14 years ago
Hi, I am running WebSphere 6. I am trying to do a lookup on an EJB. My code sample:

Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
prop.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809/");
javax.naming.InitialContext ctx = new InitialContext(prop);
Object obj = ctx.lookup("cell/nodes/localhost/servers/server1/ejb/Manager");
ManagerHome ejbHome = (ManagerHome)
PortableRemoteObject.narrow(obj,ManagerHome.class);


I get a ClassNotFoundException with 'WsnInitialContextFactory'. Because it is not in my classpath.

But where do I find the jar file that contains the 'WsnInitialContextFactory' class? What is it called, and where can I download it? Or am I supposed to use a different initial context factory class with WAS6? If so what?

Thanks in advance
14 years ago
Is there a new class in WAS6.0 that has taken the place of "com.ibm.websphere.naming.WsnInitialContextFactory"?

If so, what is it.

Thanks
14 years ago
I am trying to do a JNDI lookup to get a handle on an EJB (TrackHome). I am using WebSphere 6.0. My code is as follows:

Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
prop.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809/");
javax.naming.InitialContext ctx = new InitialContext(prop);
Object obj = ctx.lookup("ejb/album/AlbumHome");
TrackHome ejbHome = (TrackHome)
PortableRemoteObject.narrow(obj,TrackHome.class);


But when I run it I get the following error:

javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory. Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:375)
at java.lang.ClassLoader.loadClass(ClassLoader.java:562)
...

If I should not use "WsnInitialContextFactory", what should I use?

I am new to EJB, so please excuse me if this seems daft. Has anyone got any links to working with EJBs in WebSphere 6?


PS> I have tried "com.sun.jndi.fscontext.RefFSContextFactory", but get the following error:

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory. Root exception is java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:375)
at java.lang.ClassLoader.loadClass(ClassLoader.java:562)


and "com.ibm.ejs.ns.jndi.CNInitialContextFactory" but get:

javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.ejs.ns.jndi.CNInitialContextFactory. Root exception is java.lang.ClassNotFoundException: com.ibm.ejs.ns.jndi.CNInitialContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:375)
at java.lang.ClassLoader.loadClass(ClassLoader.java:562)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:442)
14 years ago
I am trying to create a connection in Rational Application Developer. I am tryig to connect to MySQL.

My Connection Details are:
Database: myschema
Host: localhost
Port no: 3306
JDBC driver class: com.mysql.jdbc.Driver (also tried: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource)
Class Location: ...workspace1\MyProjectWeb\WebContent\WEB-INF\lib\mysql-connector-java-3.1.10-bin.jar
Connection URL: jdbc:localhost:3306:myschema

Then I click Test Connection and get the folowing message: "No suitable driver" (or "MysqlConnectionPoolDataSource incompatibe with java/sql/Driver")

Has anyone managed to connect to MySQL Successfully in RAD6?
If so, what are your connection settings?

I am trying to do 'Bottom-up' creation of Entity EJBs. But can't connec to the database.

Any advise welcome.

Thanks
14 years ago