null pointer exception in setting thread local in java - java

guys i know it is dummy question but it gives me null ointer exception when writing myThreadLocal.set(str) .. here is my full code
threadLocalController.java
package threadLocalWeb;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class threadLocalController {
#RequestMapping(value = "/index")
public void doPost() {
threadLocal.setMyThreadLocal("name1");
threadLocal.getMyThreadLocal();
threadLocal.setMyThreadLocal("name2");
threadLocal.getMyThreadLocal();
}
}
threadLocal.java
package threadLocalWeb;
public class threadLocal {
private static ThreadLocal<String> myThreadLocal;
public threadLocal(){
myThreadLocal = new ThreadLocal<String>();
}
public static String getMyThreadLocal() {
return myThreadLocal.get();
}
public static void setMyThreadLocal(String str) {
myThreadLocal.set(str);
}
}
web.xml
<web-app version="2.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>sdnext</servlet-name>
<servlet-
class>org.springframework.web.servlet.DispatcherServlet</servlet-
class>
<init-param>
<param-name>contextConfigLocation</param-name><param-value>/WEB-
INF/config/sdnext-servlet.xml</param-value></init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sdnext</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
sdnext-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:annotation-driven/>
<context:annotation-config />
<context:component-scan base-package="threadLocalWeb"/>
</beans>
any help would be appreciated .. thanks

You never initialize your object... Use this instead.
public class ThreadLocal {
private static ThreadLocal<String> myThreadLocal = new ThreadLocal<>();
}

You need to call your threadLocal constructor to get your myThreadLocal initialized, or you have to do the initialization directly at variable declaration or in a static initializer block.

Related

org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver resolveException

I am new to java mvc,I am getting same error
Jan 27, 2020 10:48:16 PM org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver resolveException WARNING: Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json' not supported]
I am attaching my folder structure and code. can you please help me to proceed further
Folder structure
package com.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.bean.RegistrationBean;
#Controller
#RequestMapping("/helloworld")
public class InitController {
#RequestMapping(value="/register.do",method = RequestMethod.POST)
public String hello(#RequestBody RegistrationBean register,HttpServletRequest request) {
System.out.println("controller test");
return "asd";
}
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
registration
<script>
$(document).ready(function() {
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
$('#submit').click(function() {
debugger
var data = $("#registration").serializeObject();
var dataToPort = JSON.stringify(data);
$.ajax({
type : 'POST',
contentType: "application/json",
url : '../helloworld/register.do',
dataType : "json",
data : dataToPort,
cache : false,
success : function(result) {
debugger
}
});
});
});
mvc-dispatcher-servlet
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.controller"/>
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
Try do annotation in your controller the next way:
#RequestMapping(value="/register.do",method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)

HTTP Status 500 - Servlet.init() for servlet spring threw exception here is my code

controller,service and dao are in different package UserSer interface and UserService class is on package com.service UserDa interface and UserDao class is on package com.dao and Controller is on Package com.controller please help me with this , if i am doing this all on the same package its working but for different package its not working
thankyou
#Controller
public class UserController {
#Autowired
public UserSer userSer;
#RequestMapping(value="/get")
public void dummytest()
{
System.out.println(userSer.SayHii());
}
}
#Service("UserSer")
public class UserService implements UserSer{
#Autowired
public UserDa userDa;
public String SayHii() {
return userDa.Say();
}
}
#Repository("UserDa")
public class UserDao implements UserDa {
public String Say()
{
return "hiiiiiiiiiiiii";
}
}
web.xml
* <servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>*
spring-servlet.xml
*<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:ctx="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<ctx:annotation-config></ctx:annotation-config>
<mvc:annotation-driven/>
<ctx:component-scan base-package="com.controller"></ctx:component-scan>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
</bean>*

WARNING: No mapping found for HTTP request with URI [/SpringLoginApplication/] in DispatcherServlet with name 'SpringLoginApplication'

My project is a maven project when i run the project on tomcat it shows
org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringLoginApplication/] in DispatcherServlet with name 'SpringLoginApplication'
I tried all possibilities to resolve but all in vein, can somebody help me out to resolve this issue
my controller :
package com.spring.login.controller;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import com.spring.login.beans.Customer;
import com.spring.login.services.CustomerService;
import com.spring.login.validation.CustomerValidation;
#Controller
public class CustomerController {
#Autowired
private CustomerService customerService;
#RequestMapping(value="/" , method=RequestMethod.GET)
public String login(ModelMap model){
//model.put("Info", new Customer());
return "/login";
}
#RequestMapping(value="/register", method = RequestMethod.GET)
public String showForm(ModelMap model){
model.put("customerData", new Customer());
return "/register";
}
#RequestMapping(value= "/register", method= RequestMethod.POST)
public String saveForm(ModelMap model, #ModelAttribute("customerData") #Valid Customer customer, BindingResult br, HttpSession session){
CustomerValidation customerValidation = new CustomerValidation();
customerValidation.validate(customerValidation, br);
if(br.hasErrors()){
return "/register";
}
else{
customerService.saveCustomer(customer);
session.setAttribute("customer", customer);
return "redirect:success";
}
}
#RequestMapping(value="/logout", method = RequestMethod.GET)
public String logOut(ModelMap model, HttpSession session){
session.removeAttribute("customer");
return "redirect:login";
}
#RequestMapping(value="/success", method = RequestMethod.GET)
public String logOut(ModelMap model){
model.put("customer", new Customer());
return "redirect:success";
}
}
my web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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/web-app_3_0.xsd" >
<display-name>SpringLoginApplication</display-name>
<welcome-file-list>
<welcome-file>home.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<listener>
<listener-
class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>SpringLoginApplication</servlet-name>
<servlet-
class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/SpringLoginApplication-servlet.xml
</param-value>
</init-param>
<init-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringLoginApplication</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
my SpringLoginApplication-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.spring.login.controller" />
<context:component-scan base-package="com.spring.login.dao" />
<context:component-scan base-package="com.spring.login.beans" />
<context:component-scan base-package="com.spring.login.services" />
<context:component-scan base-package="com.spring.login.validation" />
<mvc:annotation-driven />
<context:annotation-config />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean class="com.spring.login.beans.Customer" init-method="getC_id" destroy-
method="getC_name">
<property name="c_id" value="1234"/>
<property name="c_name" value="Sanjay"/>
</bean>
</beans>
A working response would be highly appreciated!
ANY OTHER INFO REQUIRED, PLS LET ME KNOW
I had the same problem few days before, and I got bellow solution.
#Controller
#RequestMapping(value="/" )
public class CustomerController {
//do your stuff here
#RequestMapping(method=RequestMethod.GET)
public String login(ModelMap model){
//model.put("Info", new Customer());
return "/login";
}
//Rest of your stuff goes here
}
Since you have configured your Dispatcher servlet to handle your context in stead of all possibility which people generally do by adding this (/*), so above provided code snippet will work and redirect your context to /login which you want(if i'm not wrong). Cheers!!!!

Cannot access to resources when I add method = RequestMethod.POST

I have a problem with get access to resources folder with css and js and more in my project.
When I add #RequestMapping with a method = RequestMethod.POST I lose access to resource. Before everything is ok.
My Structure:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>medicine</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<context:component-scan base-package="pl.tomo" />
<jpa:repositories base-package="pl.tomo.repository"/>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
<tx:annotation-driven/>
</beans>
My controller
package pl.tomo.controller;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import pl.tomo.entity.Lek;
import pl.tomo.entity.Medicament;
import pl.tomo.service.LekService;
import pl.tomo.service.MedicamentService;
#Controller
public class IndexController {
#Autowired
private MedicamentService medicamentService;
#Autowired
private LekService lekService;
private List<Lek> listLek = new ArrayList<Lek>();
#RequestMapping(value = "/index", method = RequestMethod.GET)
public String index(Model model)
{
listLek = lekService.findAll();
model.addAttribute("listLek", listLek);
model.addAttribute("lek", new Lek());
return "index";
}
#RequestMapping(name = "/index", method = RequestMethod.POST)
public String add(#ModelAttribute("lek") Lek lek)
{
try {
lek.setDateOpen(new SimpleDateFormat("yyyy-MM-dd").parse(lek.getDateStringOpen()));
lek.setDateExpiration(new SimpleDateFormat("yyyy-MM-dd").parse(lek.getDateStringExpiration()));
lek.setDateEnd(new SimpleDateFormat("yyyy-MM-dd").parse(lek.getDateStringEnd()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Medicament medicament = medicamentService.findOne(lek.getLiczba());
lek.setMedicament(medicament);
lekService.save(lek);
return "redirect:/index";
}
}
and form from index.jsp
<form:form method="POST" commandName="lek" class="form-inline">
<form:input path="dateStringOpen" cssClass="form-control" />
<form:input path="dateStringExpiration" cssClass="form-control" />
<form:input path="dateStringEnd" cssClass="form-control" />
<input type="submit" value="Dodaj lek" Class="btn btn-default" />
</form:form>
And i want to get to localhost:8080/resources/core/css/bootstrap.min.css and i have
HTTP ERROR 405
Problem accessing /resources/core/css/bootstrap.min.css. Reason:
Request method 'GET' not supported
When I remove
#RequestMapping(name = "/index", method = RequestMethod.POST)
public String add(#ModelAttribute("lek") Lek lek)
{
try {
lek.setDateOpen(new SimpleDateFormat("yyyy-MM-dd").parse(lek.getDateStringOpen()));
lek.setDateExpiration(new SimpleDateFormat("yyyy-MM-dd").parse(lek.getDateStringExpiration()));
lek.setDateEnd(new SimpleDateFormat("yyyy-MM-dd").parse(lek.getDateStringEnd()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Medicament medicament = medicamentService.findOne(lek.getLiczba());
lek.setMedicament(medicament);
lekService.save(lek);
return "redirect:/index";
}
I have access to file localhost:8080/resources/core/css/bootstrap.min.css
Can you help me?
I've configured access to my resources differently. For starters, I use annotations only. From there, I added a resource handler:
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
I have changed servlet mapping from
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
to
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
<url-pattern>*.htm</url-pattern>
<url-pattern>*.json</url-pattern>
<url-pattern>*.xml</url-pattern>
</servlet-mapping>
and it works

Returning object with EJB 3

I'm trying to work with the EJB 3, but I'm missing something.
Initially I created a stateless bean that I called through the controller of the mvc.
The bean contained a method that returned a String.
Now, I'm wiling to go to the next level, namely I'm trying to create a bean that returns an object instead of a string.
Persona.java
package com.pojo;
import java.io.Serializable;
public class Persona implements Serializable {
private static final long serialVersionUID = 1L;
String nome;
int eta;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public int getEta() {
return eta;
}
public void setEta(int eta) {
this.eta = eta;
}
}
RitornaPersonaRemote.java
package com.demo.view;
import com.pojo.Persona;
public interface RitornaPersonaRemote {
public Persona getPersona();
}
RitornaPersona.java
package com.demo;
import com.demo.view.RitornaPersonaRemote;
#Stateless
#Remote(RitornaPersonaRemote.class)
public class RitornaPersona implements RitornaPersonaRemote {
public Persona getPersona(){
Persona p = new Persona();
p.setEta(18);
p.setNome("tizio");
return p;
}
}
Client side
My_controller.java
package controller;
import javax.ejb.EJB;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.demo.view.RitornaPersonaRemote;
#Controller
public class My_Controller {
#EJB
private RitornaPersonaRemote rp;
#RequestMapping("testpage")
public ModelAndView mostraPagina(){
ModelAndView model = new ModelAndView();
model.setViewName("testpage");
model.addObject("hello", "nome --> " + persona.getPersona().getNome());
return model;
}
}
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<!-- enable autowire -->
<context:annotation-config/>
<context:spring-configured/>
<jee:local-slsb id="RitornaPersona"
jndi-name="java:app/RitornaPersonaSenzaClient/RitornaPersona!com.demo.view.RitornaPersonaRemote"
business-interface="com.demo.view.RitornaPersonaRemote" />
</beans>
spring-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<context:component-scan base-package="controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<jee:jndi-lookup id="RitornaPersonaSenzaClient" jndi-name="com.demo.view.RitornaPersonaRemote"/>
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
<property name="alwaysUseJndiLookup" value="true" />
</bean>
</beans>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" 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/web-app_2_5.xsd">
<display-name>RitornaPersonaWeb</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>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<display-name>spring</display-name>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<ejb-ref>
<description>
</description>
<ejb-ref-name>RitornaPersonaSenzaClient</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home></home>
<remote>com.demo.view.RitornaPersonaRemote</remote>
<ejb-link>RitornaPersona</ejb-link>
</ejb-ref>
</web-app>
The errors that I'm getting are pasted here:
http://justpaste.it/gfs3
Please, can someone tell me were are my mistakes?
I looked on lots of guide, but I lost the path.

Categories