Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!

Vivek Gupta

Greenhorn
+ Follow
since May 02, 2005
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 Vivek Gupta

When I try to validate the following schema in Altova XML Spy, it gives me validation error. The idea is - either [customerId & shipTo should be provided] or [orderdetails and billto should be provided]. But the XML instance can also provide the other elements optionally. So, a particular XML instance may have all the 4 elements -> cusotmerId, orderdetails, billto & shipto.

Any reason why is the schema not validating and what is the resolution?




Error
------
The schema doesn't appear to be valid by itself (as a part of another schema, it might still be OK).
'<xs:element name='customerId'>' makes the content model non-deterministic against '<xs:element name='customerId'>'. Possible causes: name equality, overlapping occurrence or substitution groups.
Error location: xs:schema / xs:complexType / xs:choice / xs:sequence / xs:element
Details
cos-nonambig: '<xs:element name='customerId'>' makes the content model non-deterministic against '<xs:element name='customerId'>'. Possible causes: name equality, overlapping occurrence or substitution groups.


--> 1 solution I had is define seprate elements for each of the choice group and declare it under ordertype. But this introduces a new element under "order". But this impacts the client code, if somebody has programmed according to the order of xml elements.

Any other way to have the xml structure as - no impact on client code with change in a valid schema



Thanks.
hi,
Cannot upgrade the JAXB version, since the Client Application using the generated classes is still on JDK 1.4.

However solved the issue, with JAXB external binding customization - reaching the First Element using XPath expression for the 1st child element of context node "ModelAssembly".



This worked.
Thanks.
10 years ago
hi Ivan,
I tried compiling the Schema in your post using JAXB compiler, but getting the following error

C:\>xjc Sample.xsd
parsing a schema...
[WARNING] Schema contains no global element declaration.
unknown location

[ERROR] A class/interface with the same name "generated.ModelAssembly.ModelIdentifier" is already in use.
line 19 of Sample.xsd


[ERROR] (Relevant to above error) another one is generated from here.
line 18 of Sample.xsd

Failed to parse a schema.
---------------------------------------------------------------------------------------------------------------------------------
C:\>xjc -version
xjc version "1.0.2-b15-fcs"
JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build 1.0.2-b15-fcs)


Is the error due to earlier version of JWSDP - JAXB RI 1.0.2 I am using?
10 years ago
I have following xsd: Schema3.xsd

1. <?xml version="1.0"?>
2. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3. <xsd:include schemaLocation="../Schema1.xsd"/>
4. <xsd:include schemaLocation="../Schema2.xsd"/>
5. <xsd:complexType name="ModelAssembly">
6. <xsd:sequence>
7. <xsd:element name="ModelIdentifier" type="ModelIdentifier"/>
8. <xsd:element name="ModelIdentifier" type="ModelIdentifier" minOccurs="0"/>
9. <xsd:element name="ModelRelationship" type="ModelRelationship" maxOccurs="unbounded"/>
10. </xsd:sequence>
11. </xsd:complexType>
12. </xsd:schema>

**I CANNOT CHANGE THE XSD. THIS IS A VALID XSD, although not a good design **

What mapping can I follow in an external bindings.xjb file to generate the Java Classes successfully.

I get the following error during JAXB compiler run-

[ERROR] A class/interface with the same name "ModelIdentifier" is already in use. line 8 of Schema3.xsd

[ERROR] (Relevant to above error) another one is generated from here. line 7 of Schema3.xsd

I have the work-around with the inline-customization - introducing the xsd:annotation & xsd:appinfo elements combined with jaxb:class declaration within any one of the ModelIdentifier element in the above Schema. But I need it in an external bindings file.
10 years ago
hi,
I have 2 drop downs - one for Country and the other for State. On JSF page load, the Country List is populated. But the State list will be updated only at the selection of the Country. The managed bean has 2 ArrayList, one each for State and Country and also has a Hashmap which has mapping of country with a list of states. The HashMap and the ArrayList of Country has been populated from the WebService call. The arraylist for states is refreshed each time the country is selected.
The arraylist of states is refreshed from the HashMap only.

I implemented this scenario as following-

1.Add the State drop-down to a Panel Group(h:panelGroup). Add the Ajax Support to the Panel and select the Refresh(hx:ajaxRefreshRequest) as the Ajax Request. The request param is passed as the country selected.
2.Specify the behaviour of the country drop-down for onchange event(onActionFunction).
The following was used as a reference to implement this part-
Ajax Supported Java Server Faces Components
3.The Javascript function executed on "onActionFunction" will make Ajax request [Refer to Ajax JSP example] to a Servlet which has a doGet method to update the session with the States ArrayList corresponding to the country selected. This country was passed as input parameter to the Servlet.

This serves my purpose. But I am posting this in order to get any alternative or a better approach to solve the issue - refresh the State list on the selection of country, without any hardcoding(of state and country) on the client side and using only JSF. The whole page should not refresh (even with skipping the validation using immediate as true).

Can anybody suggest if the hx:ajaxRefreshRequest can help me in refresh of the state list without the XMLHttpRequest. Where do I need to add the code for refreshing the state arraylist in session after selecting the list from HashMap<Country:States> if I just use "hx:ajaxRefreshRequest"? The arraylists are directly used in the drop-downs - for example:
......................
......................
<h:selectOneMenu id="country" value="#{MyBean.country}">
<f:selectItems value="#{MyBean.arrlstCountry}"/>
......................
......................

Thanks & Regards
Vivek Gupta
11 years ago
JSF
hello,
I set up the JBoss App Server on my official notebook and was successful in calling up the HelloWorldEJB and print the "Hello" on the StandardOutput of App Server. No special configuration required to set up the environment and simply followed the O'Reilly's book, JBoss Installation & Configuration guide..etc..all standard stuff.

Probably the machine I used before had some other issues, may be with some firewall settings or any "illicit" software installed which would prohibit such remote calls, I could not figure out the exact reason though.

Thanks a lot guys for your valuable inputs and continued support.

Regards
Vivek
[Preparing for SCBCD 5 ...]
hi
it does not help. I end up with the same error.
Thanks.
OS: Microsoft Windows XP [Home Edition Version 2002, Service Pack 2].
----------------------------------------------------------------------
JAVA: java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Client VM (build 1.5.0_15-b04, mixed mode, sharing)
----------------------------------------------------------------------
I start JBoss using the "run" batch in the bin folder of JBOSS. No -b option is used. The hosts file has an entry of 127.0.0.1 with host name as "localhost".
----------------------------------------------------------------------
===============================================================================

JBoss Bootstrap Environment

JBOSS_HOME: C:\jboss4

JAVA: C:\Program Files\Java\jdk1.5.0_15\\bin\java

JAVA_OPTS: -Dprogram.name=run.bat -server -Xms128m -Xmx512m
-Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=
3600000

CLASSPATH: C:\Program
Files\Java\jdk1.5.0_15\\lib\tools.jar;C:\jboss4\bin\run.jar

===============================================================================

10:22:57,703 INFO [Server] Starting JBoss (MX MicroKernel)...
10:22:57,734 INFO [Server] Release ID: JBoss [Trinity] 4.2.2.GA
(build: SVNTag=JBoss_4_2_2_GA date=200710221139)
10:22:57,765 INFO [Server] Home Dir: C:\jboss4
10:22:57,765 INFO [Server] Home URL: file:/C:/jboss4/
10:22:57,765 INFO [Server] Patch URL: null
10:22:57,765 INFO [Server] Server Name: default
10:22:57,765 INFO [Server] Server Home Dir: C:\jboss4\server\default
10:22:57,765 INFO [Server] Server Home URL: file:/C:/jboss4/server/default/
10:22:57,765 INFO [Server] Server Log Dir: C:\jboss4\server\default\log
10:22:57,765 INFO [Server] Server Temp Dir: C:\jboss4\server\default\tmp
10:22:57,765 INFO [Server] Root Deployment Filename: jboss-service.xml
10:22:58,500 INFO [ServerInfo] Java version: 1.5.0_15,Sun Microsystems Inc.
10:22:58,500 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_15-b04,Sun Microsystems Inc.
10:22:58,500 INFO [ServerInfo] OS-System: Windows XP 5.1,x86
10:22:59,937 INFO [Server] Core system initialized
10:23:07,328 INFO [WebService] Using RMI server codebase: http://127.0.0.1:8083/
10:23:07,343 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:jboss-log4j.xml
10:23:09,734 INFO [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
10:23:09,734 INFO [TransactionManagerService] Setting up property manager MBean and JMX layer
10:23:10,234 INFO [TransactionManagerService] Starting recovery manager
10:23:10,375 INFO [TransactionManagerService] Recovery manager started
10:23:10,390 INFO [TransactionManagerService] Binding TransactionManager JNDI Reference
10:23:17,906 INFO [EJB3Deployer] Starting java:comp multiplexer
10:23:18,781 INFO [STDOUT] no object for null
10:23:18,781 INFO [STDOUT] no object for null
10:23:18,906 INFO [STDOUT] no object for null
10:23:18,953 INFO [STDOUT] no object for {urn:jboss:bean-deployer}supplyType
10:23:19,031 INFO [STDOUT] no object for {urn:jboss:bean-deployer}dependsType
10:23:24,000 INFO [NativeServerConfig] JBoss Web Services - Native
10:23:24,000 INFO [NativeServerConfig] jbossws-native-2.0.1.SP2 (build=200710210837)
10:23:26,578 INFO [Embedded] Catalina naming disabled
10:23:26,796 INFO [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments
was not found on the java.library.path: C:\Program
Files\Java\jdk1.5.0_15\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\Borland\BCC55\Bin;C:\
Program Files\Java\jre1.5.0_15\bin;C:\Program
Files\Java\jdk1.5.0_15\bin;C:\apache-ant-1.7.0\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WIND
OWS\System32\Wbem
10:23:27,265 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-127.0.0.1-8080
10:23:27,265 INFO [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-127.0.0.1-8009
10:23:27,265 INFO [Catalina] Initialization processed in 683 ms
10:23:27,265 INFO [StandardService] Starting service jboss.web
10:23:27,265 INFO [StandardEngine] Starting Servlet Engine: JBossWeb/2.0.1.GA
10:23:27,328 INFO [Catalina] Server startup in 62 ms
10:23:27,546 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=.../deploy/jboss-web.deployer/ROOT.war/
10:23:29,281 INFO [TomcatDeployer] deploy, ctxPath=/invoker, warUrl=.../deploy/http-invoker.sar/invoker.war/
10:23:29,609 INFO [TomcatDeployer] deploy, ctxPath=/jbossws, warUrl=.../deploy/jbossws.sar/jbossws-context.war/
10:23:30,687 INFO [TomcatDeployer] deploy, ctxPath=/jbossmq-httpil, warUrl=.../deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/
10:23:32,921 INFO [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=.../deploy/management/console-mgr.sar/web-console.war/
10:23:34,671 INFO [MailService] Mail Service bound to java:/Mail
10:23:34,890 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-local-jdbc.rar
10:23:34,968 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-xa-jdbc.rar
10:23:35,015 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-local-jdbc.rar
10:23:35,109 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-xa-jdbc.rar
10:23:35,187 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jms/jms-ra.rar
10:23:35,281 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/mail-ra.rar
10:23:35,343 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/quartz-ra.rar
10:23:35,343 INFO [QuartzResourceAdapter] start quartz!!!
10:23:35,453 INFO [SimpleThreadPool] Job execution threads will use class loader of thread: main
10:23:35,484 INFO [QuartzScheduler] Quartz Scheduler v.1.5.2 created.
10:23:35,500 INFO [RAMJobStore] RAMJobStore initialized.
10:23:35,500 INFO [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz pac
kage: 'quartz.properties'
10:23:35,500 INFO [StdSchedulerFactory] Quartz scheduler version: 1.5.2
10:23:35,500 INFO [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
10:23:36,343 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JN
DI name 'java efaultDS'
10:23:37,031 INFO [A] Bound to JNDI name: queue/A
10:23:37,031 INFO [B] Bound to JNDI name: queue/B
10:23:37,031 INFO [C] Bound to JNDI name: queue/C
10:23:37,031 INFO [D] Bound to JNDI name: queue/D
10:23:37,046 INFO [ex] Bound to JNDI name: queue/ex
10:23:37,093 INFO [testTopic] Bound to JNDI name: topic/testTopic
10:23:37,109 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
10:23:37,109 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
10:23:37,109 INFO [testQueue] Bound to JNDI name: queue/testQueue
10:23:37,171 INFO [UILServerILService] JBossMQ UIL service available at : /127.0.0.1:8093
10:23:37,718 INFO [DLQ] Bound to JNDI name: queue/DLQ
10:23:37,921 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to
JNDI name 'java:JmsXA'
10:23:38,000 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
10:23:38,437 INFO [EARDeployer] Init J2EE application: file:/C:/jboss4/server/default/deploy/chapter1.ear
10:23:38,796 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
10:23:38,796 INFO [JmxKernelAbstraction] installing MBean:
jboss.j2ee:ear=chapter1.ear,jar=chapter1-ejb.jar,name=HelloUserBean,service
=EJB3 with dependencies:
10:23:39,140 INFO [EJBContainer] STARTED EJB: ejb3inaction.example.HelloUserBean ejbName: HelloUserBean
10:23:39,218 INFO [EJB3Deployer] Deployed: file:/C:/jboss4/server/default/tmp/deploy/tmp37664chapter1.ear-contents/chapter1-ejb.jar
10:23:39,359 INFO [EARDeployer] Started J2EE application: file:/C:/jboss4/server/default/deploy/chapter1.ear
10:23:39,484 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
10:23:39,515 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
10:23:39,531 INFO [Server] JBoss (MX MicroKernel) [4.2.2.GA (build:
SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 41s:766ms
I used the localhost:1099, but get the following exception- Any clue

javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Permission denied: Datagram send failed [Root exception is java.net.
SocketException: Permission denied: Datagram send failed] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.SocketException: Permission den
ied: connect]]]
hi,
I am running a simple "HelloUser" client with the Session Bean deployed on JBoss 4.2.2 AS. No Eclipse IDE is used.
When I try to run the client I get the following exception - any clue How I can get past over it-
--------------------------------------------------------------------------
javax.naming.CommunicationException: Could not obtain connection to any of these urls: 127.0.0.1:1099
and discovery failed with error: javax.naming.CommunicationException: Permission denied: Datagram send failed [Root exception is java.net.SocketException: Permission denied: Datagram send failed] [Root ex
ception is javax.naming.CommunicationException: Failed to connect to server 127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 127.0.0.1:1099 [Root exception is java.net.SocketException: Permission denied: connect]]]
at org.jnp.interfaces.NamingContext.checkRefNamingContext.java:1562)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(Unknown Source)
at ejb3inaction.example.HelloUserClient.main(HelloUserClient.java:16)
Caused by: javax.naming.CommunicationException: Failed to connect to server 127.0.0.1:1099 [Root excep
tion is javax.naming.ServiceUnavailableException: Failed to connect to server 127.0.0.1:1099 [Root exc
eption is java.net.SocketException: Permission denied: connect]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server 127.0.0.1:1099 [Root
exception is java.net.SocketException: Permission denied: connect]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
... 5 more
Caused by: java.net.SocketException: Permission denied: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.jnp.interfaces.TimedSocketFactory.createSocketTimedSocketFactory.java:84)
at rg.jnp.interfaces.TimedSocketFactory.createSocketTimedSocketFactory.java:77)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244)
... 5 more
---------------------------------jndi.properties-------------------------
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jnp.interfaces
java.naming.provider.url=127.0.0.1:1099 [same exception when localhost is used]
-----------------------------------Client Code-----------------------------
package ejb3inaction.example;

import javax.ejb.EJB;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;

public class HelloUserClient {
public static void main(String[] args) {
try{
Context ic = new InitialContext();
HelloUser helloUser = (HelloUser)ic.lookup("HelloUserBean");
helloUser.sayHello("Curious George");
System.out.println("Invoked EJB successfully .. see server console for output");
}
catch(Exception e){
e.printStackTrace();
}
}
private static Context getInitialContext() throws NamingException{
Context ic = new InitialContext();
return ic;
}
}
--------------------------------------------------------------------------

Thanks & Regards
Vivek
[ May 06, 2008: Message edited by: Vivek Gupta ]
hi,
I am currently going through Spring Framework which starts the discussion with bashing EJB for its overheads.
Could my fellow ranchers help me decide upon going for SCBCD or not? since, Spring Framework projects as if EJBs are very soon going to be a passe...
Will learing EJB and getting certified be helpful in future, and which version of the SCBCD exam to go for? Which book to go through, in order to appear for the exam?

Thanks for your comments and suggestions.

Regards
Vivek
SCJP 1.4(95%), SCWCD(90%)
Can you please post the link to those difficult mock exams?
Thanks.
There are some sample questions at
http://www.javacertificate.net/scwcd_1/2/3/4.htm
I am sure you are not talking about them!!
How can I retrieve the value in the hidden input if there is a single quote involved in the value of the hidden attribute

For example
<INPUT TYPE=hidden name='hdInput' value='JSP's Content'>

At back-end(Java Code), I could only retrieve JSP for hdInput.
How can I get the complete JSP's Content
13 years ago
JSP
How can I retrieve the value in the hidden input if there is a single quote involved in the value of the hidden attribute

For example
<INPUT TYPE=hidden name='hdInput' value='JSP's Content'>

At back-end(Java Code), I could only retrieve JSP for hdInput.
How can I get the complete JSP's Content
Could someone explain me the following - Why the answer is option 1?
Q:
Which of the given statements are correct regarding the following JSP page code?

<jsp:useBean id="mystring" class="java.lang.String" />
<jsp:setProperty name="mystring" property="*" />
<%=mystring%>

Assume that the request for this page contains a parameter mystring=hello.

Options
Select 1 correct option.

1.It will print "".
2.It will print "hello"
3.It will not compile.
4.It will throw exception at runtime.