Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Srinivas Karthik

Greenhorn
+ Follow
since Sep 17, 2011
Srinivas likes ...
Eclipse IDE Java Oracle
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 Srinivas Karthik

Hello ranchers,

I am a java developer with experience in core java and J2EE (MVC,MVC2) concepts.I need to learn spring 3 now as a sudden requirement has come in.So, can you please suggest me some books or sources which go in a simple fashion with code examples etc.I need to attain perfection on Spring web and DAO(hibernate) modules.

Please let me know.

Thanks in advance.
4 years ago

Kesava Krishna wrote:Please paste the error you got.



I'm getting the below error when trying to create web service using Bottom-Up Approach.
Also please correct me If I'm doing some blunder here.

The service class "MyWebService" does not comply to one or more requirements of the JAX-RPC 1.1 specification, and may not deploy or function correctly.
The method "createConnection" on the service class "MyWebService" uses a data type, "java.sql.Connection", that is not supported by the JAX-RPC specification. Instances of the type may not serialize or deserialize correctly. Loss of data or complete failure of the Web service may result.
The value type "org.w3c.dom.Element" used via the service class "MyWebService" does not have a public default constructor. Chapter 5.4 of the JAX-RPC 1.1 specification requires a value type to have a public default constructor, otherwise a JAX-RPC 1.1 compliant Web service engine may be unable to construct an instance of the value type during deserialization.
The value type "org.w3c.dom.TypeInfo" used via the service class "MyWebService" does not have a public default constructor. Chapter 5.4 of the JAX-RPC 1.1 specification requires a value type to have a public default constructor, otherwise a JAX-RPC 1.1 compliant Web service engine may be unable to construct an instance of the value type during deserialization.

Thanks
4 years ago

William Brogden wrote:Sounds like a RESTful architecture to me but consider these questions:

1. Do your clients ever submit a request that modifies the database?
2. To what extent do you have to authenticate your clients?
3. Roughly how big is the XML response payload - are we talking 10,000 characters or millions?

Bill



1.The client doesn't modify the database but just queries and retrieves the information
2.No need of authentication
3.Hmm the xml size varies.Consider for the moment it's 10000 characters.

What should be done?
4 years ago
Greetings Ranchers,
I'm quite confused here.I need to develop a webservice which actually queries the database and create an xml out of it and put it in SOAP Body and return it.I used Axis which is a eclipse plugin Bottom up approach, when I gave my class as a webservice target. It said Connection not supported SOAPMessage not supported etc. I just couldn't find a way through this though I spent a lot of time in researching.So, I ended up in using REST webservice which queries the database and creates an XML and returns the document.But it is a temporary solution.

Please give your input on how to make things work the way I needed.
I recap what I need once again,
a.I need to create a webservice which queries the database and get some info and forms and xml out of it
b.But the formed xml in SOAP-Body and return the SOAPMessage

Also correct me if I'm wrong anywhere and point me to the right direction.

Thanks a lot in advance.


4 years ago
Hello Ranchers,
Good Morning.Could anyone suggest me a very good book for java muti-threading.I'm good with core java but I really want to learn multi-threading(Good Multithreading).I googled it and learnt that Java concurrency in practice is the best book for learning real multi threading.But some people say that it's not a beginner's book.So, please clarify and suggest me.

Thank you.
Thanks rudi. Could you please share with me some of the online tutorial links which will help me for the certification.Also I wanted to know if I just get started with the training lab material directly without any book, would it be possible to crack the certification.
Hello Ranchers,
I'm not new to java.I am good with core java and J2EE(Servlets/JSP). Now I want to learn EJB3.0 and then spring Mvc.So I just gave a thought that as I am a OCJP6.0 holder, why don't I take my preparation a little certification oriented so that in the process I'll gain knowledge and the certification.
Also wanted to know what are the prerequisites certifications for this exam Java EE 6 Enterprise JavaBeans Developer Certified Expert Exam. I have gone through some posts and got to know that, for EJB 3.0
"Enterprise Java Beans 3.1" by Bill Burke and Andrew Lee Rubinger " is a very good book.
I'm entirely new to EJB.So Please suggest me a better book if any. Also could you please tell me how much time is needed to achieve this certification(I completely understand that it depends on individual and lot other factors like time/Knowledge,memory power). Tell me an average time if I spent 2-3 hrs studying and practicing.

Thanks
Hello ranchers,

I am struggling with this problem since 2days, But not able 2 resolve it..
I created a simple JSP, which in turn instantiated and does some work, its a part of a big project though, it always throws the exception, I googled every possible way but din't find a perfect solution,
This is the error, log



It says that PolicyNameDAOBean, is already being registered. I checked many times there is only one instance of PolicyNameDAOBean.java in the project .ear file .

Please help me. I am in a big trouble


In the above code..
we have
private Set<StockDailyRecord> stockDailyRecords = new HashSet<StockDailyRecord>(0);

Why is the (0) after the declaration. what does that 0 do..
and why do we write it there.. I am dealing with a project currently .. I have similar code over there..can anyone explain me this please.
Hello guys,
Anyone here, Please explain me each line of code and its purpose..This is a client which tries to access the ejb bean.


Thanks in advance..
Heyy Guys,
I finally Made it..
I just started from the scratch and built the ejb application adn again got an error, error was like..

javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:10299 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost/127.0.0.1:10299 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/127.0.0.1:10299 [Root exception is java.net.ConnectException: Connection refused]]]

I used the web port number before here in my client file..
props.setProperty("java.naming.provider.url", "localhost:8080");
Later I explored evrything and found that I have to give the JNDI port number..I gave it as
props.setProperty("java.naming.provider.url", "localhost:1099");

and the result..Wooww My ejb executed successfully I accessed my ejb using a palin java client.. ..After a hell lot of struggle finally made it guys.. and my learning is in progress..will be posting
on in case of queries.
Thank you evryone for replying...
Cheers
Hello guys,
Can anyone please tell me whcih is the best book for hibernate. I am new to hibernate..
I searched the google for a sample ejb 3.0 execution using eclipse and jboss and found this link
I followed the same and after creating the three files I am trying to deploy But its giving an exception..
It is as follows


13:30:08,039 ERROR [AbstractKernelController] Error installing to Start: name=jboss.j2ee:jar=EjbProject.jar,name=MyBean,service=EJB3 state=Create
java.lang.ClassCastException: $Proxy271 cannot be cast to javax.naming.Context
at org.jboss.util.naming.Util.createSubcontext(Util.java:70)
at org.jboss.util.naming.Util.bind(Util.java:104)
at org.jboss.util.naming.Util.bind(Util.java:91)
at org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase.bind(JndiSessionRegistrarBase.java:910)
at org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase.bind(JndiSessionRegistrarBase.java:895)
at org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase.bind(JndiSessionRegistrarBase.java:884)
at org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase.bindEjb(JndiSessionRegistrarBase.java:151)
at org.jboss.ejb3.session.SessionContainer.lockedStart(SessionContainer.java:210)
at org.jboss.ejb3.session.SessionSpecContainer.lockedStart(SessionSpecContainer.java:577)
at org.jboss.ejb3.stateless.StatelessContainer.lockedStart(StatelessContainer.java:192)
at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:884)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:165)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
13:30:08,062 WARN [HDScanner] Failed to process changes
org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "jboss.j2ee:jar=EjbProject.jar,name=MyBean,service=EJB3_endpoint" is missing the following dependencies:
Dependency "jboss.j2ee:jar=EjbProject.jar,name=MyBean,service=EJB3" (should be in state "Configured", but is actually in state "**ERROR**")

DEPLOYMENTS IN ERROR:
Deployment "jboss.j2ee:jar=EjbProject.jar,name=MyBean,service=EJB3" is in error due to the following reason(s): java.lang.ClassCastException: $Proxy271 cannot be cast to javax.naming.Context, **ERROR**

at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:993)
at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:939)
at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:873)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.checkComplete(MainDeployerAdapter.java:128)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:369)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:165)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
It is a dead simple application. If its deployed I can write a client application and add the project.jar and proceed. But during deployment itself its throwing exceptions.
Can any one please figure out what's wrong here..

IMyBean.java:


MyBean.java


MyBeanLocal


MyBeanRemote


Please anyone figure out what's wrong. Do I need to import any jar files or something in my build path for execution of ejb's other than jdk from jboss..
Please I need this. Feeling so down, NOt able to execute a "hello world" in EJB's....
Hello Aravind,
Thanks a lot for the reply, Sure I will try this code and what do you mean by we do not need ejb-jar.xml means we don't need to configure them that's what you meant right.anyways I will try this code and get back to you. Thank you once again
Hello Syed,
Thanks a lot for your reply was waiting very badly for a reply. Yes, I am using EJB3.0 and I am new to EJB's thats why I am facing problems in executing these things, I can't use glassfish ,because I have to use JBoss 5.1 for the project so I am getting used to it by practicing using JBoss only.You said that ejb-jar.xml is not necessary, If i keep it will it be a problem and regarding jar I din't use any tool I just created it using concole I added my three .class files bean class, home and component interface's .class files and the ejb-xml.xml and made a jar and placed it in the deployment descriptor and trying to execute I am getting an exception.
only half of the program of the client is executing . This is the exception

DEPLOYMENTS IN ERROR:
Deployment "vfszip:/home/karthik/Documents/jboss-5.1.0.GA/server/default/deploy/EjbSample.jar/" is in error due to the following reason(s): java.lang.RuntimeException: Bean Class headfirst.AdviceBean has no local, webservice, or remote interfaces defined and does not implement at least one business interface: AdviceBean


xml:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.0" 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">
<display-name>EjbSample</display-name>
<enterprise-beans>
<session>
<ejb-name>Advice</ejb-name>
<home>headfirst.AdviceHome</home>
<remote>headfirst.Advice</remote>
<ejb-class>headfirst.AdviceBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

Client program
import headfirst.Advice;
import javax.naming.*;
import javax.rmi.*;
import java.rmi.*;
import headfirst.*;
import javax.ejb.*;
import java.util.Properties;

import javax.rmi.PortableRemoteObject;



@SuppressWarnings("unused")
public class AdviceClient {

public static void main(String k[])

{
new AdviceClient().go();
}

public void go() {
// TODO Auto-generated method stub

Properties pro=new Properties();
pro.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
pro.put(Context.PROVIDER_URL,"localhost:8080");

try
{

InitialContext jndi=new InitialContext(pro);
System.out.println("Got Context");
//Context ic=new InitialContext();

//Object o=ic.lookup("Advice");

Object o=jndi.lookup("Advice");
System.out.println("Got Reference");
AdviceHome home=(AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
Advice advisor=home.create();
System.out.println(advisor.getAdvice());

}
catch(Exception e)
{
System.out.println("error Now in catch");
}
}
}

I am getting the output as:
Got context
error now in catch...

It's always failing at this statement Object o=jndi.lookup("Advice");
and jumping to catch.
Please can you figure out what mistake I have done.
The home and component interfaces are un-changed.

Awaiting for your reply.
Thanks a lot in advance..