anshul bhatt

Greenhorn
+ Follow
since Sep 04, 2008
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 anshul bhatt

Hi,

I am running the the example from http://www.mkyong.com/struts2/struts-2-hibernate-integration-example/ .

But getting the following error:

Struts Problem Report

Struts has detected an unhandled exception:
Messages:
File: com/mkyong/customer/action/CustomerAction.java
Line number: 71
Stacktraces
java.lang.NullPointerException

com.mkyong.customer.action.CustomerAction.listCustomer(CustomerAction.java:71)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:662)

The line no 71 is

public String listCustomer() throws Exception{

//get hibernate session from the servlet context
SessionFactory sessionFactory =
(SessionFactory) ServletActionContext.getServletContext()
.getAttribute(HibernateListener.KEY_NAME);

line 71 Session session = sessionFactory.openSession();

customerList = session.createQuery("from Customer").list();

return SUCCESS;

}

I debugged it and show the following error at line 71

Open Declaration Session org.hibernate.SessionFactory.openSession() throws HibernateException
Note: An exception occurred while getting the Javadoc. See log for details.


Please help me with this.

Thanks
Regards
Anshul
10 years ago
Hi,

I want to display different languages in my website. Am able to save the language font in the mysql 5.0, however while retrieving it, it displays junk characters. My project is using spring+hibernate+struts 2. I tried to modify the files as

In Jsp:<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="utf-8"%>

In local.properties file : database.url=jdbc:mysql://localhost/PHONYLITE?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
This database.url is being used in applicationContext-services.xml, applicationContext.xml.

Am using tomcat so changed server.xml as : <Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />


Have also put in this in hibernate.properties in applicationContext-services.xml




<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
<prop key="hibernate.show_sql">${hibernate.showSql}</prop>
<prop key="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</prop>
<prop key="hibernate.connection.url">${database.url}</prop>
<!-- jdbc:mysql://localhost/mydb?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8, -->
<prop key="hibernate.connection.username">root</prop>
<prop key="hibernate.connection.password">root</prop>

<prop key="hibernate.connection.useUnicode">true</prop>
<prop key="hibernate.connection.characterEncoding">UTF-8</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>

Still am not able to display the characters, any help would be really appreciated

Thanks
Regards
Anshul Bhatt


10 years ago
JSP
Hi,
I am trying to call local EJB2.1 stateless session bean via java main class but getting this error. I am using netbeans6.5 with glassfish v2, however am able to successfully call EJB2.1 remote session bean. the java client code is as follows:

import hi.helloLocal;
import hi.helloLocalHome;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

/**
*
* @author anshul
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String s="-"; // Just declare a string
try {
Context context = new InitialContext();

helloLocalHome myhelloHomeLocal = (helloLocalHome)context.lookup("java:comp/env/hi/helloBean");

helloLocal myhelloLocal = myhelloHomeLocal.create();
// So, just go ahead and call a method (in this case the only method).
s = myhelloLocal.hello();
System.out.println(s);
}
catch (Exception e) {
System.err.println("errorr" +e);
s=e.toString();
}


}
}
Hi Goyal,

I was not able to resolve it if you have then please tell me the solution.
11 years ago
Hi Ivan,

I am trying to code as per the javaee5 tutorial, i am following the tutorial as follows

Coding the Service Endpoint
Implementation Class
In this example, the implementation class, Hello, is annotated as a web service
endpoint using the @WebService annotation. Hello declares a single method
named sayHello, annotated with the @WebMethod annotation. @WebMethod
exposes the annotated method to web service clients. sayHello returns a greeting
to the client, using the name passed to sayHello to compose the greeting.
The implementation class also must define a default, public, no-argument constructor.
package helloservice.endpoint;
import javax.jws.WebService;
@WebService()
public class Hello {
private String message = new String("Hello, ");
public void Hello() {}
@WebMethod()
public String sayHello(String name) {
return message + name + ".";
}
}
Building the Service
To build HelloService, in a terminal window go to the
<INSTALL>/javaeetutorial5/examples/jaxws/helloservice/ directory and
type the following:
asant build
The build task command executes these asant subtasks:
• compile-service

The compile-service Task
This asant task compiles Hello.java, writing the class files to the build subdirectory.
It then calls the wsgen tool to generate JAX-WS portable artifacts used
by the web service. The equivalent command-line command is as follows:
wsgen -d build -s build -classpath build
helloservice.endpoint.Hello
The -d flag specifies the output location of generated class files. The -s flag
specifies the output location of generated source files. The -classpath flag
specifies the location of the input files, in this case the endpoint implmentation
class, helloservice.endpoint.Hello.
Packaging and Deploying the Service
You package and deploy the service using asant.
Upon deployment, the Application Server and the JAX-WS runtime generate any
additional artifacts required for web service invocation, including the WSDL
file.
Packaging and Deploying the Service with
asant
To package and deploy the helloservice example, follow these steps:
1. In a terminal window, go to
<INSTALL>/javaeetutorial5/examples/jaxws/helloservice/.
2. Run asant create-war.
3. Make sure the Application Server is started.
4. Set your admin username and password in
<INSTALL>/javaeetutorial5/examples/common/build.properties.
5. Run asant deploy.
You can view the WSDL file of the deployed service by requesting the URL
http://localhost:8080/helloservice/hello?wsdl in a web browser. Now
you are ready to create a client that accesses this service.


It gives me error @ 5th command, i will be glad if you can tell me cause of it.

I am following the following tutorial "http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/2.0/tutorial/doc/AboutJWSDP4.html"

first example from Building Web Services
with JAX-WS chapter.


11 years ago
I am new to webservices am trying to deploy using asant deploy command, the error am getting is

BUILD FAILED
c:\jwstutorial20\examples\jaxws\helloservice\build.xml:29: The following error occurred while executing this line:
c:\jwstutorial20\examples\common\targets.xml:125: An exception occurred while running the command. THE exception message is CLI171: Command deploy failed: Deploying application in domain failed; WSGEN FAILED.

please help if someone knows how to resolve this

Thanks

A. B.

This what Glassfish server log says:


[#|2011-01-23T13:10:13.609+0530|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=29;_ThreadName=Thread-1868;|

Examples:
wsgen -cp . example.Stock
wsgen -cp . example.Stock -wsdl -servicename {http://mynamespace}MyService
|#]

[#|2011-01-23T13:10:13.812+0530|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|_ThreadID=29;_ThreadName=Thread-1868;_RequestID=99f77165-b2bc-4140-a812-5923bb15a56c;|Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: WSGEN FAILED
at com.sun.enterprise.webservice.WsUtil.genWSInfo(WsUtil.java:2256)
at com.sun.enterprise.deployment.backend.ModuleDeployer.loadDescriptors(ModuleDeployer.java:424)
at com.sun.enterprise.deployment.backend.WebModuleDeployer.deploy(WebModuleDeployer.java:157)
at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:179)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:191)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:919)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:279)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:788)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:187)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:223)
11 years ago
hi,

I was able to resolve the issue, yes you are quite right jboss4.0 doesnt support ejb3.0, however you can instali jemsinstaller made for the the particular server to make it compatible with ejb 3.0, coming back to the main issue that was completely my fault
i was using jboss 4.0.4 and jems installer designed for jboss as 4.0.5, different versions of jre were also causing the issue.

Thanks
SCJP(1.4)
SCWCD
hi,

i am facing the following exception whenever i try to run the first sample program

tools used are:
eclipse3.2.1
jboss 4.0
jre 1.5

i have deployed the jar file calculator.jar and i am able to see it in jmx console,service =jndiview, javalangstring list, global jndi namespace still getting the following error while running client

Exception in thread "main" java.lang.RuntimeException: Could not resolve beanClass method from proxy call
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:199)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:398)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190)
at org.jboss.remoting.Client.invoke(Client.java:525)
at org.jboss.remoting.Client.invoke(Client.java:488)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
at $Proxy0.add(Unknown Source)
at by.iba.client.CalculatorClient.main(CalculatorClient.java:22)

CODE:

package by.iba.client;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import by.iba.ejb.StatelessCalculator;

public class CalculatorClient {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try
{
Context jndiContext=new InitialContext();
Object ref=jndiContext.lookup("StatelessCalculatorBean/remote");
StatelessCalculator calc=(StatelessCalculator)PortableRemoteObject.narrow(ref,StatelessCalculator.class);
System.out.println("4+3="+ calc.add(4,3));
System.out.println("4+3="+ calc.multiply(4,3));
System.out.println("4+3="+ calc.subtract(4,3));
System.out.println("4+3="+ calc.divide(4,3));
}catch(NamingException ne){
ne.printStackTrace();
}
}
}

---------------------------------------------------------------------------------------------------------------

package by.iba.ejb;

import javax.ejb.Remote;

@Remote
public interface StatelessCalculator {
public double add(double a, double b);

public double subtract(double a, double b);

public double divide(double a, double b);

public double multiply(double a, double b);
}
---------------------------------------------------------------

package by.iba.ejb;

import javax.ejb.Stateless;
import by.iba.ejb.StatelessCalculator;

public @Stateless class StatelessCalculatorBean implements StatelessCalculator {

public double add(double a, double b) {
// TODO Auto-generated method stub
return a+b;
}

public double divide(double a, double b) {
// TODO Auto-generated method stub
if(b==0.0){
throw new javax.ejb.EJBException("Divided by zer0");
}

return a/b;
}

public double multiply(double a, double b) {
// TODO Auto-generated method stub
return a*b;
}

public double subtract(double a, double b) {
// TODO Auto-generated method stub
return a-b;
}

}

please reply as soon as possible as i feel stuck have checked so many times
cannot resolve by myself

Thanks